Skip to content

Commit

Permalink
Merge pull request #1077 from googlefonts/crater-no-nans
Browse files Browse the repository at this point in the history
[crater] Don't serialize nans
  • Loading branch information
rsheeter authored Oct 30, 2024
2 parents 85b467a + bbaf815 commit b0745a8
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 @@ -124,8 +124,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 @@ -163,6 +164,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 b0745a8

Please sign in to comment.