Fix test snapshot filter when runtime is greater than 1s (#267)

Tests would sometimes flake with this locally e.g. "1.50s" was not
filtered correctly.

Verified with

```diff
diff --git a/crates/puffin-cli/src/commands/pip_compile.rs b/crates/puffin-cli/src/commands/pip_compile.rs
index 0193216..2d6f8af 100644
--- a/crates/puffin-cli/src/commands/pip_compile.rs
+++ b/crates/puffin-cli/src/commands/pip_compile.rs
@@ -150,6 +150,8 @@ pub(crate) async fn pip_compile(
         result => result,
     }?;
 
+    std:🧵:sleep(std::time::Duration::from_secs(1));
+
     let s = if resolution.len() == 1 { "" } else { "s" };
     writeln!(
         printer,
```
This commit is contained in:
Zanie Blue 2023-11-01 08:15:06 -05:00 committed by GitHub
parent 079b685c8c
commit fa9f8df396
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View file

@ -70,7 +70,7 @@ fn compile_requirements_in() -> Result<()> {
insta::with_settings!({
filters => vec![
(r"\d+(ms|s)", "[TIME]"),
(r"(\d|\.)+(ms|s)", "[TIME]"),
(r"# .* pip-compile", "# [BIN_PATH] pip-compile"),
(r"--cache-dir .*", "--cache-dir [CACHE_DIR]"),
]
@ -120,7 +120,7 @@ dependencies = [
insta::with_settings!({
filters => vec![
(r"\d+(ms|s)", "[TIME]"),
(r"(\d|\.)+(ms|s)", "[TIME]"),
(r"# .* pip-compile", "# [BIN_PATH] pip-compile"),
(r"--cache-dir .*", "--cache-dir [CACHE_DIR]"),
]
@ -164,7 +164,7 @@ fn compile_constraints_txt() -> Result<()> {
insta::with_settings!({
filters => vec![
(r"\d+(ms|s)", "[TIME]"),
(r"(\d|\.)+(ms|s)", "[TIME]"),
(r"# .* pip-compile", "# [BIN_PATH] pip-compile"),
(r"--cache-dir .*", "--cache-dir [CACHE_DIR]"),
]
@ -211,7 +211,7 @@ fn compile_constraints_inline() -> Result<()> {
insta::with_settings!({
filters => vec![
(r"\d+(ms|s)", "[TIME]"),
(r"(\d|\.)+(ms|s)", "[TIME]"),
(r"# .* pip-compile", "# [BIN_PATH] pip-compile"),
(r"--cache-dir .*", "--cache-dir [CACHE_DIR]"),
]
@ -262,7 +262,7 @@ optional-dependencies.foo = [
insta::with_settings!({
filters => vec![
(r"\d+(ms|s)", "[TIME]"),
(r"(\d|\.)+(ms|s)", "[TIME]"),
(r"# .* pip-compile", "# [BIN_PATH] pip-compile"),
(r"--cache-dir .*", "--cache-dir [CACHE_DIR]"),
]
@ -315,7 +315,7 @@ optional-dependencies."FrIeNdLy-._.-bArD" = [
insta::with_settings!({
filters => vec![
(r"\d+(ms|s)", "[TIME]"),
(r"(\d|\.)+(ms|s)", "[TIME]"),
(r"# .* pip-compile", "# [BIN_PATH] pip-compile"),
(r"--cache-dir .*", "--cache-dir [CACHE_DIR]"),
]
@ -368,7 +368,7 @@ optional-dependencies.foo = [
insta::with_settings!({
filters => vec![
(r"\d+(ms|s)", "[TIME]"),
(r"(\d|\.)+(ms|s)", "[TIME]"),
(r"# .* pip-compile", "# [BIN_PATH] pip-compile"),
(r"--cache-dir .*", "--cache-dir [CACHE_DIR]"),
]
@ -421,7 +421,7 @@ optional-dependencies.foo = [
insta::with_settings!({
filters => vec![
(r"\d+(ms|s)", "[TIME]"),
(r"(\d|\.)+(ms|s)", "[TIME]"),
(r"# .* pip-compile", "# [BIN_PATH] pip-compile"),
(r"--cache-dir .*", "--cache-dir [CACHE_DIR]"),
]

View file

@ -71,7 +71,7 @@ fn install() -> Result<()> {
insta::with_settings!({
filters => vec![
(r"\d+ms", "[TIME]"),
(r"(\d|\.)+(ms|s)", "[TIME]"),
]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
@ -116,7 +116,7 @@ fn install_copy() -> Result<()> {
insta::with_settings!({
filters => vec![
(r"\d+ms", "[TIME]"),
(r"(\d|\.)+(ms|s)", "[TIME]"),
]
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))