Skip to content

Commit

Permalink
🐛 FIX: Check fuzz test name collision by checking the name against Ha…
Browse files Browse the repository at this point in the history
…shSet
  • Loading branch information
lukacan authored and Ikrk committed Feb 8, 2024
1 parent 75d0fad commit 710ba99
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions crates/client/src/test_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,26 @@ impl TestGenerator {
let fuzz_id = if fuzz_dir_path.read_dir()?.next().is_none() {
0
} else {
let mut directories: Vec<_> = fuzz_dir_path
let mut directories: std::collections::HashSet<_> = fuzz_dir_path
.read_dir()
.unwrap()
.map(|r| r.unwrap())
.map(|r| r.unwrap().file_name().to_str().unwrap().to_string())
.collect();

// INFO discard known entries created by framework, everything else
// created by user will be taken as fuzz test.
directories.retain(|x| x.file_name() != "fuzzing");
directories.retain(|x| x.file_name() != "Cargo.toml");

directories.len()
directories.retain(|x| x != "fuzzing");
directories.retain(|x| x != "Cargo.toml");

let mut fuzz_id = directories.len();
loop {
let fuzz_test = format!("fuzz_{fuzz_id}");
if directories.contains(&fuzz_test) {
fuzz_id += 1;
} else {
break fuzz_id;
}
}
};

let new_fuzz_test = format!("fuzz_{fuzz_id}");
Expand Down

0 comments on commit 710ba99

Please sign in to comment.