Skip to content

Commit

Permalink
Remove milliseconds in third-party test output
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Apr 7, 2024
1 parent 9e2edcc commit 9d60452
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions necessist/tests/third_party_common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,10 @@ fn run_test(tempdir: &Path, path: &Path, test: &Test) -> (String, Duration) {
let stdout_actual = std::str::from_utf8(&buf).unwrap();

// smoelius: Removing the line-column information makes comparing diffs easier.
let stdout_normalized = remove_line_columns(&normalize_paths(stdout_actual, tempdir));
let stdout_normalized = remove_millis(&remove_line_columns(&normalize_paths(
stdout_actual,
tempdir,
)));

if enabled("BLESS") {
write(path_stdout, stdout_normalized).unwrap();
Expand Down Expand Up @@ -631,11 +634,17 @@ fn normalize_paths(mut s: &str, path: &Path) -> String {
buf
}

static RE: Lazy<Regex> =
static LINE_COLUMN_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(?m)^\$DIR/([^:]*):[0-9]+:[0-9]+-[0-9]+:[0-9]+:").unwrap());

fn remove_line_columns(s: &str) -> String {
RE.replace_all(s, r"$$DIR/$1:").to_string()
LINE_COLUMN_RE.replace_all(s, r"$$DIR/$1:").to_string()
}

static MILLI_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"\b[0-9]+\.[0-9]+ms\b").unwrap());

fn remove_millis(s: &str) -> String {
MILLI_RE.replace_all(s, "[..]ms]").to_string()
}

fn permutation_ignoring_timeouts(expected: &str, actual: &str) -> bool {
Expand Down

0 comments on commit 9d60452

Please sign in to comment.