diff --git a/crates/forge/bin/cmd/watch.rs b/crates/forge/bin/cmd/watch.rs index 09eb8c66683b..10562ba1295c 100644 --- a/crates/forge/bin/cmd/watch.rs +++ b/crates/forge/bin/cmd/watch.rs @@ -260,7 +260,7 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { let config: Config = args.build_args().into(); let filter = args.filter(&config); // Marker to check whether to override the command. - let _no_reconfigure = filter.args().test_pattern.is_some() || + let no_reconfigure = filter.args().test_pattern.is_some() || filter.args().path_pattern.is_some() || filter.args().contract_pattern.is_some() || args.watch.run_all; @@ -303,7 +303,10 @@ pub async fn watch_test(args: TestArgs) -> Result<()> { trace!(?file, "reconfigure test command"); - command.arg("--match-path").arg(&file); + // Before appending `--match-path`, check if it already exists + if !no_reconfigure { + command.arg("--match-path").arg(file); + } }, )?; run(config).await?;