-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add an option to run only a single test #7801
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
Comments
It turns out your second approach is actually already implemented! Albeit it's probably not documented well, but I believe that at least the first command line argument to the binary is a substring match done on test names to determine which tests should run. |
Oh! It works. Thank you :). I tried to find some documentation on the test |
That page describes the tests of rustc, but doesn't describe the test |
Indeed, it seems I misread the issue and thought that you were referring to running only a single test from the testsuite. |
(For anyone else: https://github.com/mozilla/rust/wiki/Doc-unit-testing.) |
Make useless_format recognize format!("") Closes rust-lang#7796 changelog: [`useless_format`] Fix for false negitive for `format!("")`
Hi,
often, when debugging, I need to run just one special test (often because I put
println
s around the debugged code and want to watch just the output produced by the misbehaving test). For now, I just comment out the other tests, but this is clearly unsatisfactory, partly because Rust's/* ... */
comments cannot be nested.I think it would be useful to add an option to temporarily select just one test or a small set of test and ignore the others. I came up with two approaches:
Mark the tests intended to be run by a special attribute, for example
#[test(only)]
,#[test_only]
or#[ignore_others]
. If there are more tests marked with this attribute, all of them should run. In fact, it is the inversion of the#[ignore]
attribute we have now.This is similar to
it.only "does something" { ... }
syntax of RSpec (compared to the usualit "does something" { ... }
) and similar BDD frameworks.Pass the compiled test runner a command-line argument with the name of the test the user wishes to run. In addition, this filtering can grow more sophisticated -- by regexes, modules, user-defined tags... Again, RSpec and the others usually allows something like this.
The advantage of the first, quick and compile-time approach is that it may be easy to implement and is quite useful during debugging, while the second doesn't require recompilation of the whole test code and could found other uses, besides debugging.
(sorry for my non-native English)
The text was updated successfully, but these errors were encountered: