compiletest: Unconfigure tests during normal build
This commit is contained in:
parent
b990c6d813
commit
77eacaeabd
@ -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).");
|
||||
}
|
||||
|
27
src/tools/compiletest/src/header/tests.rs
Normal file
27
src/tools/compiletest/src/header/tests.rs
Normal file
@ -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).");
|
||||
}
|
@ -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")));
|
||||
}
|
||||
|
@ -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")"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
61
src/tools/compiletest/src/runtest/tests.rs
Normal file
61
src/tools/compiletest/src/runtest/tests.rs
Normal file
@ -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")"#,
|
||||
);
|
||||
}
|
51
src/tools/compiletest/src/tests.rs
Normal file
51
src/tools/compiletest/src/tests.rs
Normal file
@ -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")));
|
||||
}
|
@ -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"));
|
||||
}
|
||||
|
32
src/tools/compiletest/src/util/tests.rs
Normal file
32
src/tools/compiletest/src/util/tests.rs
Normal file
@ -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"));
|
||||
}
|
@ -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| {
|
||||
|
Loading…
Reference in New Issue
Block a user