Skip to content

Commit

Permalink
Update lang_tester so that panicking in a test results in the test fa…
Browse files Browse the repository at this point in the history
…iling
  • Loading branch information
antoyo committed Mar 1, 2024
1 parent bf5770a commit 4baadb7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
13 changes: 7 additions & 6 deletions tests/lang_tests_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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::<Vec<_>>()
.join("\n");
Some(lines)
lines
})
.test_cmds(move |path| {
// Test command 1: Compile `x.rs` into `tempdir/x`.
Expand Down

0 comments on commit 4baadb7

Please sign in to comment.