From fcd53261dd9fa55cf562bc3f9734e8befda7a4a3 Mon Sep 17 00:00:00 2001 From: Edoardo Marangoni Date: Tue, 5 Nov 2024 13:52:34 +0100 Subject: [PATCH] fix: Init logging in tests --- Cargo.lock | 27 ++++++++++++++++++++++++++- lib/wasix/Cargo.toml | 2 ++ lib/wasix/tests/runners.rs | 13 +++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 7c6adcb591b..af23f37d64a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -369,7 +369,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.10.5", + "itertools 0.12.1", "log", "prettyplease", "proc-macro2", @@ -1681,6 +1681,29 @@ dependencies = [ "syn 2.0.85", ] +[[package]] +name = "env_filter" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -6931,6 +6954,7 @@ dependencies = [ "cooked-waker", "dashmap 6.1.0", "derivative", + "env_logger", "futures", "getrandom", "heapless", @@ -6943,6 +6967,7 @@ dependencies = [ "lazy_static", "libc", "linked_hash_set", + "log", "lz4_flex", "num_enum", "once_cell", diff --git a/lib/wasix/Cargo.toml b/lib/wasix/Cargo.toml index 2e8417b49d5..99b77f54ac1 100644 --- a/lib/wasix/Cargo.toml +++ b/lib/wasix/Cargo.toml @@ -164,6 +164,8 @@ tokio = { workspace = true, features = [ pretty_assertions.workspace = true tracing-test = "0.2.4" wasm-bindgen-test = "0.3.0" +env_logger = "0.11.5" +log = "0.4.22" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen-test = "0.3.0" diff --git a/lib/wasix/tests/runners.rs b/lib/wasix/tests/runners.rs index e21807f29c6..3c54b500647 100644 --- a/lib/wasix/tests/runners.rs +++ b/lib/wasix/tests/runners.rs @@ -2,12 +2,15 @@ // there. #![cfg(not(target_family = "wasm"))] +use std::sync::Once; use std::{ path::{Path, PathBuf}, sync::Arc, time::Duration, }; +static INIT: Once = Once::new(); + use reqwest::Client; use tokio::runtime::Handle; use wasmer::Engine; @@ -29,6 +32,13 @@ mod wasi { use super::*; + fn setup() { + INIT.call_once(|| { + env_logger::builder() + .filter_level(log::LevelFilter::max()) + .init(); + }); + } #[tokio::test] async fn can_run_wat2wasm() { let webc = download_cached("https://wasmer.io/wasmer/wabt@1.0.37").await; @@ -40,6 +50,7 @@ mod wasi { #[tokio::test(flavor = "multi_thread")] async fn wat2wasm() { + setup(); let webc = download_cached("https://wasmer.io/wasmer/wabt@1.0.37").await; let container = from_bytes(webc).unwrap(); let (rt, tasks) = runtime(); @@ -81,6 +92,8 @@ mod wasi { #[tokio::test(flavor = "multi_thread")] async fn python() { + setup(); + let webc = download_cached("https://wasmer.io/python/python@0.1.0").await; let (rt, tasks) = runtime(); let container = from_bytes(webc).unwrap();