@@ -2391,6 +2391,7 @@ mod tests {
2391
2391
use super :: { Externs , OutputType , OutputTypes } ;
2392
2392
use rustc_back:: { PanicStrategy , RelroLevel } ;
2393
2393
use syntax:: symbol:: Symbol ;
2394
+ use syntax;
2394
2395
2395
2396
fn optgroups ( ) -> getopts:: Options {
2396
2397
let mut opts = getopts:: Options :: new ( ) ;
@@ -2411,61 +2412,66 @@ mod tests {
2411
2412
// When the user supplies --test we should implicitly supply --cfg test
2412
2413
#[ test]
2413
2414
fn test_switch_implies_cfg_test ( ) {
2414
- let matches = & match optgroups ( ) . parse ( & [ "--test" . to_string ( ) ] ) {
2415
- Ok ( m) => m,
2416
- Err ( f) => panic ! ( "test_switch_implies_cfg_test: {}" , f) ,
2417
- } ;
2418
- let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2419
- let ( sessopts, cfg) = build_session_options_and_crate_config ( matches) ;
2420
- let sess = build_session ( sessopts, None , registry) ;
2421
- let cfg = build_configuration ( & sess, cfg) ;
2422
- assert ! ( cfg. contains( & ( Symbol :: intern( "test" ) , None ) ) ) ;
2415
+ syntax:: with_globals ( || {
2416
+ let matches = & match optgroups ( ) . parse ( & [ "--test" . to_string ( ) ] ) {
2417
+ Ok ( m) => m,
2418
+ Err ( f) => panic ! ( "test_switch_implies_cfg_test: {}" , f) ,
2419
+ } ;
2420
+ let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2421
+ let ( sessopts, cfg) = build_session_options_and_crate_config ( matches) ;
2422
+ let sess = build_session ( sessopts, None , registry) ;
2423
+ let cfg = build_configuration ( & sess, cfg) ;
2424
+ assert ! ( cfg. contains( & ( Symbol :: intern( "test" ) , None ) ) ) ;
2425
+ } ) ;
2423
2426
}
2424
2427
2425
2428
// When the user supplies --test and --cfg test, don't implicitly add
2426
2429
// another --cfg test
2427
2430
#[ test]
2428
2431
fn test_switch_implies_cfg_test_unless_cfg_test ( ) {
2429
- let matches = & match optgroups ( ) . parse ( & [ "--test" . to_string ( ) , "--cfg=test" . to_string ( ) ] ) {
2430
- Ok ( m) => m,
2431
- Err ( f) => panic ! ( "test_switch_implies_cfg_test_unless_cfg_test: {}" , f) ,
2432
- } ;
2433
- let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2434
- let ( sessopts, cfg) = build_session_options_and_crate_config ( matches) ;
2435
- let sess = build_session ( sessopts, None , registry) ;
2436
- let cfg = build_configuration ( & sess, cfg) ;
2437
- let mut test_items = cfg. iter ( ) . filter ( |& & ( name, _) | name == "test" ) ;
2438
- assert ! ( test_items. next( ) . is_some( ) ) ;
2439
- assert ! ( test_items. next( ) . is_none( ) ) ;
2432
+ syntax:: with_globals ( || {
2433
+ let matches = & match optgroups ( ) . parse ( & [ "--test" . to_string ( ) ,
2434
+ "--cfg=test" . to_string ( ) ] ) {
2435
+ Ok ( m) => m,
2436
+ Err ( f) => panic ! ( "test_switch_implies_cfg_test_unless_cfg_test: {}" , f) ,
2437
+ } ;
2438
+ let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2439
+ let ( sessopts, cfg) = build_session_options_and_crate_config ( matches) ;
2440
+ let sess = build_session ( sessopts, None , registry) ;
2441
+ let cfg = build_configuration ( & sess, cfg) ;
2442
+ let mut test_items = cfg. iter ( ) . filter ( |& & ( name, _) | name == "test" ) ;
2443
+ assert ! ( test_items. next( ) . is_some( ) ) ;
2444
+ assert ! ( test_items. next( ) . is_none( ) ) ;
2445
+ } ) ;
2440
2446
}
2441
2447
2442
2448
#[ test]
2443
2449
fn test_can_print_warnings ( ) {
2444
- {
2450
+ syntax :: with_globals ( || {
2445
2451
let matches = optgroups ( ) . parse ( & [ "-Awarnings" . to_string ( ) ] ) . unwrap ( ) ;
2446
2452
let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2447
2453
let ( sessopts, _) = build_session_options_and_crate_config ( & matches) ;
2448
2454
let sess = build_session ( sessopts, None , registry) ;
2449
2455
assert ! ( !sess. diagnostic( ) . flags. can_emit_warnings) ;
2450
- }
2456
+ } ) ;
2451
2457
2452
- {
2458
+ syntax :: with_globals ( || {
2453
2459
let matches = optgroups ( )
2454
2460
. parse ( & [ "-Awarnings" . to_string ( ) , "-Dwarnings" . to_string ( ) ] )
2455
2461
. unwrap ( ) ;
2456
2462
let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2457
2463
let ( sessopts, _) = build_session_options_and_crate_config ( & matches) ;
2458
2464
let sess = build_session ( sessopts, None , registry) ;
2459
2465
assert ! ( sess. diagnostic( ) . flags. can_emit_warnings) ;
2460
- }
2466
+ } ) ;
2461
2467
2462
- {
2468
+ syntax :: with_globals ( || {
2463
2469
let matches = optgroups ( ) . parse ( & [ "-Adead_code" . to_string ( ) ] ) . unwrap ( ) ;
2464
2470
let registry = errors:: registry:: Registry :: new ( & [ ] ) ;
2465
2471
let ( sessopts, _) = build_session_options_and_crate_config ( & matches) ;
2466
2472
let sess = build_session ( sessopts, None , registry) ;
2467
2473
assert ! ( sess. diagnostic( ) . flags. can_emit_warnings) ;
2468
- }
2474
+ } ) ;
2469
2475
}
2470
2476
2471
2477
#[ test]
0 commit comments