Skip to content

Commit

Permalink
Merge #223
Browse files Browse the repository at this point in the history
223: Set NEXTEST_TEST_THREADS=1 for nextest r=taiki-e a=taiki-e

Attempt to fix nextest-rs/nextest#652.

Co-authored-by: Taiki Endo <[email protected]>
  • Loading branch information
bors[bot] and taiki-e authored Nov 26, 2022
2 parents 3d752d5 + 5f83983 commit 778e4fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ Note: AUR package is maintained by community, not maintainer of cargo-llvm-cov.

- Branch coverage is not supported yet. See [#8] and [rust-lang/rust#79649] for more.
- Support for doc tests is unstable and has known issues. See [#2] and [rust-lang/rust#79417] for more.
- All the tests are run with `RUST_TEST_THREADS=1` to work around [rust-lang/rust#91092]. You can pass `--test-threads` (e.g., `--test-threads=$(nproc)`) to override this behavior.
- All the tests are run with `RUST_TEST_THREADS=1` to work around [rust-lang/rust#91092]. You can pass `--test-threads` (e.g., `--test-threads=$(nproc)`) to override this behavior. (As for `nextest`, we also set `NEXTEST_TEST_THREADS=1`.)

See also [the code-coverage-related issues reported in rust-lang/rust](https://github.com/rust-lang/rust/labels/A-code-coverage).

Expand Down
16 changes: 11 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn try_main() -> Result<()> {
let stdout = io::stdout();
let writer =
&mut ShowEnvWriter { target: stdout.lock(), options: cx.args.show_env.clone() };
set_env(cx, writer)?;
set_env(cx, writer, IsNextest(true))?; // Include envs for nextest.
writer.set("CARGO_LLVM_COV_TARGET_DIR", cx.ws.metadata.target_directory.as_str())?;
}
Subcommand::Report => {
Expand Down Expand Up @@ -163,7 +163,9 @@ impl<W: io::Write> EnvTarget for ShowEnvWriter<W> {
}
}

fn set_env(cx: &Context, env: &mut dyn EnvTarget) -> Result<()> {
struct IsNextest(bool);

fn set_env(cx: &Context, env: &mut dyn EnvTarget, IsNextest(is_nextest): IsNextest) -> Result<()> {
fn push_common_flags(cx: &Context, flags: &mut String) {
if cx.ws.stable_coverage {
flags.push_str(" -C instrument-coverage");
Expand Down Expand Up @@ -252,6 +254,10 @@ fn set_env(cx: &Context, env: &mut dyn EnvTarget) -> Result<()> {
env.set("CARGO_INCREMENTAL", "0")?;
// Workaround for https://github.com/rust-lang/rust/issues/91092
env.set("RUST_TEST_THREADS", "1")?;
if is_nextest {
// Same as above
env.set("NEXTEST_TEST_THREADS", "1")?;
}
Ok(())
}

Expand All @@ -277,7 +283,7 @@ fn has_z_flag(args: &[String], name: &str) -> bool {
fn run_test(cx: &Context) -> Result<()> {
let mut cargo = cx.cargo();

set_env(cx, &mut cargo)?;
set_env(cx, &mut cargo, IsNextest(false))?;

cargo.arg("test");
if cx.args.doctests && !has_z_flag(&cx.args.cargo_args, "doctest-in-workspace") {
Expand Down Expand Up @@ -324,7 +330,7 @@ fn run_test(cx: &Context) -> Result<()> {
fn run_nextest(cx: &Context) -> Result<()> {
let mut cargo = cx.cargo();

set_env(cx, &mut cargo)?;
set_env(cx, &mut cargo, IsNextest(true))?;

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

Expand All @@ -345,7 +351,7 @@ fn run_nextest(cx: &Context) -> Result<()> {
fn run_run(cx: &Context) -> Result<()> {
let mut cargo = cx.cargo();

set_env(cx, &mut cargo)?;
set_env(cx, &mut cargo, IsNextest(false))?;

if cx.args.ignore_run_fail {
{
Expand Down

0 comments on commit 778e4fd

Please sign in to comment.