From 4a9d49fbd8dc4d945c81540a618115f2647ccd80 Mon Sep 17 00:00:00 2001 From: Charlotte Meyer Date: Sat, 5 Nov 2022 16:21:34 +0000 Subject: [PATCH] fix(runtime tests): treat write's better - unwrap on writeln!() - make sure "all" [0] is written in capture Signed-off-by: Charlotte Meyer --- crates/oyster_runtime/tests/it/builtins/mod.rs | 9 ++++++--- crates/oyster_runtime/tests/it/main.rs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/oyster_runtime/tests/it/builtins/mod.rs b/crates/oyster_runtime/tests/it/builtins/mod.rs index 01ddb86..85a9507 100644 --- a/crates/oyster_runtime/tests/it/builtins/mod.rs +++ b/crates/oyster_runtime/tests/it/builtins/mod.rs @@ -1,6 +1,10 @@ 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 oyster_builtin_proc::builtin; @@ -11,8 +15,7 @@ use crate::collect_output; #[builtin(description = "test builtin")] fn test_builtin(_: &mut Shell, _: &[Cow]) { - // XXX: this is a workaround around libtest's use of io::set_output_capture - let _ = write!(std::io::stdout(), "this is a test\n"); + writeln!(io::stdout(), "this is a test").unwrap(); } fn check(ast: &ast::Code, expect: Expect) { diff --git a/crates/oyster_runtime/tests/it/main.rs b/crates/oyster_runtime/tests/it/main.rs index 47e4850..177fe27 100644 --- a/crates/oyster_runtime/tests/it/main.rs +++ b/crates/oyster_runtime/tests/it/main.rs @@ -50,7 +50,7 @@ where let master = unsafe { File::from_raw_fd(master) }; 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 buf = vec![]; r.read_until(0, &mut buf).unwrap();