Skip to content

Commit a14d682

Browse files
davsclausclaude
andcommitted
CAMEL-26494: camel-jbang - camel run --dev with a source directory does not reload the routes when a Citrus test changes
The reload pattern of dev mode with a source directory now leaves out the Citrus tests of the project (*.citrus.*, such as test/orders.citrus.it.yaml, run with camel test run), as it does the data folders of --data-dir. They are not routes, so a change of them only restarted every route for nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
1 parent 07f5c40 commit a14d682

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

‎core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadDataDirTest.java‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,27 @@ public void testAFilePatternExcludeLeavesOutFilesNotFolders() throws Exception {
119119
assertThat(scanNames()).containsExactly("readme.txt", "shop.camel.yaml");
120120
}
121121

122+
@Test
123+
public void testCitrusTestsAreNotWatched() throws Exception {
124+
// CAMEL-26494: the pattern of camel run --dev with a source directory leaves the Citrus tests out
125+
Files.createDirectories(dir.resolve("test"));
126+
Files.writeString(dir.resolve("test/orders.citrus.it.yaml"), "a test");
127+
Files.writeString(dir.resolve("orders.citrus.it.xml"), "a test");
128+
start("*,!**/*.citrus.*,!inbox/**");
129+
130+
assertThat(strategy.isExcludedDirectory(dir.resolve("test"))).isFalse();
131+
assertThat(scanNames()).containsExactly("shop.camel.yaml");
132+
133+
// editing a test is no change of the routes
134+
Files.writeString(dir.resolve("test/orders.citrus.it.yaml"), "a test, changed");
135+
Files.writeString(dir.resolve("test/payments.citrus.it.yaml"), "another test");
136+
assertThat(scanNames()).isEmpty();
137+
138+
// a route next to the tests is still watched
139+
Files.writeString(dir.resolve("test/stub.camel.yaml"), "a stub");
140+
assertThat(scanNames()).containsExactly("stub.camel.yaml");
141+
}
142+
122143
@Test
123144
public void testRepeatedReloadsForOneFolderWarnOnce() {
124145
start("*");

‎docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ camel.jbang.dataDir=inbox,archive
9797
Dev mode then does not watch these folders, nor the folders in them. When the routes keep reloading for files in one
9898
folder, Camel logs a warning that names the folder.
9999

100+
The Citrus tests of the project (`*.citrus.*` files, such as `test/orders.citrus.it.yaml`, run with `camel test run`)
101+
are not routes either: dev mode does not reload the routes when they change.
102+
100103
=== Live reload of resource files
101104

102105
In dev mode, Camel disables `contentCache` on resource-based components (such as `xslt`)

‎dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTest.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,11 @@ public void shouldParseDataDirOption() throws Exception {
276276
@Test
277277
void sourceDirReloadPatternLeavesTheDataDirsOut() {
278278
// CAMEL-25670: the routes read and write the files of a data folder, which must not reload them
279-
assertThat(RunPipeline.sourceDirReloadPattern(null)).isEqualTo("*");
280-
assertThat(RunPipeline.sourceDirReloadPattern("inbox")).isEqualTo("*,!inbox/**");
279+
// CAMEL-26494: nor must a Citrus test of the project, which is not a route
280+
assertThat(RunPipeline.sourceDirReloadPattern(null)).isEqualTo("*,!**/*.citrus.*");
281+
assertThat(RunPipeline.sourceDirReloadPattern("inbox")).isEqualTo("*,!**/*.citrus.*,!inbox/**");
281282
assertThat(RunPipeline.sourceDirReloadPattern(" inbox , ./archive/ ,data\\in,"))
282-
.isEqualTo("*,!inbox/**,!archive/**,!data/in/**");
283+
.isEqualTo("*,!**/*.citrus.*,!inbox/**,!archive/**,!data/in/**");
283284
}
284285

285286
@Test

‎dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,13 +1137,15 @@ private static boolean isReloadRecursive(String reload) {
11371137
}
11381138

11391139
/**
1140-
* The reload pattern of dev mode with a source directory: every file under it, except the data folders
1140+
* The reload pattern of dev mode with a source directory: every file under it, except the Citrus tests of the
1141+
* project ({@code *.citrus.*}, run with camel test run), which are not routes (CAMEL-26494), and the data folders
11411142
* (--data-dir), whose files the routes read and write: a change there is not a change of the sources, and reloading
11421143
* the routes for it restarts them, so they write again and reload again (CAMEL-25670).
11431144
*/
11441145
public static String sourceDirReloadPattern(String dataDir) {
11451146
StringJoiner sj = new StringJoiner(",");
11461147
sj.add("*");
1148+
sj.add("!**/*.citrus.*");
11471149
if (dataDir != null) {
11481150
for (String dir : dataDir.split(",")) {
11491151
dir = dir.trim().replace('\\', '/');

0 commit comments

Comments
 (0)