Skip to content

Commit

Permalink
Disallow duplicate test names
Browse files Browse the repository at this point in the history
  • Loading branch information
kirstenmg committed May 29, 2024
1 parent b8d3596 commit 107a669
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/cfg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ macro_rules! cfg_test_function_to_cfg {

cfg_test_function_to_cfg!(
fib_cfg,
include_str!("../../tests/passing/brils/mem/fib.bril"),
include_str!("../../tests/passing/brils/mem/fib_test.bril"),
[
ENTRY = (Jmp) => "loop",
"loop" = (true_cond("cond")) => "body",
Expand Down
27 changes: 27 additions & 0 deletions tests/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,35 @@ fn generate_tests(glob: &str, benchmark_mode: bool) -> Vec<Trial> {
trials
}

fn check_no_duplicates(globs: Vec<&str>) {
let mut names = HashSet::<String>::new();

for glob in globs {
for file in glob::glob(glob).unwrap() {
let name = file
.unwrap()
.file_stem()
.unwrap()
.to_str()
.unwrap()
.to_string();
if names.contains(&name) {
panic!("Duplicate filename {}.", name);
}
names.insert(name);
}
}
}

fn main() {
let args = libtest_mimic::Arguments::from_args();

// Check for duplicate files
check_no_duplicates(vec![
"tests/passing/**/*.bril",
"benchmarks/passing/**/*.bril",
]);

let mut tests = generate_tests("tests/passing/**/*.bril", false);
// also generate tests for benchmarks
tests.extend(generate_tests("benchmarks/passing/**/*.bril", true));
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 107a669

Please sign in to comment.