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

davsclaus pushed a commit to branch fix/CAMEL-26494
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1cd52812df57b55586396f96fedb6e77052ad7a1
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 2 14:51:45 2026 +0100

    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 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../support/RouteWatcherReloadDataDirTest.java      | 21 +++++++++++++++++++++
 .../modules/ROOT/pages/camel-jbang-running.adoc     |  3 +++
 .../camel/dsl/jbang/core/commands/RunTest.java      |  7 ++++---
 .../org/apache/camel/dsl/jbang/run/RunPipeline.java |  4 +++-
 4 files changed, 31 insertions(+), 4 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..02b59713ec7e 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,27 @@ public class RouteWatcherReloadDataDirTest extends 
ContextTestSupport {
         assertThat(scanNames()).containsExactly("readme.txt", 
"shop.camel.yaml");
     }
 
+    @Test
+    public void testCitrusTestsAreNotWatched() throws Exception {
+        // CAMEL-26494: the pattern of camel run --dev with a source directory 
leaves the Citrus tests out
+        Files.createDirectories(dir.resolve("test"));
+        Files.writeString(dir.resolve("test/orders.citrus.it.yaml"), "a test");
+        Files.writeString(dir.resolve("orders.citrus.it.xml"), "a test");
+        start("*,!**/*.citrus.*,!inbox/**");
+
+        
assertThat(strategy.isExcludedDirectory(dir.resolve("test"))).isFalse();
+        assertThat(scanNames()).containsExactly("shop.camel.yaml");
+
+        // editing a test 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");
+        assertThat(scanNames()).isEmpty();
+
+        // a route next to the tests is still watched
+        Files.writeString(dir.resolve("test/stub.camel.yaml"), "a stub");
+        assertThat(scanNames()).containsExactly("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 a5db9aab6bb2..b346afc17758 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-running.adoc
@@ -91,6 +91,9 @@ 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 Citrus tests of the project (`*.citrus.*` files, such as 
`test/orders.citrus.it.yaml`, run with `camel test run`)
+are not routes either: dev mode does not reload the routes when they change.
+
 === 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 0ca5a3c8faab..59c089848a56 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
@@ -255,10 +255,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 a Citrus test of the project, which is not a 
route
+        
assertThat(RunPipeline.sourceDirReloadPattern(null)).isEqualTo("*,!**/*.citrus.*");
+        
assertThat(RunPipeline.sourceDirReloadPattern("inbox")).isEqualTo("*,!**/*.citrus.*,!inbox/**");
         assertThat(RunPipeline.sourceDirReloadPattern(" inbox , ./archive/ 
,data\\in,"))
-                .isEqualTo("*,!inbox/**,!archive/**,!data/in/**");
+                
.isEqualTo("*,!**/*.citrus.*,!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..b1416fca2e6e 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
+     * The reload pattern of dev mode with a source directory: every file 
under it, except the Citrus tests of the
+     * project ({@code *.citrus.*}, run with camel test run), which are not 
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("!**/*.citrus.*");
         if (dataDir != null) {
             for (String dir : dataDir.split(",")) {
                 dir = dir.trim().replace('\\', '/');

Reply via email to