@@ -85,7 +85,7 @@ pub fn run(input: &str,
85
85
rustc_lint:: register_builtins ( & mut sess. lint_store . borrow_mut ( ) , Some ( & sess) ) ;
86
86
87
87
let mut cfg = config:: build_configuration ( & sess) ;
88
- cfg. extend ( config:: parse_cfgspecs ( cfgs) ) ;
88
+ cfg. extend ( config:: parse_cfgspecs ( cfgs. clone ( ) ) ) ;
89
89
let krate = driver:: phase_1_parse_input ( & sess, cfg, & input) ;
90
90
let krate = driver:: phase_2_configure_and_expand ( & sess, & cstore, krate,
91
91
"rustdoc-test" , None )
@@ -122,6 +122,7 @@ pub fn run(input: &str,
122
122
let ( krate, _) = passes:: unindent_comments ( krate) ;
123
123
124
124
let mut collector = Collector :: new ( krate. name . to_string ( ) ,
125
+ cfgs,
125
126
libs,
126
127
externs,
127
128
false ,
@@ -168,7 +169,7 @@ fn scrape_test_config(krate: &::rustc_front::hir::Crate) -> TestOptions {
168
169
return opts;
169
170
}
170
171
171
- fn runtest ( test : & str , cratename : & str , libs : SearchPaths ,
172
+ fn runtest ( test : & str , cratename : & str , cfgs : Vec < String > , libs : SearchPaths ,
172
173
externs : core:: Externs ,
173
174
should_panic : bool , no_run : bool , as_test_harness : bool ,
174
175
opts : & TestOptions ) {
@@ -239,7 +240,8 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
239
240
240
241
let outdir = TempDir :: new ( "rustdoctest" ) . ok ( ) . expect ( "rustdoc needs a tempdir" ) ;
241
242
let out = Some ( outdir. path ( ) . to_path_buf ( ) ) ;
242
- let cfg = config:: build_configuration ( & sess) ;
243
+ let mut cfg = config:: build_configuration ( & sess) ;
244
+ cfg. extend ( config:: parse_cfgspecs ( cfgs) ) ;
243
245
let libdir = sess. target_filesearch ( PathKind :: All ) . get_lib_path ( ) ;
244
246
let mut control = driver:: CompileController :: basic ( ) ;
245
247
if no_run {
@@ -349,6 +351,7 @@ fn partition_source(s: &str) -> (String, String) {
349
351
pub struct Collector {
350
352
pub tests : Vec < testing:: TestDescAndFn > ,
351
353
names : Vec < String > ,
354
+ cfgs : Vec < String > ,
352
355
libs : SearchPaths ,
353
356
externs : core:: Externs ,
354
357
cnt : usize ,
@@ -359,11 +362,12 @@ pub struct Collector {
359
362
}
360
363
361
364
impl Collector {
362
- pub fn new ( cratename : String , libs : SearchPaths , externs : core:: Externs ,
365
+ pub fn new ( cratename : String , cfgs : Vec < String > , libs : SearchPaths , externs : core:: Externs ,
363
366
use_headers : bool , opts : TestOptions ) -> Collector {
364
367
Collector {
365
368
tests : Vec :: new ( ) ,
366
369
names : Vec :: new ( ) ,
370
+ cfgs : cfgs,
367
371
libs : libs,
368
372
externs : externs,
369
373
cnt : 0 ,
@@ -384,6 +388,7 @@ impl Collector {
384
388
format ! ( "{}_{}" , self . names. join( "::" ) , self . cnt)
385
389
} ;
386
390
self . cnt += 1 ;
391
+ let cfgs = self . cfgs . clone ( ) ;
387
392
let libs = self . libs . clone ( ) ;
388
393
let externs = self . externs . clone ( ) ;
389
394
let cratename = self . cratename . to_string ( ) ;
@@ -399,6 +404,7 @@ impl Collector {
399
404
testfn : testing:: DynTestFn ( Box :: new ( move || {
400
405
runtest ( & test,
401
406
& cratename,
407
+ cfgs,
402
408
libs,
403
409
externs,
404
410
should_panic,
0 commit comments