registry: rustc_driver::diagnostics_registry(),
};
- let mut test_args = options.test_args.clone();
+ let test_args = options.test_args.clone();
let display_warnings = options.display_warnings;
+ let nocapture = options.nocapture;
let externs = options.externs.clone();
let json_unused_externs = options.json_unused_externs;
hir_collector.visit_testable(
"".to_string(),
CRATE_HIR_ID,
- krate.item.inner,
+ krate.module().inner,
|this| {
intravisit::walk_crate(this, krate);
},
Err(ErrorReported) => return Err(ErrorReported),
};
- test_args.insert(0, "rustdoctest".to_string());
-
- testing::test_main(
- &test_args,
- tests,
- Some(testing::Options::new().display_output(display_warnings)),
- );
+ run_tests(test_args, nocapture, display_warnings, tests);
// Collect and warn about unused externs, but only if we've gotten
// reports for each doctest
Ok(())
}
+crate fn run_tests(
+ mut test_args: Vec<String>,
+ nocapture: bool,
+ display_warnings: bool,
+ tests: Vec<test::TestDescAndFn>,
+) {
+ test_args.insert(0, "rustdoctest".to_string());
+ if nocapture {
+ test_args.push("--nocapture".to_string());
+ }
+ test::test_main(&test_args, tests, Some(test::Options::new().display_output(display_warnings)));
+}
+
// Look for `#![doc(test(no_crate_inject))]`, used by crates in the std facade.
fn scrape_test_config(attrs: &[ast::Attribute]) -> TestOptions {
use rustc_ast_pretty::pprust;
cmd.current_dir(run_directory);
}
- match cmd.output() {
+ let result = if options.nocapture {
+ cmd.status().map(|status| process::Output {
+ status,
+ stdout: Vec::new(),
+ stderr: Vec::new(),
+ })
+ } else {
+ cmd.output()
+ };
+ match result {
Err(e) => return Err(TestFailure::ExecutionError(e)),
Ok(out) => {
if should_panic && out.status.success() {
}
crate struct Collector {
- crate tests: Vec<testing::TestDescAndFn>,
+ crate tests: Vec<test::TestDescAndFn>,
// The name of the test displayed to the user, separated by `::`.
//
};
debug!("creating test {}: {}", name, test);
- self.tests.push(testing::TestDescAndFn {
- desc: testing::TestDesc {
- name: testing::DynTestName(name),
+ self.tests.push(test::TestDescAndFn {
+ desc: test::TestDesc {
+ name: test::DynTestName(name),
ignore: match config.ignore {
Ignore::All => true,
Ignore::None => false,
Ignore::Some(ref ignores) => ignores.iter().any(|s| target_str.contains(s)),
},
// compiler failures are test failures
- should_panic: testing::ShouldPanic::No,
+ should_panic: test::ShouldPanic::No,
allow_fail: config.allow_fail,
compile_fail: config.compile_fail,
no_run,
- test_type: testing::TestType::DocTest,
+ test_type: test::TestType::DocTest,
},
- testfn: testing::DynTestFn(box move || {
+ testfn: test::DynTestFn(box move || {
let report_unused_externs = |uext| {
unused_externs.lock().unwrap().push(uext);
};