This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 4c8538b63242 CAMEL-26494: camel-jbang - camel run --dev with a source 
directory does not reload the routes when a file in the test folder changes 
(#28874)
4c8538b63242 is described below

commit 4c8538b632421aa84cd6c6e0c5d792fef49a80da
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 5 13:42:20 2026 +0100

    CAMEL-26494: camel-jbang - camel run --dev with a source directory does not 
reload the routes when a file in the test folder changes (#28874)
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../support/RouteWatcherReloadDataDirTest.java     | 28 ++++++++++++++++++++++
 .../modules/ROOT/pages/camel-jbang-running.adoc    |  4 ++++
 .../camel/dsl/jbang/core/commands/RunTest.java     |  7 +++---
 .../apache/camel/dsl/jbang/run/RunPipeline.java    |  8 ++++---
 4 files changed, 41 insertions(+), 6 deletions(-)

diff --git 
a/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadDataDirTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadDataDirTest.java
index 16a9e8ad51cd..16eeb1f692b3 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadDataDirTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadDataDirTest.java
@@ -119,6 +119,34 @@ public class RouteWatcherReloadDataDirTest extends 
ContextTestSupport {
         assertThat(scanNames()).containsExactly("readme.txt", 
"shop.camel.yaml");
     }
 
+    @Test
+    public void testTestFolderIsNotWatched() throws Exception {
+        // CAMEL-26494: the pattern of camel run --dev with a source directory 
leaves the test folder out, with the
+        // Citrus tests of the project (whatever their name) and their data
+        Files.createDirectories(dir.resolve("test/payloads"));
+        Files.writeString(dir.resolve("test/orders.citrus.it.yaml"), "a test");
+        Files.writeString(dir.resolve("test/orders.citrus-it.yaml"), "a test");
+        Files.writeString(dir.resolve("test/orders.feature"), "a test");
+        Files.writeString(dir.resolve("test/payloads/order.json"), "{}");
+        start("*,!test/**,!inbox/**");
+
+        assertThat(strategy.isExcludedDirectory(dir.resolve("test"))).isTrue();
+        assertThat(scanNames()).containsExactly("shop.camel.yaml");
+
+        // editing or adding a test, or its data, is no change of the routes
+        Files.writeString(dir.resolve("test/orders.citrus.it.yaml"), "a test, 
changed");
+        Files.writeString(dir.resolve("test/payments.citrus.it.yaml"), 
"another test");
+        Files.writeString(dir.resolve("test/payloads/order.json"), 
"{\"id\":1}");
+        assertThat(scanNames()).isEmpty();
+
+        // a route in another folder is still watched, and so is a folder 
whose name only starts with test
+        Files.createDirectories(dir.resolve("routes"));
+        Files.createDirectories(dir.resolve("testing"));
+        Files.writeString(dir.resolve("routes/stub.camel.yaml"), "a stub");
+        Files.writeString(dir.resolve("testing/other.camel.yaml"), "a route");
+        assertThat(scanNames()).containsExactly("other.camel.yaml", 
"stub.camel.yaml");
+    }
+
     @Test
     public void testRepeatedReloadsForOneFolderWarnOnce() {
         start("*");
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
index bf510a8f263c..6e255fe26591 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
@@ -97,6 +97,10 @@ camel.jbang.dataDir=inbox,archive
 Dev mode then does not watch these folders, nor the folders in them. When the 
routes keep reloading for files in one
 folder, Camel logs a warning that names the folder.
 
+The `test` folder of the source directory holds the Citrus tests of the 
project (such as `test/orders.citrus.it.yaml`,
+run with `camel test run`) and their data, which are not routes either: dev 
mode does not watch it, so editing a test
+does not reload the routes. Keep the routes out of `test`.
+
 === Live reload of resource files
 
 In dev mode, Camel disables `contentCache` on resource-based components (such 
as `xslt`)
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTest.java
index 6ee83315cc18..05e98e1e8e37 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTest.java
@@ -276,10 +276,11 @@ class RunTest extends CamelCommandBaseTestSupport {
     @Test
     void sourceDirReloadPatternLeavesTheDataDirsOut() {
         // CAMEL-25670: the routes read and write the files of a data folder, 
which must not reload them
-        assertThat(RunPipeline.sourceDirReloadPattern(null)).isEqualTo("*");
-        
assertThat(RunPipeline.sourceDirReloadPattern("inbox")).isEqualTo("*,!inbox/**");
+        // CAMEL-26494: nor must the test folder, with the Citrus tests of the 
project, which are not routes
+        
assertThat(RunPipeline.sourceDirReloadPattern(null)).isEqualTo("*,!test/**");
+        
assertThat(RunPipeline.sourceDirReloadPattern("inbox")).isEqualTo("*,!test/**,!inbox/**");
         assertThat(RunPipeline.sourceDirReloadPattern(" inbox , ./archive/ 
,data\\in,"))
-                .isEqualTo("*,!inbox/**,!archive/**,!data/in/**");
+                .isEqualTo("*,!test/**,!inbox/**,!archive/**,!data/in/**");
     }
 
     @Test
diff --git 
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
 
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
index aa756d8970cf..6123f15140d0 100644
--- 
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
+++ 
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
@@ -1137,13 +1137,15 @@ public class RunPipeline {
     }
 
     /**
-     * The reload pattern of dev mode with a source directory: every file 
under it, except the data folders
-     * (--data-dir), whose files the routes read and write: a change there is 
not a change of the sources, and reloading
-     * the routes for it restarts them, so they write again and reload again 
(CAMEL-25670).
+     * The reload pattern of dev mode with a source directory: every file 
under it, except the test folder, which holds
+     * the Citrus tests of the project (run with camel test run) and their 
data, none of them routes (CAMEL-26494), and
+     * the data folders (--data-dir), whose files the routes read and write: a 
change there is not a change of the
+     * sources, and reloading the routes for it restarts them, so they write 
again and reload again (CAMEL-25670).
      */
     public static String sourceDirReloadPattern(String dataDir) {
         StringJoiner sj = new StringJoiner(",");
         sj.add("*");
+        sj.add("!test/**");
         if (dataDir != null) {
             for (String dir : dataDir.split(",")) {
                 dir = dir.trim().replace('\\', '/');

Reply via email to