Rollup merge of #87372 - GuillaumeGomez:move-test_main-calls, r=jyn514
Move calls to test_main into one function Fixes #86254. cc ``@jyn514`` r? ``@camelid``
This commit is contained in:
commit
7c2436ad34
2 changed files with 20 additions and 15 deletions
|
@ -105,7 +105,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
|
||||||
registry: rustc_driver::diagnostics_registry(),
|
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 display_warnings = options.display_warnings;
|
||||||
let nocapture = options.nocapture;
|
let nocapture = options.nocapture;
|
||||||
let externs = options.externs.clone();
|
let externs = options.externs.clone();
|
||||||
|
@ -166,12 +166,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
|
||||||
Err(ErrorReported) => return Err(ErrorReported),
|
Err(ErrorReported) => return Err(ErrorReported),
|
||||||
};
|
};
|
||||||
|
|
||||||
test_args.insert(0, "rustdoctest".to_string());
|
run_tests(test_args, nocapture, display_warnings, tests);
|
||||||
if nocapture {
|
|
||||||
test_args.push("--nocapture".to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
test::test_main(&test_args, tests, Some(test::Options::new().display_output(display_warnings)));
|
|
||||||
|
|
||||||
// Collect and warn about unused externs, but only if we've gotten
|
// Collect and warn about unused externs, but only if we've gotten
|
||||||
// reports for each doctest
|
// reports for each doctest
|
||||||
|
@ -214,6 +209,19 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
|
||||||
Ok(())
|
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.
|
// Look for `#![doc(test(no_crate_inject))]`, used by crates in the std facade.
|
||||||
fn scrape_test_config(attrs: &[ast::Attribute]) -> TestOptions {
|
fn scrape_test_config(attrs: &[ast::Attribute]) -> TestOptions {
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
|
|
|
@ -115,7 +115,7 @@ crate fn render<P: AsRef<Path>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs any tests/code examples in the markdown file `input`.
|
/// Runs any tests/code examples in the markdown file `input`.
|
||||||
crate fn test(mut options: Options) -> Result<(), String> {
|
crate fn test(options: Options) -> Result<(), String> {
|
||||||
let input_str = read_to_string(&options.input)
|
let input_str = read_to_string(&options.input)
|
||||||
.map_err(|err| format!("{}: {}", options.input.display(), err))?;
|
.map_err(|err| format!("{}: {}", options.input.display(), err))?;
|
||||||
let mut opts = TestOptions::default();
|
let mut opts = TestOptions::default();
|
||||||
|
@ -135,14 +135,11 @@ crate fn test(mut options: Options) -> Result<(), String> {
|
||||||
|
|
||||||
find_testable_code(&input_str, &mut collector, codes, options.enable_per_target_ignores, None);
|
find_testable_code(&input_str, &mut collector, codes, options.enable_per_target_ignores, None);
|
||||||
|
|
||||||
options.test_args.insert(0, "rustdoctest".to_string());
|
crate::doctest::run_tests(
|
||||||
if options.nocapture {
|
options.test_args,
|
||||||
options.test_args.push("--nocapture".to_string());
|
options.nocapture,
|
||||||
}
|
options.display_warnings,
|
||||||
test::test_main(
|
|
||||||
&options.test_args,
|
|
||||||
collector.tests,
|
collector.tests,
|
||||||
Some(test::Options::new().display_output(options.display_warnings)),
|
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue