Skip to content

Rename test option --nocapture to --no-capture #24451

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
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
libtest: Rename test option --nocapture to --no-capture
Rust's built-in unit testing framework supports not capturing the output
of tests. The current flag `--nocapture` is inconsistent with the other
long name options, i.e., they are written in spinal-case (a.k.a.
kebab-case).

Codegen options `no-prepopulate-passes`, `no-vectorize-loops`,
`no-vectorize-slp`, `no-integrated-as`, and `no-redzone` are hyphenated
between "no" and the name. Cargo has `--no-default-features` and
`--no-deps`.

This change renames the test option `--nocapture` to `--no-capture` to
be consistent with Rust's naming of long name options. The ENV variable
`RUST_TEST_NOCAPTURE` is also renamed to `RUST_TEST_NO_CAPTURE`.

Because this is a public facing option, it is a [breaking-change].
  • Loading branch information
zaeleus committed May 3, 2015
commit dfd5f134ee21e7ca6bd9f6ddb7ba976d51b58443
4 changes: 2 additions & 2 deletions man/rustc.1
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ The test framework Rust provides executes tests in parallel. This variable sets
the maximum number of threads used for this purpose.

.TP
\fBRUST_TEST_NOCAPTURE\fR
A synonym for the --nocapture flag.
\fBRUST_TEST_NO_CAPTURE\fR
A synonym for the --no-capture flag.

.TP
\fBRUST_MIN_STACK\fR
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
logfile: config.logfile.clone(),
run_tests: true,
bench_benchmarks: true,
nocapture: env::var("RUST_TEST_NOCAPTURE").is_ok(),
no_capture: env::var("RUST_TEST_NO_CAPTURE").is_ok(),
color: test::AutoColor,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
true
});

for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
for key in vec!["RUST_TEST_NO_CAPTURE", "RUST_TEST_THREADS"] {
match env::var(key) {
Ok(val) =>
if exec_env.iter().find(|&&(ref x, _)| *x == key.to_string()).is_none() {
Expand Down
24 changes: 12 additions & 12 deletions src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ pub struct TestOpts {
pub run_tests: bool,
pub bench_benchmarks: bool,
pub logfile: Option<PathBuf>,
pub nocapture: bool,
pub no_capture: bool,
pub color: ColorConfig,
}

Expand All @@ -300,7 +300,7 @@ impl TestOpts {
run_tests: false,
bench_benchmarks: false,
logfile: None,
nocapture: false,
no_capture: false,
color: AutoColor,
}
}
Expand All @@ -316,7 +316,7 @@ fn optgroups() -> Vec<getopts::OptGroup> {
getopts::optflag("h", "help", "Display this message (longer with --help)"),
getopts::optopt("", "logfile", "Write logs to the specified file instead \
of stdout", "PATH"),
getopts::optflag("", "nocapture", "don't capture stdout/stderr of each \
getopts::optflag("", "no-capture", "don't capture stdout/stderr of each \
task, allow printing directly"),
getopts::optopt("", "color", "Configure coloring of output:
auto = colorize if stdout is a tty and tests are run on serially (default);
Expand All @@ -335,7 +335,7 @@ By default, all tests are run in parallel. This can be altered with the
RUST_TEST_THREADS environment variable when running tests (set it to 1).

All tests have their standard output and standard error captured by default.
This can be overridden with the --nocapture flag or the RUST_TEST_NOCAPTURE=1
This can be overridden with the --no-capture flag or the RUST_TEST_NO_CAPTURE=1
environment variable. Logging is not captured by default.

Test Attributes:
Expand Down Expand Up @@ -381,9 +381,9 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
let run_tests = ! bench_benchmarks ||
matches.opt_present("test");

let mut nocapture = matches.opt_present("nocapture");
if !nocapture {
nocapture = env::var("RUST_TEST_NOCAPTURE").is_ok();
let mut no_capture = matches.opt_present("no-capture");
if !no_capture {
no_capture = env::var("RUST_TEST_NO_CAPTURE").is_ok();
}

let color = match matches.opt_str("color").as_ref().map(|s| &**s) {
Expand All @@ -402,7 +402,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
run_tests: run_tests,
bench_benchmarks: bench_benchmarks,
logfile: logfile,
nocapture: nocapture,
no_capture: no_capture,
color: color,
};

Expand Down Expand Up @@ -929,7 +929,7 @@ pub fn run_test(opts: &TestOpts,

fn run_test_inner(desc: TestDesc,
monitor_ch: Sender<MonitorMsg>,
nocapture: bool,
no_capture: bool,
testfn: Thunk<'static>) {
struct Sink(Arc<Mutex<Vec<u8>>>);
impl Write for Sink {
Expand All @@ -948,7 +948,7 @@ pub fn run_test(opts: &TestOpts,
});

let result_guard = cfg.spawn(move || {
if !nocapture {
if !no_capture {
io::set_print(box Sink(data2.clone()));
io::set_panic(box Sink(data2));
}
Expand Down Expand Up @@ -983,8 +983,8 @@ pub fn run_test(opts: &TestOpts,
monitor_ch.send((desc, TrMetrics(mm), Vec::new())).unwrap();
return;
}
DynTestFn(f) => run_test_inner(desc, monitor_ch, opts.nocapture, f),
StaticTestFn(f) => run_test_inner(desc, monitor_ch, opts.nocapture,
DynTestFn(f) => run_test_inner(desc, monitor_ch, opts.no_capture, f),
StaticTestFn(f) => run_test_inner(desc, monitor_ch, opts.no_capture,
Box::new(move|| f()))
}
}
Expand Down