-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Libtest json output #45923
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
Libtest json output #45923
Conversation
5943a63
to
336d255
Compare
Auto-assigning to... r? @Kimundi |
Related issues are |
Your JSON example output confuses me. Wasn't there discussion of outputting every event as a JSON document? This was also discussed in rust-lang/rfcs#1284. |
Yeah, I might have misunderstood that one.
Edit: What you linked is a bit in conflict with @matklad request to have separate "events" for tests' start/finish. Otherwise, if the old RFC is acceptable, I'll close this PR and fix my code to match it. |
So that when an event happens (e.g., a test fails), it can be written
immediately. This way, it's easy to write a tool that displays the progress
interactively and without waiting for the whole test suite to finish.
Gilad Naaman <[email protected]> schrieb am Sa. 11. Nov. 2017 um
13:32:
… Yeah, I might have misunderstood that one.
Why would you want each of them to be separate document?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#45923 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABOXzru6Fo4jM19Db73IKClcy4dJtkTks5s1ZPZgaJpZM4QaL-C>
.
|
So then I have a few questions:
|
I have no authority to give any advice on how to do this, I'm just someone from the dev tools team who likes tools that offer machine readable output :)
I just wanted to point out that there's been discussion around this topic. The RFC was closed as the author wanted to rewrite it IIUC. As such, it was never accepted by the Rust team in charge.
Is there a good streaming JSON parser for Rust? I don't think serde_json supports this.
Instead of {
"events": [
{ "test": "t2", "event": "started" },
{ "test": "t2", "event": "failed" },
{ "test": "t1", "event": "started" },
{ "test": "t1", "event": "failed" }
],
"summary": { }
} you'd output something like { "type": "test", "event": "start", "name": "foo::t2" }
{ "type": "test", "event": "start", "name": "bar::t1" }
{ "type": "test", "event": "fail", "name": "foo::t2" }
{ "type": "test", "event": "success", "name": "bar:t1" }
{ "type": "final", "summary": { } }
Same as right now? Does it need to change in any way? When a test is started, you emit an event, when the test finishes (it thread ends) you emit another event depending on the result of the thread (panic/no panic basically). If you really wanted, you could capture stdout/stderr and emit it (line or timeout based) as events in-between, but I haven't really thought about this. |
I see. I'll contact the other maintainer to make sure I'm not ruining his work somehow. Thanks As for streaming parsers, I hacked one using serde https://github.com/Gilnaa/rusty3bar/blob/master/src/infinite_array.rs |
I'm excited to see work happening in this direction, I would love to have more easily machine readable test output. |
Libtest json output A revisit to my [last PR](#45923). Events are now more atomic, printed in a flat hierarchy. For the normal test output: ``` running 1 test test f ... FAILED failures: ---- f stdout ---- thread 'f' panicked at 'assertion failed: `(left == right)` left: `3`, right: `4`', f.rs:3:1 note: Run with `RUST_BACKTRACE=1` for a backtrace. failures: f test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ``` The JSON equivalent is: ``` { "type": "suite", "event": "started", "test_count": "1" } { "type": "test", "event": "started", "name": "f" } { "type": "test", "event": "failed", "name": "f" } { "type": "suite", "event": "failed", "passed": 0, "failed": 1, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": "0" } { "type": "test_output", "name": "f", "output": "thread 'f' panicked at 'assertion failed: `(left == right)` left: `3`, right: `4`', f.rs:3:1 note: Run with `RUST_BACKTRACE=1` for a backtrace. " } ```
Libtest json output A revisit to my [last PR](#45923). Events are now more atomic, printed in a flat hierarchy. For the normal test output: ``` running 1 test test f ... FAILED failures: ---- f stdout ---- thread 'f' panicked at 'assertion failed: `(left == right)` left: `3`, right: `4`', f.rs:3:1 note: Run with `RUST_BACKTRACE=1` for a backtrace. failures: f test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ``` The JSON equivalent is: ``` { "type": "suite", "event": "started", "test_count": "1" } { "type": "test", "event": "started", "name": "f" } { "type": "test", "event": "failed", "name": "f" } { "type": "suite", "event": "failed", "passed": 0, "failed": 1, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": "0" } { "type": "test_output", "name": "f", "output": "thread 'f' panicked at 'assertion failed: `(left == right)` left: `3`, right: `4`', f.rs:3:1 note: Run with `RUST_BACKTRACE=1` for a backtrace. " } ```
Libtest json output A revisit to my [last PR](#45923). Events are now more atomic, printed in a flat hierarchy. For the normal test output: ``` running 1 test test f ... FAILED failures: ---- f stdout ---- thread 'f' panicked at 'assertion failed: `(left == right)` left: `3`, right: `4`', f.rs:3:1 note: Run with `RUST_BACKTRACE=1` for a backtrace. failures: f test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ``` The JSON equivalent is: ``` { "type": "suite", "event": "started", "test_count": "1" } { "type": "test", "event": "started", "name": "f" } { "type": "test", "event": "failed", "name": "f" } { "type": "suite", "event": "failed", "passed": 0, "failed": 1, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": "0" } { "type": "test_output", "name": "f", "output": "thread 'f' panicked at 'assertion failed: `(left == right)` left: `3`, right: `4`', f.rs:3:1 note: Run with `RUST_BACKTRACE=1` for a backtrace. " } ```
Added an option to output the tests' summary in Json.
The exact format can use a good bikesheding.
A new "--format" flag is added, with the following options:
-q
-q
is now an alias to--format=terse
, but any--format=
overrides-q
Discussed a bit here: https://internals.rust-lang.org/t/alternate-libtest-output-format/6121/12
The actual code generating JSON is a bit messy. I thought about using serde, but I think it's simple enough, and as @matklad said, events should be outputted as they are ready.
Example:
Turns into