mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 12:37:49 +00:00
Merge pull request #2108 from miDeb/tests-pretty-diffs
tests: show pretty diffs for assertion failures
This commit is contained in:
commit
883dec9d00
3 changed files with 43 additions and 3 deletions
38
Cargo.lock
generated
38
Cargo.lock
generated
|
@ -221,6 +221,7 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
"nix 0.20.0",
|
"nix 0.20.0",
|
||||||
|
"pretty_assertions",
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"regex",
|
"regex",
|
||||||
"sha1",
|
"sha1",
|
||||||
|
@ -526,6 +527,16 @@ dependencies = [
|
||||||
"memchr 2.3.4",
|
"memchr 2.3.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ctor"
|
||||||
|
version = "0.1.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5e98e2ad1a782e33928b96fc3948e7c355e5af34ba4de7670fe8bac2a3b2006d"
|
||||||
|
dependencies = [
|
||||||
|
"quote 1.0.9",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custom_derive"
|
name = "custom_derive"
|
||||||
version = "0.1.7"
|
version = "0.1.7"
|
||||||
|
@ -538,6 +549,12 @@ version = "2.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97"
|
checksum = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "diff"
|
||||||
|
version = "0.1.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.6.2"
|
version = "0.6.2"
|
||||||
|
@ -949,6 +966,15 @@ version = "11.1.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "output_vt100"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9"
|
||||||
|
dependencies = [
|
||||||
|
"winapi 0.3.9",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "paste"
|
name = "paste"
|
||||||
version = "0.1.18"
|
version = "0.1.18"
|
||||||
|
@ -1018,6 +1044,18 @@ version = "0.2.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pretty_assertions"
|
||||||
|
version = "0.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1cab0e7c02cf376875e9335e0ba1da535775beb5450d21e1dffca068818ed98b"
|
||||||
|
dependencies = [
|
||||||
|
"ansi_term 0.12.1",
|
||||||
|
"ctor",
|
||||||
|
"diff",
|
||||||
|
"output_vt100",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-hack"
|
name = "proc-macro-hack"
|
||||||
version = "0.5.19"
|
version = "0.5.19"
|
||||||
|
|
|
@ -335,6 +335,7 @@ filetime = "0.2"
|
||||||
glob = "0.3.0"
|
glob = "0.3.0"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
nix = "0.20.0"
|
nix = "0.20.0"
|
||||||
|
pretty_assertions = "0.7.2"
|
||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
regex = "1.0"
|
regex = "1.0"
|
||||||
sha1 = { version="0.6", features=["std"] }
|
sha1 = { version="0.6", features=["std"] }
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use libc;
|
use libc;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
use std::env;
|
use std::env;
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
|
@ -221,7 +222,7 @@ impl CmdResult {
|
||||||
/// like stdout_is(...), but expects the contents of the file at the provided relative path
|
/// like stdout_is(...), but expects the contents of the file at the provided relative path
|
||||||
pub fn stdout_is_fixture<T: AsRef<OsStr>>(&self, file_rel_path: T) -> &CmdResult {
|
pub fn stdout_is_fixture<T: AsRef<OsStr>>(&self, file_rel_path: T) -> &CmdResult {
|
||||||
let contents = read_scenario_fixture(&self.tmpd, file_rel_path);
|
let contents = read_scenario_fixture(&self.tmpd, file_rel_path);
|
||||||
self.stdout_is_bytes(contents)
|
self.stdout_is(String::from_utf8(contents).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// asserts that the command resulted in stderr stream output that equals the
|
/// asserts that the command resulted in stderr stream output that equals the
|
||||||
|
@ -245,7 +246,7 @@ impl CmdResult {
|
||||||
/// Like stdout_is_fixture, but for stderr
|
/// Like stdout_is_fixture, but for stderr
|
||||||
pub fn stderr_is_fixture<T: AsRef<OsStr>>(&self, file_rel_path: T) -> &CmdResult {
|
pub fn stderr_is_fixture<T: AsRef<OsStr>>(&self, file_rel_path: T) -> &CmdResult {
|
||||||
let contents = read_scenario_fixture(&self.tmpd, file_rel_path);
|
let contents = read_scenario_fixture(&self.tmpd, file_rel_path);
|
||||||
self.stderr_is_bytes(contents)
|
self.stderr_is(String::from_utf8(contents).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// asserts that
|
/// asserts that
|
||||||
|
@ -619,7 +620,7 @@ impl TestScenario {
|
||||||
},
|
},
|
||||||
util_name: String::from(util_name),
|
util_name: String::from(util_name),
|
||||||
fixtures: AtPath::new(tmpd.as_ref().path()),
|
fixtures: AtPath::new(tmpd.as_ref().path()),
|
||||||
tmpd: tmpd,
|
tmpd,
|
||||||
};
|
};
|
||||||
let mut fixture_path_builder = env::current_dir().unwrap();
|
let mut fixture_path_builder = env::current_dir().unwrap();
|
||||||
fixture_path_builder.push(TESTS_DIR);
|
fixture_path_builder.push(TESTS_DIR);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue