Skip to content

Commit

Permalink
Disallow duplicate test names
Browse files Browse the repository at this point in the history
Disallow duplicate test names
  • Loading branch information
kirstenmg authored Oct 23, 2024
2 parents e2ccc39 + afac440 commit e3a2ab8
Show file tree
Hide file tree
Showing 6 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 @@ -69,8 +69,35 @@ fn generate_tests(glob: &str, slow_test: 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);
tests.extend(generate_tests("tests/passing/**/*.rs", false));

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e3a2ab8

Please sign in to comment.