Skip to content

Commit 9aa8698

Browse files
committed
Print all assertions that failed in test_ignore_and_pipefail()
1 parent 5e77f2b commit 9aa8698

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

tests/test_macros.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,38 @@ fn test_ignore_and_pipefail() {
248248
// .wait_with_pipe(&mut |_stdout| {})),
249249
];
250250

251+
macro_rules! check_eq {
252+
($left:expr, $right:expr, $($rest:tt)+) => {{
253+
let left = $left;
254+
let right = $right;
255+
if left != right {
256+
eprintln!("assertion failed ({} != {}): {}", left, right, format!($($rest)+));
257+
false
258+
} else {
259+
true
260+
}
261+
}};
262+
}
263+
264+
let mut ok = true;
251265
for case in test_cases.iter().flat_map(|items| items.iter()) {
252-
assert_eq!(
266+
ok &= check_eq!(
253267
(case.code)(),
254268
case.expected_ok_pipefail_on,
255269
"{} when pipefail is on",
256270
case.code_str
257271
);
258272
set_pipefail(false);
259-
assert_eq!(
273+
ok &= check_eq!(
260274
(case.code)(),
261275
case.expected_ok_pipefail_off,
262276
"{} when pipefail is off",
263277
case.code_str
264278
);
265279
set_pipefail(true);
266280
}
281+
282+
assert!(ok);
267283
}
268284

269285
#[test]

0 commit comments

Comments
 (0)