diff --git a/schema.json b/schema.json index c517e731..56306aa2 100644 --- a/schema.json +++ b/schema.json @@ -101,6 +101,12 @@ "Bin": { "description": "Target under test", "oneOf": [ + { + "type": "string", + "enum": [ + "ignore" + ] + }, { "type": "object", "required": [ diff --git a/src/registry.rs b/src/registry.rs index e8c4de2c..1a81ed66 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -36,6 +36,7 @@ impl BinRegistry { let bin = self.resolve_name(&name); Ok(bin) } + crate::schema::Bin::Ignore => Ok(crate::schema::Bin::Ignore), crate::schema::Bin::Error(err) => Err(err), } } diff --git a/src/runner.rs b/src/runner.rs index e4f4620e..a903ca65 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -321,6 +321,19 @@ impl Case { return Ok(output); } + match &step.bin { + // Will be handled by `Step::to_command` + Some(crate::schema::Bin::Path(_)) + | Some(crate::schema::Bin::Name(_)) + | Some(crate::schema::Bin::Error(_)) + | None => {} + Some(crate::schema::Bin::Ignore) => { + // Unhandled by resolve + assert_eq!(output.spawn.status, SpawnStatus::Skipped); + return Ok(output); + } + } + let cmd = step.to_command(cwd).map_err(|e| output.clone().error(e))?; let cmd_output = cmd .output() diff --git a/src/schema.rs b/src/schema.rs index af06aa98..5a200ce4 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -448,6 +448,7 @@ impl Step { let bin = match &self.bin { Some(Bin::Path(path)) => Ok(path.clone()), Some(Bin::Name(name)) => Err(format!("Unknown bin.name = {}", name).into()), + Some(Bin::Ignore) => Err("Internal error: tried to run an ignored bin".into()), Some(Bin::Error(err)) => Err(err.clone()), None => Err("No bin specified".into()), }?; @@ -683,6 +684,7 @@ impl Env { pub enum Bin { Path(std::path::PathBuf), Name(String), + Ignore, #[serde(skip)] Error(crate::Error), } diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs index 5ef816b4..cb764f64 100644 --- a/tests/cli_tests.rs +++ b/tests/cli_tests.rs @@ -21,4 +21,5 @@ fn cli_tests() { t.skip("tests/cmd/timeout.toml"); } t.extend_vars([("[EXAMPLE]", "example")]).unwrap(); + t.register_bin("ignored-bin", trycmd::schema::Bin::Ignore); } diff --git a/tests/cmd/ignored_bin.trycmd b/tests/cmd/ignored_bin.trycmd new file mode 100644 index 00000000..a4485aaa --- /dev/null +++ b/tests/cmd/ignored_bin.trycmd @@ -0,0 +1,6 @@ +Ignored by test runner: +``` +$ ignored-bin I have No Impact +I'm ignored too + +```