@@ -309,24 +309,14 @@ macro_rules! supported_targets {
309309 }
310310
311311 #[ 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;
316314
315+ // Cannot put this into a separate file without duplication, make an exception.
317316 $(
318- #[ test] // `#[test]` - this is hard to put into a separate file, make an exception
317+ #[ test] // `#[test]`
319318 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( ) ) ;
330320 }
331321 ) +
332322 }
@@ -1289,34 +1279,6 @@ impl Target {
12891279 }
12901280 }
12911281 }
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- }
13201282}
13211283
13221284impl ToJson for Target {
0 commit comments