mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +00:00
ui tests: fix for MacOS and skip for Windows
This commit is contained in:
parent
af7e95ae98
commit
bc1d9457f0
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -793,7 +793,7 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"regex",
|
"regex",
|
||||||
"regex-syntax 0.7.4",
|
"regex-syntax 0.7.5",
|
||||||
"structmeta",
|
"structmeta",
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
@ -974,25 +974,25 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.9.3"
|
version = "1.9.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a"
|
checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex-automata",
|
"regex-automata",
|
||||||
"regex-syntax 0.7.4",
|
"regex-syntax 0.7.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.3.6"
|
version = "0.3.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69"
|
checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex-syntax 0.7.4",
|
"regex-syntax 0.7.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1003,9 +1003,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.7.4"
|
version = "0.7.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
|
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "roff"
|
name = "roff"
|
||||||
|
23
tests/ui.rs
23
tests/ui.rs
@ -8,8 +8,12 @@ mod utils;
|
|||||||
|
|
||||||
use std::{io, path::Path, process::Output};
|
use std::{io, path::Path, process::Output};
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
use insta::assert_display_snapshot as ui;
|
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;
|
use crate::utils::run_in;
|
||||||
|
|
||||||
fn testdir() -> io::Result<(tempfile::TempDir, &'static Path)> {
|
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
|
// remove random tempdir paths from snapshots to make them deterministic
|
||||||
fn redact_paths(text: &str, path: &Path) -> String {
|
fn redact_paths(text: &str, path: &Path) -> String {
|
||||||
let path = format!("{}/", path.display());
|
let redacted = "<FOLDER>";
|
||||||
|
|
||||||
text.replace(&path, "<FOLDER>/")
|
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 {
|
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!("--help")));
|
||||||
ui!(output_to_string(ouch!("-h")));
|
ui!(output_to_string(ouch!("-h")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! ignore {
|
||||||
|
($expr:expr) => {{
|
||||||
|
$expr
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user