Skip to content

Commit eee1053

Browse files
committed
refactor: Port from matches_unordered to assert_e2e
1 parent 3054936 commit eee1053

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

crates/cargo-test-support/src/compare.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ pub fn assert_e2e() -> snapbox::Assert {
151151
.redact_with(subs)
152152
}
153153

154-
static MIN_LITERAL_REDACTIONS: &[(&str, &str)] = &[("[EXE]", std::env::consts::EXE_SUFFIX)];
154+
static MIN_LITERAL_REDACTIONS: &[(&str, &str)] = &[
155+
("[EXE]", std::env::consts::EXE_SUFFIX),
156+
("[BROKEN_PIPE]", "Broken pipe (os error 32)"),
157+
("[BROKEN_PIPE]", "The pipe is being closed. (os error 232)"),
158+
];
155159
static E2E_LITERAL_REDACTIONS: &[(&str, &str)] = &[
156160
("[RUNNING]", " Running"),
157161
("[COMPILING]", " Compiling"),
@@ -351,7 +355,7 @@ pub(crate) fn assert_match_exact(expected: &str, actual: &str) {
351355
/// of the lines.
352356
///
353357
/// See [Patterns](index.html#patterns) for more information on pattern matching.
354-
pub fn match_unordered(expected: &str, actual: &str, cwd: Option<&Path>) -> Result<()> {
358+
pub(crate) fn match_unordered(expected: &str, actual: &str, cwd: Option<&Path>) -> Result<()> {
355359
let expected = normalize_expected(expected, cwd);
356360
let actual = normalize_actual(actual, cwd);
357361
let e: Vec<_> = expected.lines().map(|line| WildStr::new(line)).collect();

tests/testsuite/build.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ use cargo::{
66
ops::CompileOptions,
77
GlobalContext,
88
};
9+
use cargo_test_support::compare::assert_e2e;
910
use cargo_test_support::paths::{root, CargoPathExt};
11+
use cargo_test_support::prelude::*;
1012
use cargo_test_support::registry::Package;
13+
use cargo_test_support::str;
1114
use cargo_test_support::{
12-
basic_bin_manifest, basic_lib_manifest, basic_manifest, cargo_exe, cargo_process, compare, git,
15+
basic_bin_manifest, basic_lib_manifest, basic_manifest, cargo_exe, cargo_process, git,
1316
is_nightly, main_file, paths, process, project, rustc_host, sleep_ms, symlink_supported, t,
1417
tools, Execs, ProjectBuilder,
1518
};
@@ -6448,17 +6451,17 @@ fn close_output() {
64486451
};
64496452

64506453
let stderr = spawn(false);
6451-
compare::match_unordered(
6452-
"\
6453-
[COMPILING] foo [..]
6454+
assert_e2e().eq(
6455+
&stderr,
6456+
str![[r#"
6457+
[COMPILING] foo v0.1.0 ([ROOT]/foo)
64546458
hello stderr!
6455-
[ERROR] [..]
6459+
[ERROR] [BROKEN_PIPE]
64566460
[WARNING] build failed, waiting for other jobs to finish...
6457-
",
6458-
&stderr,
6459-
None,
6460-
)
6461-
.unwrap();
6461+
6462+
"#]]
6463+
.unordered(),
6464+
);
64626465

64636466
// Try again with stderr.
64646467
p.build_dir().rm_rf();

0 commit comments

Comments
 (0)