Skip to content

Commit 46b3712

Browse files
committed
test+refactor: Move stdout_text to _utils
1 parent 486ed0e commit 46b3712

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

tests/_utils.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::{
1717
fs::{create_dir, metadata, remove_dir_all, Metadata},
1818
io::Error,
1919
path::{Path, PathBuf},
20-
process::Command,
20+
process::{Command, Output},
2121
};
2222

2323
/// Representation of a temporary filesystem item.
@@ -273,6 +273,26 @@ impl<'a> CommandList<'a> {
273273
}
274274
}
275275

276+
pub fn stdout_text(
277+
Output {
278+
status,
279+
stdout,
280+
stderr,
281+
}: Output,
282+
) -> String {
283+
inspect_stderr(&stderr);
284+
assert!(
285+
status.success(),
286+
"progress exits with non-zero status: {:?}",
287+
status
288+
);
289+
stdout
290+
.pipe(String::from_utf8)
291+
.expect("parse stdout as UTF-8")
292+
.trim()
293+
.to_string()
294+
}
295+
276296
pub fn inspect_stderr(stderr: &[u8]) {
277297
let text = String::from_utf8_lossy(stderr);
278298
let text = text.trim();

tests/json.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,14 @@ use pretty_assertions::assert_eq;
2020
use std::{
2121
convert::TryInto,
2222
io::Write,
23-
process::{Command, Output, Stdio},
23+
process::{Command, Stdio},
2424
};
2525

2626
type SampleName = String;
2727
type SampleData = Bytes;
2828
type SampleReflection = Reflection<SampleName, SampleData>;
2929
type SampleTree = DataTree<SampleName, SampleData>;
3030

31-
fn stdout_text(
32-
Output {
33-
status,
34-
stdout,
35-
stderr,
36-
}: Output,
37-
) -> String {
38-
inspect_stderr(&stderr);
39-
assert!(
40-
status.success(),
41-
"progress exits with non-zero status: {:?}",
42-
status
43-
);
44-
stdout
45-
.pipe(String::from_utf8)
46-
.expect("parse stdout as UTF-8")
47-
.trim()
48-
.to_string()
49-
}
50-
5131
fn sample_tree() -> SampleTree {
5232
let dir = |name: &'static str, children: Vec<SampleTree>| {
5333
SampleTree::dir(name.to_string(), 1024.into(), children)

0 commit comments

Comments
 (0)