Skip to content

Commit

Permalink
Pass --color=... to libtest (#375)
Browse files Browse the repository at this point in the history
* Pass `--color=...` to libtest

Two parts to #367 :
- The libtest output, which this PR solves
  - I've hand-tested it
  - Possibly this becomes moot if `cargo` is changed to handle more of the output
- The `insta` output when insta is called by libtest; e.g. the diffs. There's not much we can do here, but [`CLICOLOR_FORCE`](http://bixense.com/clicolors/) works

* Update cargo-insta/src/cli.rs
  • Loading branch information
max-sixty committed Jun 3, 2023
1 parent 5bc79ed commit 2658173
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cargo-insta/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,18 +892,23 @@ fn prepare_test_runner<'snapshot_ref>(
proc.arg("--color");
proc.arg(color);
proc.args(extra_args);
let mut dashdash = false;
// Items after this are passed to the test runner
proc.arg("--");
if !cmd.no_quiet && matches!(test_runner, TestRunner::CargoTest) {
proc.arg("--");
proc.arg("-q");
dashdash = true;
}
if !cmd.cargo_options.is_empty() {
if !dashdash {
proc.arg("--");
}
proc.args(&cmd.cargo_options);
}
// Currently libtest uses a different approach to color, so we need to pass
// it again to get output from the test runner as well as cargo. See
// https://github.com/rust-lang/cargo/issues/1983 for more
match test_runner {
TestRunner::CargoTest | TestRunner::Auto => {
proc.arg(format!("--color={}", color));
}
_ => {}
};
Ok((proc, snapshot_ref_file, prevents_doc_run))
}

Expand Down

0 comments on commit 2658173

Please sign in to comment.