@@ -45,11 +45,8 @@ impl DocTestRunner {
45
45
self . crate_attrs . insert ( line. to_string ( ) ) ;
46
46
}
47
47
}
48
- if !self . ids . is_empty ( ) {
49
- self . ids . push ( ',' ) ;
50
- }
51
48
self . ids . push_str ( & format ! (
52
- "{}::TEST" ,
49
+ "tests.push( {}::TEST); \n " ,
53
50
generate_mergeable_doctest(
54
51
doctest,
55
52
scraped_test,
@@ -136,19 +133,23 @@ mod __doctest_mod {{
136
133
137
134
#[rustc_main]
138
135
fn main() -> std::process::ExitCode {{
139
- const TESTS: [test::TestDescAndFn; {nb_tests}] = [{ids}];
136
+ let tests = {{
137
+ let mut tests = Vec::with_capacity({nb_tests});
138
+ {ids}
139
+ tests
140
+ }};
140
141
let test_marker = std::ffi::OsStr::new(__doctest_mod::RUN_OPTION);
141
142
let test_args = &[{test_args}];
142
143
const ENV_BIN: &'static str = \" RUSTDOC_DOCTEST_BIN_PATH\" ;
143
144
144
145
if let Ok(binary) = std::env::var(ENV_BIN) {{
145
146
let _ = crate::__doctest_mod::BINARY_PATH.set(binary.into());
146
147
unsafe {{ std::env::remove_var(ENV_BIN); }}
147
- return std::process::Termination::report(test::test_main(test_args, Vec::from(TESTS) , None));
148
+ return std::process::Termination::report(test::test_main(test_args, tests , None));
148
149
}} else if let Ok(nb_test) = std::env::var(__doctest_mod::RUN_OPTION) {{
149
150
if let Ok(nb_test) = nb_test.parse::<usize>() {{
150
- if let Some(test) = TESTS .get(nb_test) {{
151
- if let test::StaticTestFn(f) = test.testfn {{
151
+ if let Some(test) = tests .get(nb_test) {{
152
+ if let test::StaticTestFn(f) = & test.testfn {{
152
153
return std::process::Termination::report(f());
153
154
}}
154
155
}}
@@ -158,7 +159,7 @@ if let Ok(binary) = std::env::var(ENV_BIN) {{
158
159
159
160
eprintln!(\" WARNING: No rustdoc doctest environment variable provided so doctests will be run in \
160
161
the same process\" );
161
- std::process::Termination::report(test::test_main(test_args, Vec::from(TESTS) , None))
162
+ std::process::Termination::report(test::test_main(test_args, tests , None))
162
163
}}" ,
163
164
nb_tests = self . nb_tests,
164
165
output = self . output,
0 commit comments