@@ -85,7 +85,7 @@ pub fn run(input: &str,
8585 rustc_lint:: register_builtins ( & mut sess. lint_store . borrow_mut ( ) , Some ( & sess) ) ;
8686
8787 let mut cfg = config:: build_configuration ( & sess) ;
88- cfg. extend ( config:: parse_cfgspecs ( cfgs) ) ;
88+ cfg. extend ( config:: parse_cfgspecs ( cfgs. clone ( ) ) ) ;
8989 let krate = driver:: phase_1_parse_input ( & sess, cfg, & input) ;
9090 let krate = driver:: phase_2_configure_and_expand ( & sess, & cstore, krate,
9191 "rustdoc-test" , None )
@@ -122,6 +122,7 @@ pub fn run(input: &str,
122122 let ( krate, _) = passes:: unindent_comments ( krate) ;
123123
124124 let mut collector = Collector :: new ( krate. name . to_string ( ) ,
125+ cfgs,
125126 libs,
126127 externs,
127128 false ,
@@ -168,7 +169,7 @@ fn scrape_test_config(krate: &::rustc_front::hir::Crate) -> TestOptions {
168169 return opts;
169170}
170171
171- fn runtest ( test : & str , cratename : & str , libs : SearchPaths ,
172+ fn runtest ( test : & str , cratename : & str , cfgs : Vec < String > , libs : SearchPaths ,
172173 externs : core:: Externs ,
173174 should_panic : bool , no_run : bool , as_test_harness : bool ,
174175 opts : & TestOptions ) {
@@ -239,7 +240,8 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
239240
240241 let outdir = TempDir :: new ( "rustdoctest" ) . ok ( ) . expect ( "rustdoc needs a tempdir" ) ;
241242 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) ) ;
243245 let libdir = sess. target_filesearch ( PathKind :: All ) . get_lib_path ( ) ;
244246 let mut control = driver:: CompileController :: basic ( ) ;
245247 if no_run {
@@ -349,6 +351,7 @@ fn partition_source(s: &str) -> (String, String) {
349351pub struct Collector {
350352 pub tests : Vec < testing:: TestDescAndFn > ,
351353 names : Vec < String > ,
354+ cfgs : Vec < String > ,
352355 libs : SearchPaths ,
353356 externs : core:: Externs ,
354357 cnt : usize ,
@@ -359,11 +362,12 @@ pub struct Collector {
359362}
360363
361364impl 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 ,
363366 use_headers : bool , opts : TestOptions ) -> Collector {
364367 Collector {
365368 tests : Vec :: new ( ) ,
366369 names : Vec :: new ( ) ,
370+ cfgs : cfgs,
367371 libs : libs,
368372 externs : externs,
369373 cnt : 0 ,
@@ -384,6 +388,7 @@ impl Collector {
384388 format ! ( "{}_{}" , self . names. join( "::" ) , self . cnt)
385389 } ;
386390 self . cnt += 1 ;
391+ let cfgs = self . cfgs . clone ( ) ;
387392 let libs = self . libs . clone ( ) ;
388393 let externs = self . externs . clone ( ) ;
389394 let cratename = self . cratename . to_string ( ) ;
@@ -399,6 +404,7 @@ impl Collector {
399404 testfn : testing:: DynTestFn ( Box :: new ( move || {
400405 runtest ( & test,
401406 & cratename,
407+ cfgs,
402408 libs,
403409 externs,
404410 should_panic,
0 commit comments