Skip to content

Commit

Permalink
[crater] Don't serialize nans
Browse files Browse the repository at this point in the history
This would happen in certain cases where some error caused every target
to fail. This hasn't happened in production but it has happened various
times in my local testing, and it's annoying.
  • Loading branch information
cmyr committed Oct 27, 2024
1 parent ddd569c commit bbaf815
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions fontc_crater/src/ttx_diff_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ impl Summary {
})
.sum::<f32>();
let total_diff = total_diff + (identical as f32);
let diff_perc_including_failures = total_diff / (n_failed + success.len()) as f32 * 100.;
let diff_perc_excluding_failures = total_diff / success.len() as f32 * 100.;
let diff_perc_including_failures =
non_nan(total_diff / (n_failed + success.len()) as f32) * 100.;
let diff_perc_excluding_failures = non_nan(total_diff / success.len() as f32) * 100.;
let (mut fontc_failed, mut fontmake_failed, mut both_failed, mut other_failure) =
(0, 0, 0, 0);
for fail in failure.values() {
Expand Down Expand Up @@ -146,6 +147,15 @@ fn assert_has_timeout_coreutil() {
std::process::exit(1);
}

// replace nan with 0
fn non_nan(val: f32) -> f32 {
if val.is_nan() {
0.0
} else {
val
}
}

/// make sure we can find and execute ttx_diff script
pub(super) fn assert_can_run_script() {
// first check that we can find timeout(1) (not present on macOS by default,
Expand Down

0 comments on commit bbaf815

Please sign in to comment.