`xtask::utils::run_capturing_stdout`: handle `#[should_error]`-tests
@@ -25,6 +25,15 @@ pub fn run_capturing_stdout(cmd: &mut Command) -> anyhow::Result<String> {
match output.status.success() {
true => Ok(str::from_utf8(&output.stdout)?.to_string()),
false => {
+ // #[shoud_error]-tests return non-zero code
+ if output.status.code() == Some(1) {
+ let stdout = str::from_utf8(&output.stdout)?;
+ if stdout.contains(
+ "`#[should_error]` test failed with outcome: Ok(this should have returned `Err`)",
+ ) {
+ return Ok(stdout.to_string());
+ }
+ }
eprintln!("{}", str::from_utf8(&output.stderr)?.dimmed());
Err(anyhow!(""))
}
