From bc1d9457f058785a2df34fc4ba9ea68a7b3d8d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Fri, 15 Sep 2023 23:16:00 -0300 Subject: [PATCH] ui tests: fix for MacOS and skip for Windows --- Cargo.lock | 18 +++++++++--------- tests/ui.rs | 23 +++++++++++++++++++++-- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d164bb5..f806a3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -793,7 +793,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "regex-syntax 0.7.4", + "regex-syntax 0.7.5", "structmeta", "syn", ] @@ -974,25 +974,25 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.3" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.7.4", + "regex-syntax 0.7.5", ] [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.4", + "regex-syntax 0.7.5", ] [[package]] @@ -1003,9 +1003,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "roff" diff --git a/tests/ui.rs b/tests/ui.rs index 68c642e..efbf8c1 100644 --- a/tests/ui.rs +++ b/tests/ui.rs @@ -8,8 +8,12 @@ mod utils; use std::{io, path::Path, process::Output}; +#[cfg(not(windows))] use insta::assert_display_snapshot as ui; +// Don't run these on Windows +#[cfg(windows)] +use self::ignore as ui; use crate::utils::run_in; fn testdir() -> io::Result<(tempfile::TempDir, &'static Path)> { @@ -37,9 +41,16 @@ fn run_ouch(argv: &str, dir: &Path) -> String { // remove random tempdir paths from snapshots to make them deterministic fn redact_paths(text: &str, path: &Path) -> String { - let path = format!("{}/", path.display()); + let redacted = ""; - text.replace(&path, "/") + let path = path.display(); + let path = if cfg!(target_os = "macos") { + format!(r"/private{path}") + } else { + path.to_string() + }; + + text.replace(path.as_str(), redacted) } fn output_to_string(output: Output) -> String { @@ -101,3 +112,11 @@ fn ui_test_usage_help_flag() { ui!(output_to_string(ouch!("--help"))); ui!(output_to_string(ouch!("-h"))); } + +#[allow(unused)] +#[macro_export] +macro_rules! ignore { + ($expr:expr) => {{ + $expr + }}; +}