-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make --nocapture
optional
#12737
Comments
I would implement this by making cargo args configurable in general, allowing the user to enter an arbitrary string. There's nothing particularly special about --nocapture that entitles it to special treatment compared to other cargo args. I would also make it empty by default, as in --nocapture should not be enabled unless the user explicitly turns it on by typing it, due to the reasoning in #13040. |
A possible complication in "just" making test arguments customizable: there are both arguments to cargo and arguments to the test binary, and users might want to specify one or both. I think accepting a custom argument list that may include |
This feature would be great to have. The current behavior is opaque and the presence of This makes test suites that make use of
(this output is with only a single |
Right, |
* Added config `runnables.extraTestBinaryArgs` to control the args. * The default is `--show-output` rather than `--nocapture` to prevent unreadable output when 2 or more tests fail or print output at once. * Renamed variables in `CargoTargetSpec::runnable_args()` for clarity. Fixes <rust-lang#12737>.
* Added config `runnables.extraTestBinaryArgs` to control the args. * The default is `--show-output` rather than `--nocapture` to prevent unreadable output when 2 or more tests fail or print output at once. * Renamed variables in `CargoTargetSpec::runnable_args()` for clarity. Fixes <rust-lang/rust-analyzer#12737>.
"rust-analyzer.runnables.extraTestBinaryArgs": [
"--nocapture"
], |
I personally feel strongly that The more "stuff" happens between the user and the test binary, the harder it is to realize what's happening. The problem with interleaved test output should be fixed by making sure that passing tests do not print anything. Interleaving output is a feature when you debug a tricky concurrency bug caused by interraction between the tests. It is of course file to have an option to use To reiterate, this is my personal opinion, and, while I do hold is strongly, it could be wrong. |
Regarding the treatment of stdout, I can see reasonable arguments on both sides, but I don't think these arguments are relevant to rust-analyzer. These arguments are more relevant to rustc. If the default behavior should be to not capture stdout, then why shouldn't we change rustc to have that behavior? I believe that rust-analyzer's defaults should be consistent with rustc's defaults, whatever they are. Discrepancies in behavior are a source of confusion and frustration. |
For what it’s worth, I'll give some additional background, as the author of this issue and PR, since our experiences of testing seem to be very different: I find it very frequently useful to write tests that “log” their actions with simple Instead of “passing tests do not print anything”, the property I like is “I don't see anything from passing tests”, which is what the test harness’s default mode (not
I agree with the logic, but the case is rare for me: I have never had tests interfere with each other (in the kind of code I write, which is on the “avoid global state at nearly all costs” side of things), and hanging tests are very rare and usually need more intervention than just being able to look at the output in Also, when RA used One exception: I do think it would make sense to pass |
When running tests, rust-analyzer unconditionally adds
--nocapture
to the test arguments. I would like this to be optional, because using--nocapture
leads to sometimes-unreadable interleaved output, especially when two tests fail simultaneously, or when successful tests are producing verbose output intended to be read only if the test fails.The text was updated successfully, but these errors were encountered: