Closed lovelymono closed 2 years ago
Running cargo nextest run in a workspace containing two libraries, lexer and parser, and a binary, soilc, produces incorrect padded width of crate names in the runner reporter:
cargo nextest run
lexer
parser
soilc
~/d/soil > cargo nextest run Finished test [unoptimized] target(s) in 0.01s Executable unittests src/lib.rs (target/x86_64-unknown-linux-musl/debug/deps/lexer-f26b099b66f61ac0) Executable unittests src/lib.rs (target/x86_64-unknown-linux-musl/debug/deps/parser-10e48dd98bd493db) Executable unittests src/main.rs (target/x86_64-unknown-linux-musl/debug/deps/soilc-d15e0318b1d9c4c2) Starting 12 tests across 3 binaries PASS [ 0.001s] lexer tests::identifier_underscore PASS [ 0.001s] lexer tests::identifier_alphanumeric PASS [ 0.001s] lexer tests::identifier_mixed_case PASS [ 0.001s] lexer tests::identifier PASS [ 0.001s] lexer tests::identifier_single_character PASS [ 0.040s] parser tests::number PASS [ 0.040s] lexer tests::number PASS [ 0.040s] lexer tests::keyword_func PASS [ 0.040s] lexer tests::whitespace PASS [ 0.040s] lexer tests::invalid_identifier PASS [ 0.040s] parser tests::advancing_past_none PASS [ 0.040s] lexer tests::invalid_hex_number Summary [ 0.040s] 12 tests run: 12 passed, 0 skipped
This happens because the width calculation also takes into a consideration binary soilc::bin/soilc, which contains no test cases.
soilc::bin/soilc
The simplest fix is to filter out crates for which testcases field is 0, which produces the expected output:
testcases
~/d/soil > cargo nextest run Finished test [unoptimized] target(s) in 0.01s Executable unittests src/lib.rs (target/x86_64-unknown-linux-musl/debug/deps/lexer-f26b099b66f61ac0) Executable unittests src/lib.rs (target/x86_64-unknown-linux-musl/debug/deps/parser-10e48dd98bd493db) Executable unittests src/main.rs (target/x86_64-unknown-linux-musl/debug/deps/soilc-d15e0318b1d9c4c2) Starting 12 tests across 3 binaries PASS [ 0.001s] lexer tests::identifier PASS [ 0.047s] lexer tests::identifier_mixed_case PASS [ 0.047s] parser tests::number PASS [ 0.047s] lexer tests::number PASS [ 0.047s] lexer tests::invalid_identifier PASS [ 0.047s] lexer tests::identifier_single_character PASS [ 0.047s] parser tests::advancing_past_none PASS [ 0.047s] lexer tests::keyword_func PASS [ 0.047s] lexer tests::identifier_underscore PASS [ 0.047s] lexer tests::whitespace PASS [ 0.047s] lexer tests::invalid_hex_number PASS [ 0.047s] lexer tests::identifier_alphanumeric Summary [ 0.048s] 12 tests run: 12 passed, 0 skipped
Since it's a really small fix, here's the diff output, which fixes this issue:
diff --git a/nextest-runner/src/list/test_list.rs b/nextest-runner/src/list/test_list.rs index 4afaabe..b3d8f86 100644 --- a/nextest-runner/src/list/test_list.rs +++ b/nextest-runner/src/list/test_list.rs @@ -341,6 +341,7 @@ impl<'g> TestList<'g> { pub fn iter(&self) -> impl Iterator<Item = (&Utf8Path, &RustTestSuite)> + '_ { self.rust_suites .iter() + .filter(|(_, info)| info.testcases.len() > 0) .map(|(path, info)| (path.as_path(), info)) }
Thank you! I'll land a fix for this in the next release.
Neat!
Running
cargo nextest run
in a workspace containing two libraries,lexer
andparser
, and a binary,soilc
, produces incorrect padded width of crate names in the runner reporter:This happens because the width calculation also takes into a consideration binary
soilc::bin/soilc
, which contains no test cases.The simplest fix is to filter out crates for which
testcases
field is 0, which produces the expected output:Since it's a really small fix, here's the diff output, which fixes this issue: