Skip to content

cargo test --no-run prints executable names, even with --message-format json (or json-render-diagnostics) #10684

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

Closed
sunshowers opened this issue May 20, 2022 · 4 comments · Fixed by #10691
Labels
C-bug Category: bug Command-test E-easy Experience: Easy

Comments

@sunshowers
Copy link
Contributor

Problem

Hi there, I'm the primary author of cargo nextest, a tool that wraps cargo test. Part of how nextest works is separating out the build and run phases: for the build phase, nextest runs cargo test --no-run --message-format json-render-diagnostics to gather a list of test binaries.

With cargo 1.60 or below, this integrated well with the UI:

image

However, with 1.61 it looks like it prints out all the executable names before starting any tests.

image

Steps

cargo test --no-run --message-format json-render-diagnostics

Possible Solution(s)

I think this feature makes a lot of sense if not invoked from a programmatic context, but I believe executable names should not be printed out if JSON output is requested.

Notes

No response

Version

cargo 1.61.0 (a028ae4 2022-04-29)
release: 1.61.0
commit-hash: a028ae42fc1376571de836be702e840ca8e060c2
commit-date: 2022-04-29
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1m)
os: Pop!_OS 22.04 (jammy) [64-bit]
@sunshowers sunshowers added the C-bug Category: bug label May 20, 2022
@ehuss
Copy link
Contributor

ehuss commented May 20, 2022

Yea, sounds reasonable to not show that with --message-format json.

@ehuss ehuss added the E-easy Experience: Easy label May 20, 2022
@danilhendrasr
Copy link
Contributor

Hey, I saw this issue marked as E-easy. I'm new to cargo's code base but I'm interested in contributing and this seems like a good starting point. Can I work on it?

@weihanglo
Copy link
Member

@danilhendrasr Definitely yes. Go ahead!

Basically, the message Executable unittests ... is from display_no_run_information. You can determine whether or not to print the message by something like TestOptions.compile_opts.build_config.emit_json(). You may also want to add new tests if needed.

@danilhendrasr
Copy link
Contributor

Got it, thank you for the hints!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-test E-easy Experience: Easy
Projects
None yet
5 participants