diff --git a/src/args.rs b/src/args.rs index 3af80ef..6cde51d 100644 --- a/src/args.rs +++ b/src/args.rs @@ -8,8 +8,6 @@ const OPTSET_OUTPUT: &str = "OUTPUT"; const OPTSET_BEHAVIOUR: &str = "BEHAVIOUR"; const OPTSET_WORKSPACES: &str = "WORKSPACES"; -// --watch-when-idle is now default - #[derive(Debug, Clone, clap::Parser)] #[clap(name = "cargo-watch", about, version)] pub struct Args { @@ -72,12 +70,15 @@ pub struct Args { )] pub no_dot_ignores: bool, - /// Don’t restart command while it’s still running + /// Restart the command set when events come in while it’s still running + /// + /// Note that this can lead to loops when the command set causes a watched file to change. In + /// that case, you should restrict what is watched with --watch and/or --ignore. #[clap( long, help_heading = OPTSET_BEHAVIOUR, )] - pub no_restart: bool, + pub restart: bool, /// Reserved for workspace support #[clap( diff --git a/src/config/runtime.rs b/src/config/runtime.rs index dcc1bb9..cf43433 100644 --- a/src/config/runtime.rs +++ b/src/config/runtime.rs @@ -132,10 +132,10 @@ pub fn runtime(args: &Args, command_order: Vec<&'static str>) -> Result) -> Result Outcome::DoNothing, "restart" => Outcome::both(Outcome::Stop, start), // "signal" => Outcome::Signal(signal), - // "queue" => Outcome::wait(start), _ => Outcome::DoNothing, }; diff --git a/tests/trycmd/unix/restart.trycmd b/tests/trycmd/unix/restart.trycmd index 984132b..e6f5d27 100644 --- a/tests/trycmd/unix/restart.trycmd +++ b/tests/trycmd/unix/restart.trycmd @@ -1,4 +1,4 @@ -This first one tests that test-cw behaves correctly: +This first one tests that test-cw behaves correctly on a single run: ``` $ test-cw -- @@ -13,15 +13,16 @@ out ``` -This one uses `--quit-after-n`. As the default is to restart the command on -event, we're looking for the second command to start in the middle of the -first. We ignore the output after the second start because the order of the -`ForceStop` message and the `in` message can vary. But we're looking for the -`quit-after-n` signalling message afterwards to check that Cargo Watch stopped. +This one uses `--quit-after-n`. With `--restart`, we restart the command on +event without waiting for it to stop, so we're looking for the second command +to start in the middle of the first. We ignore the output after the second +start because the order of the `ForceStop` message and the `in` message can +vary. But we're looking for the `quit-after-n` signalling message afterwards to +check that Cargo Watch stopped. ``` $ test-cw --touch File --touch Other --between 500 -- -> --quit-after-n 2 --postpone -S sh -s 'echo in; sleep 1; echo out' +> --restart --quit-after-n 2 --postpone -S sh -s 'echo in; sleep 1; echo out' ? 0 [[Running `echo in; sleep 1; echo out`]] in @@ -39,7 +40,7 @@ signalling from the tester. ``` $ test-cw --touch File --touch Other --between 500 --expect-timeout -- -> --postpone -S sh -s 'echo in; sleep 1; echo out' +> --restart --postpone -S sh -s 'echo in; sleep 1; echo out' ? 0 [[Running `echo in; sleep 1; echo out`]] in