diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-08-01 02:15:42 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-08-02 01:59:01 +0300 |
| commit | 77eacaeabd834184761eb690650ccf6b078bdf9e (patch) | |
| tree | 70e9dbfb4671a9ef82e6ac57415bc2c78c0ac3f8 | |
| parent | b990c6d813a01179527ceaf6479dd946209df45d (diff) | |
| download | rust-77eacaeabd834184761eb690650ccf6b078bdf9e.tar.gz rust-77eacaeabd834184761eb690650ccf6b078bdf9e.zip | |
compiletest: Unconfigure tests during normal build
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 30 | ||||
| -rw-r--r-- | src/tools/compiletest/src/header/tests.rs | 27 | ||||
| -rw-r--r-- | src/tools/compiletest/src/main.rs | 53 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 68 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest/tests.rs | 61 | ||||
| -rw-r--r-- | src/tools/compiletest/src/tests.rs | 51 | ||||
| -rw-r--r-- | src/tools/compiletest/src/util.rs | 34 | ||||
| -rw-r--r-- | src/tools/compiletest/src/util/tests.rs | 32 | ||||
| -rw-r--r-- | src/tools/tidy/src/unit_tests.rs | 1 |
9 files changed, 183 insertions, 174 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 040230d0020..076ad87c70f 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -8,9 +8,11 @@ use log::*; use crate::common::{self, CompareMode, Config, Mode, PassMode}; use crate::util; - use crate::extract_gdb_version; +#[cfg(test)] +mod tests; + /// Whether to ignore the test. #[derive(Clone, Copy, PartialEq, Debug)] pub enum Ignore { @@ -969,29 +971,3 @@ fn parse_normalization_string(line: &mut &str) -> Option<String> { *line = &line[end + 1..]; Some(result) } - -#[test] -fn test_parse_normalization_string() { - let mut s = "normalize-stderr-32bit: \"something (32 bits)\" -> \"something ($WORD bits)\"."; - let first = parse_normalization_string(&mut s); - assert_eq!(first, Some("something (32 bits)".to_owned())); - assert_eq!(s, " -> \"something ($WORD bits)\"."); - - // Nothing to normalize (No quotes) - let mut s = "normalize-stderr-32bit: something (32 bits) -> something ($WORD bits)."; - let first = parse_normalization_string(&mut s); - assert_eq!(first, None); - assert_eq!(s, r#"normalize-stderr-32bit: something (32 bits) -> something ($WORD bits)."#); - - // Nothing to normalize (Only a single quote) - let mut s = "normalize-stderr-32bit: \"something (32 bits) -> something ($WORD bits)."; - let first = parse_normalization_string(&mut s); - assert_eq!(first, None); - assert_eq!(s, "normalize-stderr-32bit: \"something (32 bits) -> something ($WORD bits)."); - - // Nothing to normalize (Three quotes) - let mut s = "normalize-stderr-32bit: \"something (32 bits)\" -> \"something ($WORD bits)."; - let first = parse_normalization_string(&mut s); - assert_eq!(first, Some("something (32 bits)".to_owned())); - assert_eq!(s, " -> \"something ($WORD bits)."); -} diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs new file mode 100644 index 00000000000..2a1831d5ee8 --- /dev/null +++ b/src/tools/compiletest/src/header/tests.rs @@ -0,0 +1,27 @@ +use super::*; + +#[test] +fn test_parse_normalization_string() { + let mut s = "normalize-stderr-32bit: \"something (32 bits)\" -> \"something ($WORD bits)\"."; + let first = parse_normalization_string(&mut s); + assert_eq!(first, Some("something (32 bits)".to_owned())); + assert_eq!(s, " -> \"something ($WORD bits)\"."); + + // Nothing to normalize (No quotes) + let mut s = "normalize-stderr-32bit: something (32 bits) -> something ($WORD bits)."; + let first = parse_normalization_string(&mut s); + assert_eq!(first, None); + assert_eq!(s, r#"normalize-stderr-32bit: something (32 bits) -> something ($WORD bits)."#); + + // Nothing to normalize (Only a single quote) + let mut s = "normalize-stderr-32bit: \"something (32 bits) -> something ($WORD bits)."; + let first = parse_normalization_string(&mut s); + assert_eq!(first, None); + assert_eq!(s, "normalize-stderr-32bit: \"something (32 bits) -> something ($WORD bits)."); + + // Nothing to normalize (Three quotes) + let mut s = "normalize-stderr-32bit: \"something (32 bits)\" -> \"something ($WORD bits)."; + let first = parse_normalization_string(&mut s); + assert_eq!(first, Some("something (32 bits)".to_owned())); + assert_eq!(s, " -> \"something ($WORD bits)."); +} diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index d709475541a..bde49ff391c 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -25,6 +25,9 @@ use log::*; use self::header::{EarlyProps, Ignore}; +#[cfg(test)] +mod tests; + pub mod common; pub mod errors; pub mod header; @@ -1093,53 +1096,3 @@ fn extract_lldb_version(full_version_line: Option<String>) -> (Option<String>, b fn is_blacklisted_lldb_version(version: &str) -> bool { version == "350" } - -#[test] -fn test_extract_gdb_version() { - macro_rules! test { ($($expectation:tt: $input:tt,)*) => {{$( - assert_eq!(extract_gdb_version($input), Some($expectation)); - )*}}} - - test! { - 7000001: "GNU gdb (GDB) CentOS (7.0.1-45.el5.centos)", - - 7002000: "GNU gdb (GDB) Red Hat Enterprise Linux (7.2-90.el6)", - - 7004000: "GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04", - 7004001: "GNU gdb (GDB) 7.4.1-debian", - - 7006001: "GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-80.el7", - - 7007001: "GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1", - 7007001: "GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1", - 7007001: "GNU gdb (GDB) Fedora 7.7.1-21.fc20", - - 7008000: "GNU gdb (GDB; openSUSE 13.2) 7.8", - 7009001: "GNU gdb (GDB) Fedora 7.9.1-20.fc22", - 7010001: "GNU gdb (GDB) Fedora 7.10.1-31.fc23", - - 7011000: "GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11", - 7011001: "GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1", - 7011001: "GNU gdb (Debian 7.11.1-2) 7.11.1", - 7011001: "GNU gdb (GDB) Fedora 7.11.1-86.fc24", - 7011001: "GNU gdb (GDB; openSUSE Leap 42.1) 7.11.1", - 7011001: "GNU gdb (GDB; openSUSE Tumbleweed) 7.11.1", - - 7011090: "7.11.90", - 7011090: "GNU gdb (Ubuntu 7.11.90.20161005-0ubuntu1) 7.11.90.20161005-git", - - 7012000: "7.12", - 7012000: "GNU gdb (GDB) 7.12", - 7012000: "GNU gdb (GDB) 7.12.20161027-git", - 7012050: "GNU gdb (GDB) 7.12.50.20161027-git", - } -} - -#[test] -fn is_test_test() { - assert_eq!(true, is_test(&OsString::from("a_test.rs"))); - assert_eq!(false, is_test(&OsString::from(".a_test.rs"))); - assert_eq!(false, is_test(&OsString::from("a_cat.gif"))); - assert_eq!(false, is_test(&OsString::from("#a_dog_gif"))); - assert_eq!(false, is_test(&OsString::from("~a_temp_file"))); -} diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 11741132c2e..05cfdf1ce53 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -35,6 +35,9 @@ use log::*; use crate::extract_gdb_version; use crate::is_android_gdb_target; +#[cfg(test)] +mod tests; + #[cfg(windows)] fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R { use std::sync::Mutex; @@ -3706,68 +3709,3 @@ fn read2_abbreviated(mut child: Child) -> io::Result<Output> { stderr: stderr.into_bytes(), }) } - -#[cfg(test)] -mod tests { - use super::TestCx; - - #[test] - fn normalize_platform_differences() { - assert_eq!( - TestCx::normalize_platform_differences(r"$DIR\foo.rs"), - "$DIR/foo.rs" - ); - assert_eq!( - TestCx::normalize_platform_differences(r"$BUILD_DIR\..\parser.rs"), - "$BUILD_DIR/../parser.rs" - ); - assert_eq!( - TestCx::normalize_platform_differences(r"$DIR\bar.rs hello\nworld"), - r"$DIR/bar.rs hello\nworld" - ); - assert_eq!( - TestCx::normalize_platform_differences(r"either bar\baz.rs or bar\baz\mod.rs"), - r"either bar/baz.rs or bar/baz/mod.rs", - ); - assert_eq!( - TestCx::normalize_platform_differences(r"`.\some\path.rs`"), - r"`./some/path.rs`", - ); - assert_eq!( - TestCx::normalize_platform_differences(r"`some\path.rs`"), - r"`some/path.rs`", - ); - assert_eq!( - TestCx::normalize_platform_differences(r"$DIR\path-with-dashes.rs"), - r"$DIR/path-with-dashes.rs" - ); - assert_eq!( - TestCx::normalize_platform_differences(r"$DIR\path_with_underscores.rs"), - r"$DIR/path_with_underscores.rs", - ); - assert_eq!( - TestCx::normalize_platform_differences(r"$DIR\foo.rs:12:11"), "$DIR/foo.rs:12:11", - ); - assert_eq!( - TestCx::normalize_platform_differences(r"$DIR\path with spaces 'n' quotes"), - "$DIR/path with spaces 'n' quotes", - ); - assert_eq!( - TestCx::normalize_platform_differences(r"$DIR\file_with\no_extension"), - "$DIR/file_with/no_extension", - ); - - assert_eq!(TestCx::normalize_platform_differences(r"\n"), r"\n"); - assert_eq!(TestCx::normalize_platform_differences(r"{ \n"), r"{ \n"); - assert_eq!(TestCx::normalize_platform_differences(r"`\]`"), r"`\]`"); - assert_eq!(TestCx::normalize_platform_differences(r#""\{""#), r#""\{""#); - assert_eq!( - TestCx::normalize_platform_differences(r#"write!(&mut v, "Hello\n")"#), - r#"write!(&mut v, "Hello\n")"# - ); - assert_eq!( - TestCx::normalize_platform_differences(r#"println!("test\ntest")"#), - r#"println!("test\ntest")"#, - ); - } -} diff --git a/src/tools/compiletest/src/runtest/tests.rs b/src/tools/compiletest/src/runtest/tests.rs new file mode 100644 index 00000000000..79128aa9c69 --- /dev/null +++ b/src/tools/compiletest/src/runtest/tests.rs @@ -0,0 +1,61 @@ +use super::*; + +#[test] +fn normalize_platform_differences() { + assert_eq!( + TestCx::normalize_platform_differences(r"$DIR\foo.rs"), + "$DIR/foo.rs" + ); + assert_eq!( + TestCx::normalize_platform_differences(r"$BUILD_DIR\..\parser.rs"), + "$BUILD_DIR/../parser.rs" + ); + assert_eq!( + TestCx::normalize_platform_differences(r"$DIR\bar.rs hello\nworld"), + r"$DIR/bar.rs hello\nworld" + ); + assert_eq!( + TestCx::normalize_platform_differences(r"either bar\baz.rs or bar\baz\mod.rs"), + r"either bar/baz.rs or bar/baz/mod.rs", + ); + assert_eq!( + TestCx::normalize_platform_differences(r"`.\some\path.rs`"), + r"`./some/path.rs`", + ); + assert_eq!( + TestCx::normalize_platform_differences(r"`some\path.rs`"), + r"`some/path.rs`", + ); + assert_eq!( + TestCx::normalize_platform_differences(r"$DIR\path-with-dashes.rs"), + r"$DIR/path-with-dashes.rs" + ); + assert_eq!( + TestCx::normalize_platform_differences(r"$DIR\path_with_underscores.rs"), + r"$DIR/path_with_underscores.rs", + ); + assert_eq!( + TestCx::normalize_platform_differences(r"$DIR\foo.rs:12:11"), "$DIR/foo.rs:12:11", + ); + assert_eq!( + TestCx::normalize_platform_differences(r"$DIR\path with spaces 'n' quotes"), + "$DIR/path with spaces 'n' quotes", + ); + assert_eq!( + TestCx::normalize_platform_differences(r"$DIR\file_with\no_extension"), + "$DIR/file_with/no_extension", + ); + + assert_eq!(TestCx::normalize_platform_differences(r"\n"), r"\n"); + assert_eq!(TestCx::normalize_platform_differences(r"{ \n"), r"{ \n"); + assert_eq!(TestCx::normalize_platform_differences(r"`\]`"), r"`\]`"); + assert_eq!(TestCx::normalize_platform_differences(r#""\{""#), r#""\{""#); + assert_eq!( + TestCx::normalize_platform_differences(r#"write!(&mut v, "Hello\n")"#), + r#"write!(&mut v, "Hello\n")"# + ); + assert_eq!( + TestCx::normalize_platform_differences(r#"println!("test\ntest")"#), + r#"println!("test\ntest")"#, + ); +} diff --git a/src/tools/compiletest/src/tests.rs b/src/tools/compiletest/src/tests.rs new file mode 100644 index 00000000000..388ad75757f --- /dev/null +++ b/src/tools/compiletest/src/tests.rs @@ -0,0 +1,51 @@ +use super::*; + +#[test] +fn test_extract_gdb_version() { + macro_rules! test { ($($expectation:tt: $input:tt,)*) => {{$( + assert_eq!(extract_gdb_version($input), Some($expectation)); + )*}}} + + test! { + 7000001: "GNU gdb (GDB) CentOS (7.0.1-45.el5.centos)", + + 7002000: "GNU gdb (GDB) Red Hat Enterprise Linux (7.2-90.el6)", + + 7004000: "GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04", + 7004001: "GNU gdb (GDB) 7.4.1-debian", + + 7006001: "GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-80.el7", + + 7007001: "GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1", + 7007001: "GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1", + 7007001: "GNU gdb (GDB) Fedora 7.7.1-21.fc20", + + 7008000: "GNU gdb (GDB; openSUSE 13.2) 7.8", + 7009001: "GNU gdb (GDB) Fedora 7.9.1-20.fc22", + 7010001: "GNU gdb (GDB) Fedora 7.10.1-31.fc23", + + 7011000: "GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11", + 7011001: "GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1", + 7011001: "GNU gdb (Debian 7.11.1-2) 7.11.1", + 7011001: "GNU gdb (GDB) Fedora 7.11.1-86.fc24", + 7011001: "GNU gdb (GDB; openSUSE Leap 42.1) 7.11.1", + 7011001: "GNU gdb (GDB; openSUSE Tumbleweed) 7.11.1", + + 7011090: "7.11.90", + 7011090: "GNU gdb (Ubuntu 7.11.90.20161005-0ubuntu1) 7.11.90.20161005-git", + + 7012000: "7.12", + 7012000: "GNU gdb (GDB) 7.12", + 7012000: "GNU gdb (GDB) 7.12.20161027-git", + 7012050: "GNU gdb (GDB) 7.12.50.20161027-git", + } +} + +#[test] +fn is_test_test() { + assert_eq!(true, is_test(&OsString::from("a_test.rs"))); + assert_eq!(false, is_test(&OsString::from(".a_test.rs"))); + assert_eq!(false, is_test(&OsString::from("a_cat.gif"))); + assert_eq!(false, is_test(&OsString::from("#a_dog_gif"))); + assert_eq!(false, is_test(&OsString::from("~a_temp_file"))); +} diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 76099b950b0..56ebea7c20f 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -5,6 +5,9 @@ use crate::common::Config; use log::*; +#[cfg(test)] +mod tests; + /// Conversion table from triple OS name to Rust SYSNAME const OS_TABLE: &'static [(&'static str, &'static str)] = &[ ("android", "android"), @@ -157,34 +160,3 @@ impl PathBufExt for PathBuf { } } } - -#[test] -#[should_panic(expected = "Cannot determine Architecture from triple")] -fn test_get_arch_failure() { - get_arch("abc"); -} - -#[test] -fn test_get_arch() { - assert_eq!("x86_64", get_arch("x86_64-unknown-linux-gnu")); - assert_eq!("x86_64", get_arch("amd64")); - assert_eq!("nvptx64", get_arch("nvptx64-nvidia-cuda")); -} - -#[test] -#[should_panic(expected = "Cannot determine OS from triple")] -fn test_matches_os_failure() { - matches_os("abc", "abc"); -} - -#[test] -fn test_matches_os() { - assert!(matches_os("x86_64-unknown-linux-gnu", "linux")); - assert!(matches_os("wasm32-unknown-unknown", "emscripten")); - assert!(matches_os("wasm32-unknown-unknown", "wasm32-bare")); - assert!(!matches_os("wasm32-unknown-unknown", "windows")); - assert!(matches_os("thumbv6m0-none-eabi", "none")); - assert!(matches_os("riscv32imc-unknown-none-elf", "none")); - assert!(matches_os("nvptx64-nvidia-cuda", "cuda")); - assert!(matches_os("x86_64-fortanix-unknown-sgx", "sgx")); -} diff --git a/src/tools/compiletest/src/util/tests.rs b/src/tools/compiletest/src/util/tests.rs new file mode 100644 index 00000000000..55bf659ba28 --- /dev/null +++ b/src/tools/compiletest/src/util/tests.rs @@ -0,0 +1,32 @@ +use super::*; + +#[test] +#[should_panic(expected = "Cannot determine Architecture from triple")] +fn test_get_arch_failure() { + get_arch("abc"); +} + +#[test] +fn test_get_arch() { + assert_eq!("x86_64", get_arch("x86_64-unknown-linux-gnu")); + assert_eq!("x86_64", get_arch("amd64")); + assert_eq!("nvptx64", get_arch("nvptx64-nvidia-cuda")); +} + +#[test] +#[should_panic(expected = "Cannot determine OS from triple")] +fn test_matches_os_failure() { + matches_os("abc", "abc"); +} + +#[test] +fn test_matches_os() { + assert!(matches_os("x86_64-unknown-linux-gnu", "linux")); + assert!(matches_os("wasm32-unknown-unknown", "emscripten")); + assert!(matches_os("wasm32-unknown-unknown", "wasm32-bare")); + assert!(!matches_os("wasm32-unknown-unknown", "windows")); + assert!(matches_os("thumbv6m0-none-eabi", "none")); + assert!(matches_os("riscv32imc-unknown-none-elf", "none")); + assert!(matches_os("nvptx64-nvidia-cuda", "cuda")); + assert!(matches_os("x86_64-fortanix-unknown-sgx", "sgx")); +} diff --git a/src/tools/tidy/src/unit_tests.rs b/src/tools/tidy/src/unit_tests.rs index 6a04068fbd8..8ae2b2cfc70 100644 --- a/src/tools/tidy/src/unit_tests.rs +++ b/src/tools/tidy/src/unit_tests.rs @@ -40,7 +40,6 @@ pub fn check(root_path: &Path, bad: &mut bool) { "libsyntax_pos", "libterm/terminfo", "libtest", - "tools/compiletest/src", ]; let mut skip = |path: &Path| { |
