Skip to content

Commit

Permalink
feat: add cargo nextest support
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Chi <iskyzh@gmail.com>
  • Loading branch information
skyzh committed Mar 17, 2022
1 parent e8ae56d commit 180e623
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ pub(crate) enum Subcommand {
)]
Clean(CleanOptions),

/// Run tests with cargo nextest
#[clap(
bin_name = "cargo llvm-cov nextest",
max_term_width(MAX_TERM_WIDTH),
setting(AppSettings::DeriveDisplayOrder)
)]
Nextest,

// internal (unstable)
#[clap(
bin_name = "cargo llvm-cov demangle",
Expand Down
36 changes: 36 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@ fn try_main() -> Result<()> {
writer.set("CARGO_LLVM_COV_TARGET_DIR", cx.ws.metadata.target_directory.as_str());
}

Some(Subcommand::Nextest) => {
let cx = &context_from_args(&mut args, false)?;

clean::clean_partial(cx)?;
create_dirs(cx)?;
match (args.no_run, cx.cov.no_report) {
(false, false) => {
run_nextest(cx, &args)?;
generate_report(cx)?;
}
(false, true) => {
run_nextest(cx, &args)?;
}
(true, false) => {
generate_report(cx)?;
}
(true, true) => unreachable!(),
}
}

None => {
let cx = &context_from_args(&mut args, false)?;
let tmp = term::warn(); // The following warnings should not be promoted to an error.
Expand Down Expand Up @@ -274,6 +294,22 @@ fn run_test(cx: &Context, args: &Args) -> Result<()> {
Ok(())
}

fn run_nextest(cx: &Context, args: &Args) -> Result<()> {
let mut cargo = cx.cargo();

set_env(cx, &mut cargo);

cargo.arg("nextest").arg("run");

cargo::test_args(cx, args, &mut cargo);

if term::verbose() {
status!("Running", "{}", cargo);
}
cargo.stdout_to_stderr().run()?;
Ok(())
}

fn run_run(cx: &Context, args: &RunOptions) -> Result<()> {
let mut cargo = cx.cargo();

Expand Down

0 comments on commit 180e623

Please sign in to comment.