From 300bf249ff6e7bdd2362a510048c1eafc3da6349 Mon Sep 17 00:00:00 2001 From: Daniel Lehmann Date: Sat, 27 Jul 2024 15:25:35 +0200 Subject: [PATCH] cleanup warnings, errors output a bit --- crates/test_utilities/src/lib.rs | 12 +++++++----- crates/wasabi/src/tests.rs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/test_utilities/src/lib.rs b/crates/test_utilities/src/lib.rs index 69a445d8..fe7bf42f 100644 --- a/crates/test_utilities/src/lib.rs +++ b/crates/test_utilities/src/lib.rs @@ -58,7 +58,7 @@ pub fn for_each_valid_wasm_binary_in_test_set(test_fn: impl Fn(&Path) + Send + S system.available_memory() }; if memory_needed_for_ast_approx > memory_available { - eprintln!("Skipping {} due to running low on memory...\n\t{:10} bytes memory available\n\t{:10} bytes module size\n\t{:10} bytes memory approximately required", path.display(), memory_available, module_size_bytes, memory_needed_for_ast_approx); + eprintln!("skipping '{}' due to running low on memory...\n\t{:10} bytes memory available\n\t{:10} bytes module size\n\t{:10} bytes memory approximately required", path.display(), memory_available, module_size_bytes, memory_needed_for_ast_approx); return; } @@ -130,12 +130,12 @@ impl fmt::Display for WasmValidateError { } => { writeln!(f, "invalid Wasm file {input_file}")?; writeln!(f, "\twasm-validate status code: {status_code}")?; - writeln!(f, "\tstdout: {stdout}")?; - writeln!(f, "\tstderr: {stderr}") + writeln!(f, "\tstdout: {}", stdout.trim())?; + writeln!(f, "\tstderr: {}", stderr.trim()) } WasmValidateError::CouldNotValidate { input_file, error } => { writeln!(f, "could not validate Wasm file {input_file}")?; - writeln!(f, "possibly crash, error: {error}") + writeln!(f, "\tpossibly crash\n\t{}", error.trim()) } } } @@ -162,13 +162,15 @@ pub fn wasm_validate(path: impl AsRef) -> Result<(), WasmValidateError> { Ok(validate_output) => match validate_output.status.code() { Some(0) => { assert!(validate_output.stdout.is_empty()); + // Warnings don't make validation fail but _are_ printed on stderr. let stderr = String::from_utf8_lossy(&validate_output.stderr); let stderr = stderr.trim(); if !stderr.is_empty() { let file_info = WasmFileInfo::new(path); - eprintln!("wasm-validate warning on {file_info}: {stderr}"); + eprintln!("wasm-validate warning on {file_info}:\n\t{stderr}"); } + Ok(()) }, Some(status_code) => Err(WasmValidateError::InvalidWasmFile { diff --git a/crates/wasabi/src/tests.rs b/crates/wasabi/src/tests.rs index ad8d949c..86b0b3da 100644 --- a/crates/wasabi/src/tests.rs +++ b/crates/wasabi/src/tests.rs @@ -54,7 +54,7 @@ fn test_instrument(instrument: fn(&mut Module) -> Option, instrument_nam } // NOTE: If the instrumented binary is very large, `wasm-validate` can OOM. Log but ignore this here. Err(err @ WasmValidateError::CouldNotValidate { .. }) => { - eprintln!("{err}\nignoring this here (possible OOM), please validate manually...") + eprintln!("{err}\n\tignoring this here (possible OOM), please validate manually...") } } });