Skip to content

Commit a3a9320

Browse files
committed
test+refactor: Create inspect_stderr
1 parent 6e9dff5 commit a3a9320

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

tests/_utils.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,11 @@ impl<'a> CommandList<'a> {
272272
}
273273
}
274274
}
275+
276+
pub fn inspect_stderr(stderr: &[u8]) {
277+
let text = String::from_utf8_lossy(stderr);
278+
let text = text.trim();
279+
if !text.is_empty() {
280+
eprintln!("STDERR:\n{}\n", text);
281+
}
282+
}

tests/flag_combinations.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub mod _utils;
44
pub use _utils::*;
55

66
use command_extra::CommandExtra;
7-
use pipe_trait::Pipe;
87
use std::process::Stdio;
98

109
/// There are branches of similar shapes in `/src/app.rs` that call
@@ -32,11 +31,7 @@ fn flag_combinations() {
3231
.with_stderr(Stdio::piped())
3332
.output()
3433
.expect("execute command");
35-
let error = output.stderr.pipe_as_ref(String::from_utf8_lossy);
36-
let error = error.trim();
37-
if !error.is_empty() {
38-
eprintln!("STDERR:\n{}\n", error);
39-
}
34+
inspect_stderr(&output.stderr);
4035
let status = output.status;
4136
assert!(status.success(), "status: {:?}", status.code())
4237
}

0 commit comments

Comments
 (0)