Skip to content

Commit

Permalink
fix(test): Redact elapsed time in the minutes time frame
Browse files Browse the repository at this point in the history
This came up in #14231
```
---- expected: tests/testsuite/lto.rs:611:27
++++ actual:   stderr
   1    1 | [FRESH] registry-shared v0.0.1
   2    2 | [FRESH] registry v0.0.1
   3    3 | [COMPILING] bar v0.0.0 ([ROOT]/foo/bar)
   4    4 | [RUNNING] `rustc --crate-name bar [..]-C lto [..]--test [..]`
   5    5 | [RUNNING] `rustc --crate-name b [..]-C lto [..]--test [..]`
   6      - [FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
   7    6 | [RUNNING] `[ROOT]/foo/target/release/deps/bar-[HASH][EXE]`
   8    7 | [RUNNING] `[ROOT]/foo/target/release/deps/b-[HASH][EXE]`
   9    8 | [DOCTEST] bar
  10    9 | [RUNNING] `rustdoc --edition=2015 --crate-type cdylib --crate-type rlib --crate-name bar --test [..]-C lto [..]
       10 + [FINISHED] `release` profile [optimized] target(s) in 1m 00s

Update with SNAPSHOTS=overwrite
```
  • Loading branch information
epage committed Jul 10, 2024
1 parent 5ed6392 commit 7fcd580
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/cargo-test-support/src/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,19 @@ fn add_regex_redactions(subs: &mut snapbox::Redactions) {
// For e2e tests
subs.insert(
"[ELAPSED]",
regex!(r"\[FINISHED\].*in (?<redacted>[0-9]+(\.[0-9]+))s"),
regex!(r"\[FINISHED\].*in (?<redacted>[0-9]+(\.[0-9]+)?(m [0-9]+)?)s"),
)
.unwrap();
// for UI tests
subs.insert(
"[ELAPSED]",
regex!(r"Finished.*in (?<redacted>[0-9]+(\.[0-9]+))s"),
regex!(r"Finished.*in (?<redacted>[0-9]+(\.[0-9]+)?(m [0-9]+)?)s"),
)
.unwrap();
// output from libtest
subs.insert(
"[ELAPSED]",
regex!(r"; finished in (?<redacted>[0-9]+(\.[0-9]+))s"),
regex!(r"; finished in (?<redacted>[0-9]+(\.[0-9]+)?(m [0-9]+)?)s"),
)
.unwrap();
subs.insert(
Expand Down Expand Up @@ -976,7 +976,7 @@ B", false,
);
assert_data_eq!(
subs.redact("[FINISHED] `release` profile [optimized] target(s) in 1m 05s"),
str!["[FINISHED] `release` profile [optimized] target(s) in 1m 05s"].raw()
str!["[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s"].raw()
);
}
}

0 comments on commit 7fcd580

Please sign in to comment.