Skip to content

Commit 484a00d

Browse files
committed
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 hypenated 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].
1 parent 16e1fce commit 484a00d

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

man/rustc.1

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ The test framework Rust provides executes tests in parallel. This variable sets
253253
the maximum number of threads used for this purpose.
254254

255255
.TP
256-
\fBRUST_TEST_NOCAPTURE\fR
257-
A synonym for the --nocapture flag.
256+
\fBRUST_TEST_NO_CAPTURE\fR
257+
A synonym for the --no-capture flag.
258258

259259
.TP
260260
\fBRUST_MIN_STACK\fR

src/compiletest/compiletest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
270270
logfile: config.logfile.clone(),
271271
run_tests: true,
272272
run_benchmarks: true,
273-
nocapture: env::var("RUST_TEST_NOCAPTURE").is_ok(),
273+
no_capture: env::var("RUST_TEST_NO_CAPTURE").is_ok(),
274274
color: test::AutoColor,
275275
}
276276
}

src/compiletest/header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
131131
true
132132
});
133133

134-
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
134+
for key in vec!["RUST_TEST_NO_CAPTURE", "RUST_TEST_THREADS"] {
135135
match env::var(key) {
136136
Ok(val) =>
137137
if exec_env.iter().find(|&&(ref x, _)| *x == key.to_string()).is_none() {

src/libtest/lib.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ pub struct TestOpts {
294294
pub run_tests: bool,
295295
pub run_benchmarks: bool,
296296
pub logfile: Option<PathBuf>,
297-
pub nocapture: bool,
297+
pub no_capture: bool,
298298
pub color: ColorConfig,
299299
}
300300

@@ -307,7 +307,7 @@ impl TestOpts {
307307
run_tests: false,
308308
run_benchmarks: false,
309309
logfile: None,
310-
nocapture: false,
310+
no_capture: false,
311311
color: AutoColor,
312312
}
313313
}
@@ -323,7 +323,7 @@ fn optgroups() -> Vec<getopts::OptGroup> {
323323
getopts::optflag("h", "help", "Display this message (longer with --help)"),
324324
getopts::optopt("", "logfile", "Write logs to the specified file instead \
325325
of stdout", "PATH"),
326-
getopts::optflag("", "nocapture", "don't capture stdout/stderr of each \
326+
getopts::optflag("", "no-capture", "don't capture stdout/stderr of each \
327327
task, allow printing directly"),
328328
getopts::optopt("", "color", "Configure coloring of output:
329329
auto = colorize if stdout is a tty and tests are run on serially (default);
@@ -342,7 +342,7 @@ By default, all tests are run in parallel. This can be altered with the
342342
RUST_TEST_THREADS environment variable when running tests (set it to 1).
343343
344344
All tests have their standard output and standard error captured by default.
345-
This can be overridden with the --nocapture flag or the RUST_TEST_NOCAPTURE=1
345+
This can be overridden with the --no-capture flag or the RUST_TEST_NO_CAPTURE=1
346346
environment variable. Logging is not captured by default.
347347
348348
Test Attributes:
@@ -388,9 +388,9 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
388388
let run_tests = ! run_benchmarks ||
389389
matches.opt_present("test");
390390

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

396396
let color = match matches.opt_str("color").as_ref().map(|s| &**s) {
@@ -409,7 +409,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
409409
run_tests: run_tests,
410410
run_benchmarks: run_benchmarks,
411411
logfile: logfile,
412-
nocapture: nocapture,
412+
no_capture: no_capture,
413413
color: color,
414414
};
415415

@@ -914,7 +914,7 @@ pub fn run_test(opts: &TestOpts,
914914

915915
fn run_test_inner(desc: TestDesc,
916916
monitor_ch: Sender<MonitorMsg>,
917-
nocapture: bool,
917+
no_capture: bool,
918918
testfn: Thunk<'static>) {
919919
struct Sink(Arc<Mutex<Vec<u8>>>);
920920
impl Write for Sink {
@@ -933,7 +933,7 @@ pub fn run_test(opts: &TestOpts,
933933
});
934934

935935
let result_guard = cfg.spawn(move || {
936-
if !nocapture {
936+
if !no_capture {
937937
io::set_print(box Sink(data2.clone()));
938938
io::set_panic(box Sink(data2));
939939
}
@@ -968,8 +968,8 @@ pub fn run_test(opts: &TestOpts,
968968
monitor_ch.send((desc, TrMetrics(mm), Vec::new())).unwrap();
969969
return;
970970
}
971-
DynTestFn(f) => run_test_inner(desc, monitor_ch, opts.nocapture, f),
972-
StaticTestFn(f) => run_test_inner(desc, monitor_ch, opts.nocapture,
971+
DynTestFn(f) => run_test_inner(desc, monitor_ch, opts.no_capture, f),
972+
StaticTestFn(f) => run_test_inner(desc, monitor_ch, opts.no_capture,
973973
Box::new(move|| f()))
974974
}
975975
}

0 commit comments

Comments
 (0)