From 336e46559c49c9adf25a0a00280cbef1d7235c28 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 15 May 2023 20:43:41 -0700 Subject: [PATCH] fixes, comments --- Cargo.lock | 43 +++++++++++++------ crates/test-programs/Cargo.toml | 18 ++++---- crates/test-programs/build.rs | 6 +-- .../test-programs/tests/wasi-cap-std-sync.rs | 3 ++ crates/test-programs/tests/wasi-tokio.rs | 5 ++- 5 files changed, 50 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b747c2673332..c4ef3f2e1c89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1943,6 +1943,15 @@ dependencies = [ "libc", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + [[package]] name = "maybe-owned" version = "0.3.4" @@ -2170,16 +2179,6 @@ dependencies = [ "pretty_env_logger", ] -[[package]] -name = "os_pipe" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb233f06c2307e1f5ce2ecad9f8121cffbbee2c95428f44ea85222e460d0d213" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "os_str_bytes" version = "6.0.0" @@ -2641,6 +2640,9 @@ name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] [[package]] name = "regex-syntax" @@ -3097,6 +3099,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "test-log" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f0c854faeb68a048f0f2dc410c5ddae3bf83854ef0e4977d58306a5edef50e" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.92", +] + [[package]] name = "test-programs" version = "0.0.0" @@ -3110,17 +3123,17 @@ dependencies = [ "http-body", "http-body-util", "hyper", - "os_pipe", - "target-lexicon", + "lazy_static", "tempfile", + "test-log", "tokio", + "tracing", "tracing-subscriber", "wasi-cap-std-sync", "wasi-common", "wasmtime", "wasmtime-wasi", "wasmtime-wasi-http", - "wat", "wit-component 0.9.0", ] @@ -3286,8 +3299,12 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596" dependencies = [ + "lazy_static", + "matchers", + "regex", "sharded-slab", "thread_local", + "tracing", "tracing-core", ] diff --git a/crates/test-programs/Cargo.toml b/crates/test-programs/Cargo.toml index fa301bb2f7fc..871fe5d7f33b 100644 --- a/crates/test-programs/Cargo.toml +++ b/crates/test-programs/Cargo.toml @@ -14,18 +14,20 @@ wit-component = "0.9.0" heck = "0.4.0" [dev-dependencies] +anyhow = { workspace = true } +tempfile = "3.1.0" +test-log = { version = "0.2", default-features = false, features = ["trace"] } +tracing = { workspace = true } +tracing-subscriber = { version = "0.3.1", default-features = false, features = ['fmt', 'env-filter'] } +lazy_static = "1" +wasmtime = { workspace = true, features = ['cranelift', 'component-model'] } + wasi-common = { workspace = true } wasi-cap-std-sync = { workspace = true } -wasmtime = { workspace = true, features = ['cranelift'] } wasmtime-wasi = { workspace = true, features = ["tokio"] } -target-lexicon = { workspace = true } -tracing-subscriber = { version = "0.3.1", default-features = false, features = ['fmt'] } -tempfile = "3.1.0" -os_pipe = "0.9" -anyhow = { workspace = true } -wat = { workspace = true } cap-std = { workspace = true } -tokio = { version = "1.8.0", features = ["net", "rt-multi-thread"] } +tokio = { version = "1.8.0", features = ["net", "rt-multi-thread", "macros"] } + wasmtime-wasi-http = { workspace = true } hyper = { version = "1.0.0-rc.3", features = ["full"] } http = { version = "0.2.9" } diff --git a/crates/test-programs/build.rs b/crates/test-programs/build.rs index 7ded4b99b2a3..13839665c45e 100644 --- a/crates/test-programs/build.rs +++ b/crates/test-programs/build.rs @@ -92,7 +92,7 @@ fn modules_rs(meta: &cargo_metadata::Metadata, package: &str, kind: &str, out_di format!( " {decls}\n - fn get_module(s: &str) -> wasmtime::Module {{ + pub fn get_module(s: &str) -> wasmtime::Module {{ match s {{ {cases} _ => panic!(\"no such module: {{}}\", s), @@ -162,11 +162,11 @@ fn components_rs( } std::fs::write( - out_dir.join(&format!("{}_modules.rs", package.to_snake_case())), + out_dir.join(&format!("{}_components.rs", package.to_snake_case())), format!( " {decls}\n - fn get_component(s: &str) -> wasmtime::component::Component {{ + pub fn get_component(s: &str) -> wasmtime::component::Component {{ match s {{ {cases} _ => panic!(\"no such component: {{}}\", s), diff --git a/crates/test-programs/tests/wasi-cap-std-sync.rs b/crates/test-programs/tests/wasi-cap-std-sync.rs index 589ab5aa75f6..d4f5b2704f62 100644 --- a/crates/test-programs/tests/wasi-cap-std-sync.rs +++ b/crates/test-programs/tests/wasi-cap-std-sync.rs @@ -115,6 +115,9 @@ fn run(name: &str, inherit_stdio: bool) -> Result<()> { Ok(()) } +// Below here is mechanical: there should be one test for every binary in +// wasi-tests. The only differences should be should_panic annotations for +// tests which fail. #[test_log::test] fn big_random_buf() { run("big_random_buf", true).unwrap() diff --git a/crates/test-programs/tests/wasi-tokio.rs b/crates/test-programs/tests/wasi-tokio.rs index 20c69b988128..897e5eca5808 100644 --- a/crates/test-programs/tests/wasi-tokio.rs +++ b/crates/test-programs/tests/wasi-tokio.rs @@ -117,6 +117,9 @@ async fn run(name: &str, inherit_stdio: bool) -> Result<()> { Ok(()) } +// Below here is mechanical: there should be one test for every binary in +// wasi-tests. The only differences should be should_panic annotations for +// tests which fail. #[test_log::test(tokio::test(flavor = "multi_thread"))] async fn big_random_buf() { run("big_random_buf", true).await.unwrap() @@ -239,7 +242,7 @@ async fn path_rename_file_trailing_slashes() { run("path_rename_file_trailing_slashes", false) .await .unwrap() -}(flavor = "multi_thread", worker_threads = 1) +} #[test_log::test(tokio::test(flavor = "multi_thread"))] async fn path_rename() { run("path_rename", true).await.unwrap()