@@ -151,8 +151,6 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, options: RustdocOptions) -> Result<()
151
151
expanded_args : options. expanded_args . clone ( ) ,
152
152
} ;
153
153
154
- let test_args = options. test_args . clone ( ) ;
155
- let nocapture = options. nocapture ;
156
154
let externs = options. externs . clone ( ) ;
157
155
let json_unused_externs = options. json_unused_externs ;
158
156
@@ -202,15 +200,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, options: RustdocOptions) -> Result<()
202
200
} )
203
201
} ) ?;
204
202
205
- run_tests (
206
- test_args,
207
- nocapture,
208
- opts,
209
- & rustdoc_options,
210
- & unused_extern_reports,
211
- standalone_tests,
212
- mergeable_tests,
213
- ) ;
203
+ run_tests ( opts, & rustdoc_options, & unused_extern_reports, standalone_tests, mergeable_tests) ;
214
204
215
205
let compiling_test_count = compiling_test_count. load ( Ordering :: SeqCst ) ;
216
206
@@ -256,16 +246,16 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, options: RustdocOptions) -> Result<()
256
246
}
257
247
258
248
pub ( crate ) fn run_tests (
259
- mut test_args : Vec < String > ,
260
- nocapture : bool ,
261
249
opts : GlobalTestOptions ,
262
250
rustdoc_options : & Arc < RustdocOptions > ,
263
251
unused_extern_reports : & Arc < Mutex < Vec < UnusedExterns > > > ,
264
252
mut standalone_tests : Vec < test:: TestDescAndFn > ,
265
253
mergeable_tests : FxHashMap < Edition , Vec < ( DocTest , ScrapedDoctest ) > > ,
266
254
) {
255
+ let mut test_args = Vec :: with_capacity ( rustdoc_options. test_args . len ( ) + 1 ) ;
267
256
test_args. insert ( 0 , "rustdoctest" . to_string ( ) ) ;
268
- if nocapture {
257
+ test_args. extend_from_slice ( & rustdoc_options. test_args ) ;
258
+ if rustdoc_options. nocapture {
269
259
test_args. push ( "--nocapture" . to_string ( ) ) ;
270
260
}
271
261
@@ -283,7 +273,7 @@ pub(crate) fn run_tests(
283
273
284
274
let rustdoc_test_options = IndividualTestOptions :: new (
285
275
& rustdoc_options,
286
- & format ! ( "merged_doctest_{edition}" ) ,
276
+ & Some ( format ! ( "merged_doctest_{edition}" ) ) ,
287
277
PathBuf :: from ( format ! ( "doctest_{edition}.rs" ) ) ,
288
278
) ;
289
279
@@ -685,10 +675,10 @@ struct IndividualTestOptions {
685
675
}
686
676
687
677
impl IndividualTestOptions {
688
- fn new ( options : & RustdocOptions , test_id : & str , test_path : PathBuf ) -> Self {
678
+ fn new ( options : & RustdocOptions , test_id : & Option < String > , test_path : PathBuf ) -> Self {
689
679
let outdir = if let Some ( ref path) = options. persist_doctests {
690
680
let mut path = path. clone ( ) ;
691
- path. push ( & test_id) ;
681
+ path. push ( & test_id. as_deref ( ) . unwrap_or_else ( || "<doctest>" ) ) ;
692
682
693
683
if let Err ( err) = std:: fs:: create_dir_all ( & path) {
694
684
eprintln ! ( "Couldn't create directory for doctest executables: {err}" ) ;
@@ -858,11 +848,8 @@ fn generate_test_desc_and_fn(
858
848
unused_externs : Arc < Mutex < Vec < UnusedExterns > > > ,
859
849
) -> test:: TestDescAndFn {
860
850
let target_str = rustdoc_options. target . to_string ( ) ;
861
- let rustdoc_test_options = IndividualTestOptions :: new (
862
- & rustdoc_options,
863
- test. test_id . as_deref ( ) . unwrap_or_else ( || "<doctest>" ) ,
864
- scraped_test. path ( ) ,
865
- ) ;
851
+ let rustdoc_test_options =
852
+ IndividualTestOptions :: new ( & rustdoc_options, & test. test_id , scraped_test. path ( ) ) ;
866
853
867
854
debug ! ( "creating test {}: {}" , scraped_test. name, scraped_test. text) ;
868
855
test:: TestDescAndFn {
0 commit comments