Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse test results from tests running with --quiet #184

Merged
merged 1 commit into from
May 2, 2024

Conversation

narpfel
Copy link
Contributor

@narpfel narpfel commented Apr 14, 2024

Running tests with -q/--quiet outputs a . per test instead of the test name. When a test fails, the test name and FAILED is still printed, but the test at the beginning of the line is omitted:

# run without `--quiet`
test tests::failing_test ... FAILED
# run with `--quiet`
tests::failing_test --- FAILED

This PR changes the regex used to parse the output to parse both output formats.

@Canop
Copy link
Owner

Canop commented Apr 14, 2024

Can you please build a test case which failed and is solved ?

@narpfel
Copy link
Contributor Author

narpfel commented Apr 15, 2024

Here’s an example that shows this:

bacon.toml:

default_job = "test"

[jobs.test]
command = [
    "cargo", "test", "--color", "always",
    "--", "--color", "always", # see https://github.com/Canop/bacon/issues/124
]
need_stdout = true

[jobs.testquiet]
command = [
    "cargo", "test", "--color", "always",
    "--", "--color", "always", # see https://github.com/Canop/bacon/issues/124
    "--quiet",
]
need_stdout = true


[keybindings]
z = "job:testquiet"

src/lib.rs:

#[cfg(test)]
mod tests {
    #[test]
    fn first_test() {}

    #[test]
    fn failing_test() {
        assert!(false, "message for first failing test");
    }

    #[test]
    fn third_test() {}

    #[test]
    fn another_failing_test() {
        assert!(false, "message for second failing test");
    }
}

Output when running the test job:

 t   test    2 fails

 1  failed: tests::failing_test
 thread 'tests::failing_test' panicked at src/lib.rs:8:9:
 message for first failing test

 2  failed: tests::another_failing_test
 thread 'tests::another_failing_test' panicked at src/lib.rs:16:9:
 message for second failing test

Output when running the testquiet job with the bacon 2af07e7 (current main):

 t   testquiet   Command error code: 101

    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.01s
     Running unittests src/lib.rs (target/debug/deps/t-32496683b92ff7c2)

running 4 tests
tests::another_failing_test --- FAILED
. 2/4
tests::failing_test --- FAILED
.
failures:

---- tests::another_failing_test stdout ----
thread 'tests::another_failing_test' panicked at src/lib.rs:16:9:
message for second failing test
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- tests::failing_test stdout ----
thread 'tests::failing_test' panicked at src/lib.rs:8:9:
message for first failing test


failures:
    tests::another_failing_test
    tests::failing_test

test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass `--lib`

And with this PR:

 t   testquiet    2 fails

 1  failed: tests::failing_test
 thread 'tests::failing_test' panicked at src/lib.rs:8:9:
 message for first failing test

 2  failed: tests::another_failing_test
 thread 'tests::another_failing_test' panicked at src/lib.rs:16:9:
 message for second failing test

Or did you mean an automated test?

@Canop
Copy link
Owner

Canop commented Apr 15, 2024

Or did you mean an automated test?

No, just enough to reproduce the problem.

@Canop
Copy link
Owner

Canop commented Apr 16, 2024

Here's why I asked: it doesn't seem to be solved with your fix (in my test on linux, even with your test case).

I'll look deeper if necessary but not immediately, I can't dive into this problem until end of last week.

@narpfel
Copy link
Contributor Author

narpfel commented Apr 16, 2024

it doesn't seem to be solved with your fix (in my test on linux, even with your test case).

I’m on nightly, and hadn’t realised that the output format was recently changed: rust-lang/rust#113518 So on stable (currently 1.77) this PR will not work (because the test name and FAILED are not printed), but on Rust 1.78+ it will work.

Sorry for the confusion!

@Canop Canop merged commit 8e09214 into Canop:main May 2, 2024
@narpfel narpfel deleted the parse-quiet-test-results branch September 26, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants