Skip to content

Commit 438adcf

Browse files
authored
Merge pull request #148 from epage/error
Errorfix(trycmd): Error, instead of ignore, unknown bins
2 parents 165be6f + 95ca380 commit 438adcf

7 files changed

+22
-12
lines changed

schema.json

+6
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
"Bin": {
102102
"description": "Target under test",
103103
"oneOf": [
104+
{
105+
"type": "string",
106+
"enum": [
107+
"ignore"
108+
]
109+
},
104110
{
105111
"type": "object",
106112
"required": [

src/registry.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ impl BinRegistry {
3636
let bin = self.resolve_name(&name);
3737
Ok(bin)
3838
}
39+
crate::schema::Bin::Ignore => Ok(crate::schema::Bin::Ignore),
3940
crate::schema::Bin::Error(err) => Err(err),
4041
}
4142
}

src/runner.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,17 @@ impl Case {
321321
return Ok(output);
322322
}
323323

324-
#[allow(unused_variables)]
325324
match &step.bin {
326-
Some(crate::schema::Bin::Path(_)) => {}
327-
Some(crate::schema::Bin::Name(name)) => {
325+
// Will be handled by `Step::to_command`
326+
Some(crate::schema::Bin::Path(_))
327+
| Some(crate::schema::Bin::Name(_))
328+
| Some(crate::schema::Bin::Error(_))
329+
| None => {}
330+
Some(crate::schema::Bin::Ignore) => {
328331
// Unhandled by resolve
329-
snapbox::debug!("bin={:?} not found", name);
330332
assert_eq!(output.spawn.status, SpawnStatus::Skipped);
331333
return Ok(output);
332334
}
333-
Some(crate::schema::Bin::Error(_)) => {}
334-
// Unlike `Name`, this always represents a bug
335-
None => {}
336335
}
337336

338337
let cmd = step.to_command(cwd).map_err(|e| output.clone().error(e))?;

src/schema.rs

+2
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ impl Step {
448448
let bin = match &self.bin {
449449
Some(Bin::Path(path)) => Ok(path.clone()),
450450
Some(Bin::Name(name)) => Err(format!("Unknown bin.name = {}", name).into()),
451+
Some(Bin::Ignore) => Err("Internal error: tried to run an ignored bin".into()),
451452
Some(Bin::Error(err)) => Err(err.clone()),
452453
None => Err("No bin specified".into()),
453454
}?;
@@ -683,6 +684,7 @@ impl Env {
683684
pub enum Bin {
684685
Path(std::path::PathBuf),
685686
Name(String),
687+
Ignore,
686688
#[serde(skip)]
687689
Error(crate::Error),
688690
}

tests/cli_tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ fn cli_tests() {
2121
t.skip("tests/cmd/timeout.toml");
2222
}
2323
t.extend_vars([("[EXAMPLE]", "example")]).unwrap();
24+
t.register_bin("ignored-bin", trycmd::schema::Bin::Ignore);
2425
}

tests/cmd/ignored_bin.trycmd

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Ignored by test runner:
2+
```
3+
$ ignored-bin I have No Impact
4+
I'm ignored too
5+
6+
```

tests/cmd/unresolved.trycmd

-5
This file was deleted.

0 commit comments

Comments
 (0)