Skip to content

Commit 6daa25b

Browse files
authored
Use string for RunnerError instead of byte vector (#816)
1 parent 2076f15 commit 6daa25b

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

crates/cli/tests/dylib_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn test_dylib_with_error() -> Result<()> {
4141
let expected_log_output = "Error:1:24 foo error\n at foo (function.mjs:1:24)\n at <anonymous> (function.mjs:1:50)\n\n";
4242
assert_eq!(
4343
expected_log_output,
44-
String::from_utf8(e.downcast_ref::<RunnerError>().unwrap().stderr.clone())?
44+
e.downcast_ref::<RunnerError>().unwrap().stderr
4545
);
4646

4747
Ok(())

crates/cli/tests/integration_test.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ fn test_promises(builder: &mut Builder) -> Result<()> {
190190
let mut runner = builder.input("promise.js").build()?;
191191
let res = runner.exec(&[]);
192192
let err = res.err().unwrap().downcast::<RunnerError>().unwrap();
193-
assert!(str::from_utf8(&err.stderr)
194-
.unwrap()
195-
.contains("Pending jobs in the event queue."));
193+
assert!(err.stderr.contains("Pending jobs in the event queue."));
196194

197195
Ok(())
198196
}
@@ -272,7 +270,7 @@ fn test_error_handling(builder: &mut Builder) -> Result<()> {
272270

273271
let expected_log_output = "Error:2:9 error\n at error (function.mjs:2:9)\n at <anonymous> (function.mjs:5:1)\n\n";
274272

275-
assert_eq!(expected_log_output, str::from_utf8(&err.stderr).unwrap());
273+
assert_eq!(expected_log_output, err.stderr);
276274
Ok(())
277275
}
278276

crates/runner/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ pub struct Runner {
224224
#[derive(Debug)]
225225
pub struct RunnerError {
226226
pub stdout: Vec<u8>,
227-
pub stderr: Vec<u8>,
227+
pub stderr: String,
228228
pub err: anyhow::Error,
229229
}
230230

@@ -234,7 +234,7 @@ impl Display for RunnerError {
234234
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
235235
write!(
236236
f,
237-
"error: {:?}, stdout: {:?}, stderr: {:?}",
237+
"error: {:?}, stdout: {:?}, stderr: {}",
238238
self.err, self.stdout, self.stderr
239239
)
240240
}
@@ -809,7 +809,7 @@ impl Runner {
809809
Ok(_) => Ok((output, logs, fuel_consumed)),
810810
Err(err) => Err(RunnerError {
811811
stdout: output,
812-
stderr: logs,
812+
stderr: String::from_utf8(logs).unwrap(),
813813
err,
814814
}
815815
.into()),

0 commit comments

Comments
 (0)