Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --ignore-run-fail option #174

Merged
merged 1 commit into from
May 30, 2022
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ OPTIONS:
--no-fail-fast
Run all tests regardless of failure

--ignore-run-fail
Run all tests regardless of failure and generate report

If tests failed but report generation succeeded, exit with a status of 0.

-q, --quiet
Display one character per test instead of one line

Expand Down
9 changes: 9 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ pub(crate) struct Args {
/// Run all tests regardless of failure
#[clap(long)]
pub(crate) no_fail_fast: bool,
/// Run all tests regardless of failure and generate report
///
/// If tests failed but report generation succeeded, exit with a status of 0.
#[clap(
long,
// --ignore-run-fail implicitly enable --no-fail-fast.
conflicts_with = "no-fail-fast",
)]
pub(crate) ignore_run_fail: bool,
/// Display one character per test instead of one line
#[clap(short, long, conflicts_with = "verbose")]
pub(crate) quiet: bool,
Expand Down
34 changes: 30 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,38 @@ fn run_test(cx: &Context, args: &Args) -> Result<()> {
cargo.arg("-Z");
cargo.arg("doctest-in-workspace");
}
cargo::test_args(cx, args, &mut cargo);

if term::verbose() {
status!("Running", "{}", cargo);
if args.ignore_run_fail {
let mut cargo_no_run = cargo.clone();
if !args.no_run {
cargo_no_run.arg("--no-run");
}
cargo::test_args(cx, args, &mut cargo_no_run);
if term::verbose() {
status!("Running", "{}", cargo_no_run);
cargo_no_run.stdout_to_stderr().run()?;
} else {
// Capture output to prevent duplicate warnings from appearing in two runs.
cargo_no_run.run_with_output()?;
}
drop(cargo_no_run);

cargo.arg("--no-fail-fast");
cargo::test_args(cx, args, &mut cargo);
if term::verbose() {
status!("Running", "{}", cargo);
}
if let Err(e) = cargo.stdout_to_stderr().run() {
warn!("{}", e);
}
} else {
cargo::test_args(cx, args, &mut cargo);
if term::verbose() {
status!("Running", "{}", cargo);
}
cargo.stdout_to_stderr().run()?;
}
cargo.stdout_to_stderr().run()?;

Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ macro_rules! cmd {

// A builder for an external process, inspired by https://github.com/rust-lang/cargo/blob/0.47.0/src/cargo/util/process_builder.rs
#[must_use]
#[derive(Clone)]
pub(crate) struct ProcessBuilder {
/// The program to execute.
program: OsString,
Expand Down
5 changes: 5 additions & 0 deletions tests/long-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ OPTIONS:
--no-fail-fast
Run all tests regardless of failure

--ignore-run-fail
Run all tests regardless of failure and generate report

If tests failed but report generation succeeded, exit with a status of 0.

-q, --quiet
Display one character per test instead of one line

Expand Down
3 changes: 3 additions & 0 deletions tests/short-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ OPTIONS:
--no-fail-fast
Run all tests regardless of failure

--ignore-run-fail
Run all tests regardless of failure and generate report

-q, --quiet
Display one character per test instead of one line

Expand Down