mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Reduce merged doctest source code size
This commit is contained in:
parent
d512438435
commit
1e1743a379
@ -250,3 +250,37 @@ pub struct TestDescAndFn {
|
|||||||
pub desc: TestDesc,
|
pub desc: TestDesc,
|
||||||
pub testfn: TestFn,
|
pub testfn: TestFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TestDescAndFn {
|
||||||
|
pub const fn new_doctest(
|
||||||
|
test_name: &'static str,
|
||||||
|
ignore: bool,
|
||||||
|
source_file: &'static str,
|
||||||
|
start_line: usize,
|
||||||
|
no_run: bool,
|
||||||
|
should_panic: bool,
|
||||||
|
testfn: TestFn,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
desc: TestDesc {
|
||||||
|
name: StaticTestName(test_name),
|
||||||
|
ignore,
|
||||||
|
ignore_message: None,
|
||||||
|
source_file,
|
||||||
|
start_line,
|
||||||
|
start_col: 0,
|
||||||
|
end_line: 0,
|
||||||
|
end_col: 0,
|
||||||
|
compile_fail: false,
|
||||||
|
no_run,
|
||||||
|
should_panic: if should_panic {
|
||||||
|
options::ShouldPanic::Yes
|
||||||
|
} else {
|
||||||
|
options::ShouldPanic::No
|
||||||
|
},
|
||||||
|
test_type: TestType::DocTest,
|
||||||
|
},
|
||||||
|
testfn,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -235,36 +235,18 @@ fn main() {returns_result} {{
|
|||||||
output,
|
output,
|
||||||
"
|
"
|
||||||
#[rustc_test_marker = {test_name:?}]
|
#[rustc_test_marker = {test_name:?}]
|
||||||
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {{
|
pub const TEST: test::TestDescAndFn = test::TestDescAndFn::new_doctest(
|
||||||
desc: test::TestDesc {{
|
{test_name:?}, {ignore}, {file:?}, {line}, {no_run}, {should_panic},
|
||||||
name: test::StaticTestName({test_name:?}),
|
test::StaticTestFn(
|
||||||
ignore: {ignore},
|
#[coverage(off)]
|
||||||
ignore_message: None,
|
|| {{{runner}}},
|
||||||
source_file: {file:?},
|
));
|
||||||
start_line: {line},
|
|
||||||
start_col: 0,
|
|
||||||
end_line: 0,
|
|
||||||
end_col: 0,
|
|
||||||
compile_fail: false,
|
|
||||||
no_run: {no_run},
|
|
||||||
should_panic: test::ShouldPanic::{should_panic},
|
|
||||||
test_type: test::TestType::DocTest,
|
|
||||||
}},
|
|
||||||
testfn: test::StaticTestFn(
|
|
||||||
#[coverage(off)]
|
|
||||||
|| {{{runner}}},
|
|
||||||
)
|
|
||||||
}};
|
|
||||||
}}",
|
}}",
|
||||||
test_name = scraped_test.name,
|
test_name = scraped_test.name,
|
||||||
file = scraped_test.path(),
|
file = scraped_test.path(),
|
||||||
line = scraped_test.line,
|
line = scraped_test.line,
|
||||||
no_run = scraped_test.langstr.no_run,
|
no_run = scraped_test.langstr.no_run,
|
||||||
should_panic = if !scraped_test.langstr.no_run && scraped_test.langstr.should_panic {
|
should_panic = !scraped_test.langstr.no_run && scraped_test.langstr.should_panic,
|
||||||
"Yes"
|
|
||||||
} else {
|
|
||||||
"No"
|
|
||||||
},
|
|
||||||
// Setting `no_run` to `true` in `TestDesc` still makes the test run, so we simply
|
// Setting `no_run` to `true` in `TestDesc` still makes the test run, so we simply
|
||||||
// don't give it the function to run.
|
// don't give it the function to run.
|
||||||
runner = if not_running {
|
runner = if not_running {
|
||||||
|
Loading…
Reference in New Issue
Block a user