Auto merge of #13973 - epage:elapsed, r=weihanglo

feat(test): Auto-redact elapsed time

By making this a redaction,
it automatically gets applied when generating the snapshot,
removing these extra steps
(that you likely only discover after the fact and have to debug)
This commit is contained in:
bors 2024-05-28 17:06:13 +00:00
commit 2415192bcd
5 changed files with 10 additions and 2 deletions

2
Cargo.lock generated
View File

@ -426,6 +426,7 @@ dependencies = [
"glob",
"itertools 0.12.1",
"pasetors",
"regex",
"serde",
"serde_json",
"snapbox",
@ -3220,6 +3221,7 @@ dependencies = [
"escargot",
"filetime",
"normalize-line-endings",
"regex",
"serde_json",
"similar",
"snapbox-macros",

View File

@ -91,7 +91,7 @@ sha1 = "0.10.6"
sha2 = "0.10.8"
shell-escape = "0.1.5"
supports-hyperlinks = "3.0.0"
snapbox = { version = "0.6.5", features = ["diff", "dir", "term-svg"] }
snapbox = { version = "0.6.5", features = ["diff", "dir", "term-svg", "regex"] }
tar = { version = "0.4.40", default-features = false }
tempfile = "3.10.1"
thiserror = "1.0.59"

View File

@ -24,6 +24,7 @@ git2.workspace = true
glob.workspace = true
itertools.workspace = true
pasetors.workspace = true
regex.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
snapbox.workspace = true

View File

@ -86,6 +86,11 @@ pub fn assert_ui() -> snapbox::Assert {
.unwrap();
subs.insert("[ROOT]", root).unwrap();
subs.insert("[ROOTURL]", root_url).unwrap();
subs.insert(
"[ELAPSED]",
regex::Regex::new("Finished.*in (?<redacted>[0-9]+(\\.[0-9]+))s").unwrap(),
)
.unwrap();
snapbox::Assert::new()
.action_env(snapbox::assert::DEFAULT_ACTION_ENV)
.redact_with(subs)

View File

@ -37,7 +37,7 @@
</tspan>
<tspan x="10px" y="154px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.0.1 ([ROOT]/foo)</tspan>
</tspan>
<tspan x="10px" y="172px"><tspan class="fg-green bold"> Finished</tspan><tspan> [..]</tspan>
<tspan x="10px" y="172px"><tspan class="fg-green bold"> Finished</tspan><tspan> `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s</tspan>
</tspan>
<tspan x="10px" y="190px">
</tspan>

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB