@@ -309,24 +309,14 @@ macro_rules! supported_targets {
309
309
}
310
310
311
311
#[ cfg( test) ]
312
- mod test_json_encode_decode {
313
- use rustc_serialize:: json:: ToJson ;
314
- use super :: Target ;
315
- $( use super :: $module; ) +
312
+ mod tests {
313
+ mod tests_impl;
316
314
315
+ // Cannot put this into a separate file without duplication, make an exception.
317
316
$(
318
- #[ test] // `#[test]` - this is hard to put into a separate file, make an exception
317
+ #[ test] // `#[test]`
319
318
fn $module( ) {
320
- // Grab the TargetResult struct. If we successfully retrieved
321
- // a Target, then the test JSON encoding/decoding can run for this
322
- // Target on this testing platform (i.e., checking the iOS targets
323
- // only on a Mac test platform).
324
- let _ = $module:: target( ) . map( |original| {
325
- original. check_consistency( ) ;
326
- let as_json = original. to_json( ) ;
327
- let parsed = Target :: from_json( as_json) . unwrap( ) ;
328
- assert_eq!( original, parsed) ;
329
- } ) ;
319
+ tests_impl:: test_target( super :: $module:: target( ) ) ;
330
320
}
331
321
) +
332
322
}
@@ -1289,34 +1279,6 @@ impl Target {
1289
1279
}
1290
1280
}
1291
1281
}
1292
-
1293
- #[ cfg( test) ]
1294
- fn check_consistency ( & self ) {
1295
- // Check that LLD with the given flavor is treated identically to the linker it emulates.
1296
- // If you target really needs to deviate from the rules below, whitelist it
1297
- // and document the reasons.
1298
- assert_eq ! (
1299
- self . linker_flavor == LinkerFlavor :: Msvc
1300
- || self . linker_flavor == LinkerFlavor :: Lld ( LldFlavor :: Link ) ,
1301
- self . options. lld_flavor == LldFlavor :: Link ,
1302
- ) ;
1303
- for args in & [
1304
- & self . options . pre_link_args ,
1305
- & self . options . pre_link_args_crt ,
1306
- & self . options . late_link_args ,
1307
- & self . options . late_link_args_dynamic ,
1308
- & self . options . late_link_args_static ,
1309
- & self . options . post_link_args ,
1310
- ] {
1311
- assert_eq ! (
1312
- args. get( & LinkerFlavor :: Msvc ) ,
1313
- args. get( & LinkerFlavor :: Lld ( LldFlavor :: Link ) ) ,
1314
- ) ;
1315
- if args. contains_key ( & LinkerFlavor :: Msvc ) {
1316
- assert_eq ! ( self . options. lld_flavor, LldFlavor :: Link ) ;
1317
- }
1318
- }
1319
- }
1320
1282
}
1321
1283
1322
1284
impl ToJson for Target {
0 commit comments