From 4baadb7859b6de4e5bf7addcbba253d24d70f52a Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 1 Mar 2024 17:28:57 -0500 Subject: [PATCH] Update lang_tester so that panicking in a test results in the test failing --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- tests/lang_tests_common.rs | 13 +++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ffbd4ee39de..ab2c7ca8a47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,9 +70,9 @@ checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "fm" -version = "0.1.4" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68fda3cff2cce84c19e5dfa5179a4b35d2c0f18b893f108002b8a6a54984acca" +checksum = "21bcf4db620a804cf7e9d84fbcb5d4ac83a8c43396203b2507d62ea31814dfd4" dependencies = [ "regex", ] @@ -110,9 +110,9 @@ checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "lang_tester" -version = "0.3.13" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96bd995a092cac79868250589869b5a5d656b02a02bd74c8ebdc566dc7203090" +checksum = "9af8149dbb3ed7d8e529fcb141fe033b1c26ed54cbffc6762d3a86483c485d23" dependencies = [ "fm", "getopts", diff --git a/Cargo.toml b/Cargo.toml index e23aaeab977..100c10ef1d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ smallvec = { version = "1.6.1", features = ["union", "may_dangle"] } tempfile = "3.7.1" [dev-dependencies] -lang_tester = "0.3.9" +lang_tester = "0.8.0" tempfile = "3.1.0" boml = "0.3.1" diff --git a/tests/lang_tests_common.rs b/tests/lang_tests_common.rs index 67629a3c95a..d116daab7c4 100644 --- a/tests/lang_tests_common.rs +++ b/tests/lang_tests_common.rs @@ -37,8 +37,8 @@ pub fn main_inner(profile: Profile) { .to_string(); env::set_var("LD_LIBRARY_PATH", gcc_path); - fn rust_filter(filename: &Path) -> bool { - filename.extension().expect("extension").to_str().expect("to_str") == "rs" + fn rust_filter(path: &Path) -> bool { + path.is_file() && path.extension().expect("extension").to_str().expect("to_str") == "rs" } #[cfg(feature = "master")] @@ -58,16 +58,17 @@ pub fn main_inner(profile: Profile) { LangTester::new() .test_dir("tests/run") - .test_file_filter(filter) - .test_extract(|source| { - let lines = source + .test_path_filter(filter) + .test_extract(|path| { + let lines = std::fs::read_to_string(path) + .expect("read file") .lines() .skip_while(|l| !l.starts_with("//")) .take_while(|l| l.starts_with("//")) .map(|l| &l[2..]) .collect::>() .join("\n"); - Some(lines) + lines }) .test_cmds(move |path| { // Test command 1: Compile `x.rs` into `tempdir/x`.