Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ninja-xtask/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog ninja-xtask

## v0.2.6

- show stdout and exit status for failed commands

## v0.2.4 & 0.2.5

- fix build workflow for publishing binaries
Expand Down
2 changes: 1 addition & 1 deletion ninja-xtask/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ninja-xtask/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ninja-xtask"
version = "0.2.5"
version = "0.2.6"
edition = "2024"
readme = "README.md"
description = "xtask utilities that I use in most projects"
Expand Down
6 changes: 5 additions & 1 deletion ninja-xtask/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ impl From<Cmd> for Exit<()> {
println!("{}: OK", cmd.name);
Self::Ok(())
} else {
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
Self::Error(stderr.to_string())
Self::Error(format!(
"====== {} exited with {} ======\n-- stdout: --\n{}\n\n-- stderr: --\n{}",
cmd.name, output.status, stdout, stderr
))
}
}
Err(e) => {
Expand Down
12 changes: 11 additions & 1 deletion ninja-xtask/tests/fixture/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
enum foo { bar }
enum foo { bar }

#[cfg(test)]
mod tests {
#[test]
fn print_and_panic() {
println!("test printed to stdout");
dbg!("test dbg");
assert_eq!(5,7);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::fs;
use std::{fs, path::PathBuf};

use dircpy::copy_dir;
use ninja_xtask::commands::fmt;
use ninja_xtask::{
Exit,
commands::{fmt, test},
};
use tempfile::tempdir;

#[test]
Expand All @@ -23,3 +26,18 @@ fn fmt_fixture() {
assert_ne!(original, formatted);
dbg!(tmp.path());
}

#[test]
fn fail_output() {
let fixture = PathBuf::from("tests/fixture");
let run_tests = test(&fixture);
let exit = Exit::from(run_tests);
let Exit::Error(output) = exit else {
panic!("test didn't fail")
};
assert!(output.contains("====== tests exited with"));
assert!(output.contains("test printed to stdout"));
assert!(output.contains("test dbg"));
assert!(output.contains("left: 5"));
println!("{output}");
}
Loading