diff --git a/aws-example/Cargo.toml b/aws-example/Cargo.toml index 1e4f0348..05a0c0e7 100644 --- a/aws-example/Cargo.toml +++ b/aws-example/Cargo.toml @@ -24,3 +24,6 @@ aws-smithy-wasm = "0.1.10" wstd = "0.6.5" [workspace] + +[patch.crates-io] +wstd = { path = ".." } diff --git a/src/time/mod.rs b/src/time/mod.rs index ed22947c..c649463c 100644 --- a/src/time/mod.rs +++ b/src/time/mod.rs @@ -171,7 +171,7 @@ mod timer { /// Future created by [`Timer::wait`]. #[must_use = "futures do nothing unless polled or .awaited"] - pub struct Wait(Pin + Send>>); + pub struct Wait(Pin + Send + Sync>>); impl Future for Wait { type Output = Instant; diff --git a/test-programs/build.rs b/test-programs/build.rs index 0f6b874a..c42748bd 100644 --- a/test-programs/build.rs +++ b/test-programs/build.rs @@ -34,22 +34,17 @@ fn main() { assert!(status.success()); } - fn build_targets(pkg: &str, manifest: &str, kind: &str, build_p3: bool, out_dir: &Path) { + fn build_targets(pkg: &str, manifest: &str, kind: &str, out_dir: &Path) { build_target(pkg, manifest, kind, "wasm32-wasip2", out_dir); - - if build_p3 { - build_target(pkg, manifest, kind, "wasm32-wasip3", out_dir); - } + build_target(pkg, manifest, kind, "wasm32-wasip3", out_dir); } - build_targets("wstd", "../Cargo.toml", "--examples", true, &out_dir); - build_targets("wstd-axum", "../Cargo.toml", "--examples", true, &out_dir); + build_targets("wstd", "../Cargo.toml", "--examples", &out_dir); + build_targets("wstd-axum", "../Cargo.toml", "--examples", &out_dir); build_targets( "wstd-aws-example", "../aws-example/Cargo.toml", "--bins", - // TODO: enable when aws example is running for WASIp3 - false, &out_dir, ); diff --git a/test-programs/tests/aws_s3.rs b/test-programs/tests/aws_s3.rs index f5f26fb5..77dd66a1 100644 --- a/test-programs/tests/aws_s3.rs +++ b/test-programs/tests/aws_s3.rs @@ -2,15 +2,17 @@ use anyhow::Result; use std::path::Path; use std::process::Command; -fn run_s3_example() -> Command { +fn run_s3_example(component: &str) -> Command { let mut command = Command::new("wasmtime"); command.arg("run"); command.arg("-Shttp"); + // Also supports WASIp2 components. + command.arg("-Sp3"); command.args(["--env", "AWS_ACCESS_KEY_ID"]); command.args(["--env", "AWS_SECRET_ACCESS_KEY"]); command.args(["--env", "AWS_SESSION_TOKEN"]); command.args(["--dir", ".::."]); - command.arg(test_programs::aws::S3); + command.arg(component); command.arg(format!( "--region={}", std::env::var("AWS_REGION").unwrap_or_else(|_| "us-west-2".to_owned()) @@ -25,8 +27,20 @@ fn run_s3_example() -> Command { #[test_log::test] #[cfg_attr(feature = "no-aws", ignore)] fn aws_s3() -> Result<()> { + run(test_programs::aws::S3, "shoug_p2.jpg") +} + +#[test_log::test] +#[cfg_attr(feature = "no-aws", ignore)] +fn aws_s3_p3() -> Result<()> { + run(test_programs::aws::S3_P3, "shoug_p3.jpg") +} + +/// `out` is where the downloaded object is written; it must be distinct per +/// test, since tests run concurrently. +fn run(component: &str, out: &str) -> Result<()> { // bucket list command - let output = run_s3_example().arg("list").output()?; + let output = run_s3_example(component).arg("list").output()?; println!("{:?}", output); assert!(output.status.success()); let stdout = String::from_utf8_lossy(&output.stdout); @@ -34,11 +48,15 @@ fn aws_s3() -> Result<()> { assert!(stdout.contains("shoug.jpg")); // bucket get command - let output = run_s3_example().arg("get").arg("shoug.jpg").output()?; + let output = run_s3_example(component) + .arg("get") + .arg("shoug.jpg") + .arg(format!("--out={out}")) + .output()?; println!("{:?}", output); assert!(output.status.success()); - assert!(Path::new("shoug.jpg").exists()); + assert!(Path::new(out).exists()); Ok(()) } diff --git a/test-programs/tests/axum_weather.rs b/test-programs/tests/axum_weather.rs index f2b3f3ca..7ec0e0f8 100644 --- a/test-programs/tests/axum_weather.rs +++ b/test-programs/tests/axum_weather.rs @@ -9,7 +9,6 @@ fn weather() -> Result<()> { run(test_programs::axum::WEATHER) } -#[ignore] #[test_log::test] fn weather_p3() -> Result<()> { run(test_programs::axum::WEATHER_P3)