fix(pipeline): use OsString in tests

Signed-off-by: Charlotte Meyer <dev@buffet.sh>
This commit is contained in:
buffet 2022-10-24 21:27:24 +00:00
parent eb78097206
commit a5d971de35

View file

@ -1,10 +1,10 @@
use std::{ use std::{
borrow::Cow, borrow::Cow,
env, env,
ffi::OsStr, ffi::{OsStr, OsString},
fs::File, fs::File,
io::{BufRead, BufReader, Write}, io::{BufRead, BufReader, Write},
os::unix::io::FromRawFd, os::unix::{ffi::OsStringExt, io::FromRawFd},
process, process,
}; };
@ -30,7 +30,7 @@ fn test_builtin(_: &mut Shell, _: &[Cow<OsStr>]) {
/// Forks to redirect stdin, stderr, stdout, then run the commands. /// Forks to redirect stdin, stderr, stdout, then run the commands.
/// Relies on inserting a NUL byte in the end, so there shouldn't be NUL in the output. /// Relies on inserting a NUL byte in the end, so there shouldn't be NUL in the output.
fn collect_output<F>(mut f: F) -> String fn collect_output<F>(mut f: F) -> OsString
where where
F: FnMut(), F: FnMut(),
{ {
@ -65,9 +65,7 @@ where
let mut buf = vec![]; let mut buf = vec![];
r.read_until(0, &mut buf).unwrap(); r.read_until(0, &mut buf).unwrap();
std::str::from_utf8(&buf[..buf.len() - 1]) OsString::from_vec(buf[..buf.len() - 1].to_vec())
.unwrap()
.to_owned()
} }
#[test] #[test]