nextest-rs/nextest

Output file for Machine-readable output for test runs

lcheylus opened this issue · 2 comments

I'm testing the experimental feature for Machine-readable output for test runs to generate results in JSON format.

$ NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1 cargo nextest run --hide-progress-bar --message-format libtest-json-plus

The feature works as attended but the JSON ouputs are mixed with cargo-nextest ouput on stdout. It's not convenient to parse JSON outputs to generate infos after tests.
How could I have only the results in JSON format with this feature ?

Is it possible to implement a new parameter for output file (JSON format) ?

$ NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1 cargo nextest run --hide-progress-bar --profile ci --features "unix" --message-format libtest-json --output-file <OUT.json>

Thanks for the report. The JSON output goes to stdout while the human-readable output goes to stderr, so you can use > and 2> to work on the outputs individually.

I'd like to keep the UI generally similar to cargo — that doesn't expose this kind of option, but does split "json" and "json-render-diagnostics". I'd like to introduce that split before stabilizing the feature.

Thanks for your help. I redirect stdout outputs in a file (JSON format) and human-readable outputs are displayed on stderr (live output on my console):

NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1 cargo nextest run --hide-progress-bar --message-format libtest-json-plus 1>/tmp/test.json