Skip to content

Commit

Permalink
Update candidates test check to do comparison by individual element
Browse files Browse the repository at this point in the history
  • Loading branch information
aandresen-slack authored Jan 17, 2024
1 parent 1ce2063 commit 249e344
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions src/cli/test_runners/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ impl TestRunner {
} else if dir.contains("/migration-candidates/") {
let candidates_file = format!("{}/candidates.txt", dir);
let expected_candidates_contents = fs::read_to_string(candidates_file).unwrap();
let expected_candidates = expected_candidates_contents
.trim()
.lines()
.map(String::from)
.collect::<Vec<String>>();

let result = result.unwrap();

Expand All @@ -309,18 +314,40 @@ impl TestRunner {
}
}

if migration_candidates.join("\n") == expected_candidates_contents {
(".".to_string(), Some(result.1), Some(result.0))
} else {
let missing_candidates = expected_candidates
.iter()
.filter(|item| !migration_candidates.contains(item))
.map(String::from)
.collect::<Vec<String>>();
let unexpected_candidates = migration_candidates
.iter()
.filter(|item| !expected_candidates.contains(item))
.map(String::from)
.collect::<Vec<String>>();

if unexpected_candidates.len() > 0 {
test_diagnostics.push((
dir,
dir.clone(),
format!(
"Found unexpected candidates: {}",
unexpected_candidates.join("\n")
),
));
}
if missing_candidates.len() > 0 {
test_diagnostics.push((
dir.clone(),
format!(
"- {}\n+ {}",
expected_candidates_contents,
migration_candidates.join("\n")
"Missing expected candidates: {}",
missing_candidates.join("\n")
),
));
}

if unexpected_candidates.len() > 0 || missing_candidates.len() > 0 {
("F".to_string(), Some(result.1), Some(result.0))
} else {
(".".to_string(), Some(result.1), Some(result.0))
}
} else {
match result {
Expand Down

0 comments on commit 249e344

Please sign in to comment.