Skip to content

Commit

Permalink
Add --ignore-run-fail option
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed May 30, 2022
1 parent 8d8669a commit 0fbcda7
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 4 deletions.
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

0 comments on commit 0fbcda7

Please sign in to comment.