fix(runtime tests): treat write's better
- unwrap on writeln!() - make sure "all" [0] is written in capture Signed-off-by: Charlotte Meyer <dev@buffet.sh>
This commit is contained in:
parent
87b911183c
commit
4a9d49fbd8
2 changed files with 7 additions and 4 deletions
|
@ -1,6 +1,10 @@
|
||||||
mod math;
|
mod math;
|
||||||
|
|
||||||
use std::{borrow::Cow, ffi::OsStr, io::Write};
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
|
ffi::OsStr,
|
||||||
|
io::{self, Write},
|
||||||
|
};
|
||||||
|
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use oyster_builtin_proc::builtin;
|
use oyster_builtin_proc::builtin;
|
||||||
|
@ -11,8 +15,7 @@ use crate::collect_output;
|
||||||
|
|
||||||
#[builtin(description = "test builtin")]
|
#[builtin(description = "test builtin")]
|
||||||
fn test_builtin(_: &mut Shell, _: &[Cow<OsStr>]) {
|
fn test_builtin(_: &mut Shell, _: &[Cow<OsStr>]) {
|
||||||
// XXX: this is a workaround around libtest's use of io::set_output_capture
|
writeln!(io::stdout(), "this is a test").unwrap();
|
||||||
let _ = write!(std::io::stdout(), "this is a test\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check(ast: &ast::Code, expect: Expect) {
|
fn check(ast: &ast::Code, expect: Expect) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ where
|
||||||
let master = unsafe { File::from_raw_fd(master) };
|
let master = unsafe { File::from_raw_fd(master) };
|
||||||
let mut slave = unsafe { File::from_raw_fd(slave) };
|
let mut slave = unsafe { File::from_raw_fd(slave) };
|
||||||
|
|
||||||
slave.write(&[0]).unwrap();
|
slave.write_all(&[0]).unwrap();
|
||||||
let mut r = BufReader::new(master);
|
let mut r = BufReader::new(master);
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
r.read_until(0, &mut buf).unwrap();
|
r.read_until(0, &mut buf).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue