diff --git a/src/librustc_target/spec/abi.rs b/src/librustc_target/spec/abi.rs index c9c41f109224..909f0fc53fce 100644 --- a/src/librustc_target/spec/abi.rs +++ b/src/librustc_target/spec/abi.rs @@ -1,5 +1,8 @@ use std::fmt; +#[cfg(test)] +mod tests; + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Clone, Copy, Debug)] pub enum Abi { // N.B., this ordering MUST match the AbiDatas array below. @@ -100,29 +103,3 @@ impl fmt::Display for Abi { write!(f, "\"{}\"", self.name()) } } - -#[allow(non_snake_case)] -#[test] -fn lookup_Rust() { - let abi = lookup("Rust"); - assert!(abi.is_some() && abi.unwrap().data().name == "Rust"); -} - -#[test] -fn lookup_cdecl() { - let abi = lookup("cdecl"); - assert!(abi.is_some() && abi.unwrap().data().name == "cdecl"); -} - -#[test] -fn lookup_baz() { - let abi = lookup("baz"); - assert!(abi.is_none()); -} - -#[test] -fn indices_are_correct() { - for (i, abi_data) in AbiDatas.iter().enumerate() { - assert_eq!(i, abi_data.abi.index()); - } -} diff --git a/src/librustc_target/spec/abi/tests.rs b/src/librustc_target/spec/abi/tests.rs new file mode 100644 index 000000000000..8bea5e5efe3b --- /dev/null +++ b/src/librustc_target/spec/abi/tests.rs @@ -0,0 +1,27 @@ +use super::*; + +#[allow(non_snake_case)] +#[test] +fn lookup_Rust() { + let abi = lookup("Rust"); + assert!(abi.is_some() && abi.unwrap().data().name == "Rust"); +} + +#[test] +fn lookup_cdecl() { + let abi = lookup("cdecl"); + assert!(abi.is_some() && abi.unwrap().data().name == "cdecl"); +} + +#[test] +fn lookup_baz() { + let abi = lookup("baz"); + assert!(abi.is_none()); +} + +#[test] +fn indices_are_correct() { + for (i, abi_data) in AbiDatas.iter().enumerate() { + assert_eq!(i, abi_data.abi.index()); + } +} diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 54e3cad6a614..53d66186c368 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -312,7 +312,7 @@ macro_rules! supported_targets { $(use super::$module;)+ $( - #[test] + #[test] // `#[test]` - this is hard to put into a separate file, make an exception fn $module() { // Grab the TargetResult struct. If we successfully retrieved // a Target, then the test JSON encoding/decoding can run for this diff --git a/src/tools/tidy/src/unit_tests.rs b/src/tools/tidy/src/unit_tests.rs index d8ee1ef57b78..7c0cc985880d 100644 --- a/src/tools/tidy/src/unit_tests.rs +++ b/src/tools/tidy/src/unit_tests.rs @@ -30,7 +30,6 @@ pub fn check(root_path: &Path, bad: &mut bool) { "librustc", "librustc_data_structures", "librustc_incremental/persist", - "librustc_target/spec", "librustdoc", "libstd", "libsyntax",