Skip to content

Commit

Permalink
move test functionality to the main crate behind a feature flag
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Prendes <[email protected]>
  • Loading branch information
jprendes committed Oct 3, 2023
1 parent d9f9079 commit 118a3ff
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 35 deletions.
8 changes: 3 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
members = [
"crates/containerd-shim-wasm",
"crates/containerd-shim-wasm-test",
"crates/containerd-shim-wasm-test-modules",
"crates/wasi-demo-app",
"crates/oci-tar-builder",
"crates/containerd-shim-wasmedge",
Expand All @@ -24,7 +24,7 @@ cap-std = "1.0"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
containerd-shim = "0.5.0"
containerd-shim-wasm = { path = "crates/containerd-shim-wasm" }
containerd-shim-wasm-test = { path = "crates/containerd-shim-wasm-test" }
containerd-shim-wasm-test-modules = { path = "crates/containerd-shim-wasm-test-modules" }
crossbeam = { version = "0.8.2", default-features = false }
env_logger = "0.10"
libc = "0.2.147"
Expand All @@ -36,6 +36,7 @@ serde = "1.0"
serde_json = "1.0"
sha256 = "1.4.0"
tar = "0.4"
tempfile = "3.8"
thiserror = "1.0"
ttrpc = "0.8.0"
wat = "*" # Use whatever version wasmtime will make us pull
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ check: check-wasm $(RUNTIMES:%=check-%);

check-common: check-wasm;
check-wasm:
$(CARGO) +nightly fmt $(TARGET_FLAG) -p oci-tar-builder -p wasi-demo-app -p containerd-shim-wasm -p containerd-shim-wasm-test -- --check
$(CARGO) clippy $(TARGET_FLAG) $(FEATURES_wasm) -p oci-tar-builder -p wasi-demo-app -p containerd-shim-wasm -p containerd-shim-wasm-test -- $(WARNINGS)
$(CARGO) +nightly fmt $(TARGET_FLAG) -p oci-tar-builder -p wasi-demo-app -p containerd-shim-wasm -p containerd-shim-wasm-test-modules -- --check
$(CARGO) clippy $(TARGET_FLAG) $(FEATURES_wasm) -p oci-tar-builder -p wasi-demo-app -p containerd-shim-wasm -p containerd-shim-wasm-test-modules -- $(WARNINGS)

check-%:
$(CARGO) +nightly fmt $(TARGET_FLAG) -p containerd-shim-$* -- --check
Expand All @@ -59,8 +59,8 @@ fix: fix-wasm $(RUNTIMES:%=fix-%);

fix-common: fix-wasm;
fix-wasm:
$(CARGO) +nightly fmt $(TARGET_FLAG) -p oci-tar-builder -p wasi-demo-app -p containerd-shim-wasm -p containerd-shim-wasm-test
$(CARGO) clippy $(TARGET_FLAG) $(FEATURES_wasm) --fix -p oci-tar-builder -p wasi-demo-app -p containerd-shim-wasm -p containerd-shim-wasm-test -- $(WARNINGS)
$(CARGO) +nightly fmt $(TARGET_FLAG) -p oci-tar-builder -p wasi-demo-app -p containerd-shim-wasm -p containerd-shim-wasm-test-modules
$(CARGO) clippy $(TARGET_FLAG) $(FEATURES_wasm) --fix -p oci-tar-builder -p wasi-demo-app -p containerd-shim-wasm -p containerd-shim-wasm-test-modules -- $(WARNINGS)

fix-%:
$(CARGO) +nightly fmt $(TARGET_FLAG) -p containerd-shim-$*
Expand All @@ -72,7 +72,7 @@ test: test-wasm $(RUNTIMES:%=test-%);
test-common: test-wasm;
test-wasm:
# oci-tar-builder and wasi-demo-app have no tests
RUST_LOG=trace $(CARGO) test $(TARGET_FLAG) --package containerd-shim-wasm $(FEATURES_wasm) --verbose -- --nocapture
RUST_LOG=trace $(CARGO) test $(TARGET_FLAG) --package containerd-shim-wasm $(FEATURES_wasm) --verbose -- --nocapture --test-threads=1

test-wasmedge:
# run tests in one thread to prevent paralellism
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[package]
name = "containerd-shim-wasm-test"
description = "Library for testing containerd shims for wasm"
name = "containerd-shim-wasm-test-modules"
description = "Set of WebAssembly modules for testing containerd shims for wasm"
version.workspace = true
edition.workspace = true
license.workspace = true

[dependencies]
anyhow = { workspace = true }
containerd-shim-wasm = { workspace = true }
env_logger = "0.10"
libc = { workspace = true }
log = { workspace = true }
Expand Down
File renamed without changes.
10 changes: 8 additions & 2 deletions crates/containerd-shim-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ doctest = false
[dependencies]
anyhow = { workspace = true }
chrono = { workspace = true }
git-version = "0.3.5"
containerd-shim = { workspace = true }
containerd-shim-wasm-test-modules = { workspace = true, optional = true }
crossbeam = { workspace = true }
env_logger = { workspace = true, optional = true }
git-version = "0.3.5"
libc = { workspace = true }
log = { workspace = true }
oci-spec = { workspace = true }
protobuf = "3.2"
serde = { workspace = true }
serde_json = { workspace = true }
tempfile = { workspace = true, optional = true }
thiserror = { workspace = true }
ttrpc = { workspace = true }
wat = { workspace = true }
Expand All @@ -40,8 +43,11 @@ windows-sys = { workspace = true, features = ["Win32_Foundation", "Win32_Storage
ttrpc-codegen = { version = "0.4.2", optional = true }

[dev-dependencies]
tempfile = "3.8"
containerd-shim-wasm-test-modules = { workspace = true }
env_logger = { workspace = true }
tempfile = { workspace = true }

[features]
testing = ["dep:containerd-shim-wasm-test-modules", "dep:env_logger", "dep:tempfile"]
generate_bindings = ["ttrpc-codegen"]
generate_doc = []
3 changes: 3 additions & 0 deletions crates/containerd-shim-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ pub mod services;
#[cfg_attr(unix, path = "sys/unix/mod.rs")]
#[cfg_attr(windows, path = "sys/windows/mod.rs")]
pub(crate) mod sys;

#[cfg(any(test, feature = "testing"))]
pub mod testing;
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ use std::sync::mpsc::channel;
use std::time::Duration;

use anyhow::{bail, Result};
#[cfg(unix)]
use libc::SIGKILL;

#[cfg(windows)]
const SIGKILL: i32 = 9;

use containerd_shim_wasm::sandbox::instance::Wait;
use containerd_shim_wasm::sandbox::{Instance, InstanceConfig};
pub use containerd_shim_wasm_test_modules as modules;
use oci_spec::runtime::{ProcessBuilder, RootBuilder, SpecBuilder};

pub mod modules;
use crate::sandbox::instance::Wait;
use crate::sandbox::{Instance, InstanceConfig};
use crate::sys::signals::SIGKILL;

pub struct WasiTestBuilder<WasiInstance: Instance>
where
Expand Down
2 changes: 1 addition & 1 deletion crates/containerd-shim-wasmedge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ wasmedge-sdk = { version = "0.12.2" }
wasmedge-sys = "*"

[dev-dependencies]
containerd-shim-wasm-test = { workspace = true }
containerd-shim-wasm = { workspace = true, features = ["testing"] }
libc = { workspace = true }
serial_test = "*"

Expand Down
4 changes: 2 additions & 2 deletions crates/containerd-shim-wasmedge/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::time::Duration;

//use containerd_shim_wasm::sandbox::Instance;
use containerd_shim_wasm_test::modules::*;
use containerd_shim_wasm_test::WasiTest;
use containerd_shim_wasm::testing::modules::*;
use containerd_shim_wasm::testing::WasiTest;
use serial_test::serial;

use crate::instance::WasmEdgeInstance as WasiInstance;
Expand Down
2 changes: 1 addition & 1 deletion crates/containerd-shim-wasmer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ wasmer-compiler = { version = "4.1.2", features = ["compiler"] }
wasmer-wasix = { version = "0.12.0" }

[dev-dependencies]
containerd-shim-wasm-test = { workspace = true }
containerd-shim-wasm = { workspace = true, features = ["testing"] }
serial_test = "*"

[[bin]]
Expand Down
4 changes: 2 additions & 2 deletions crates/containerd-shim-wasmer/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::time::Duration;

//use containerd_shim_wasm::sandbox::Instance;
use containerd_shim_wasm_test::modules::*;
use containerd_shim_wasm_test::WasiTest;
use containerd_shim_wasm::testing::modules::*;
use containerd_shim_wasm::testing::WasiTest;
use serial_test::serial;

use crate::instance::WasmerInstance as WasiInstance;
Expand Down
2 changes: 1 addition & 1 deletion crates/containerd-shim-wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ wasmtime-wasi = { version = "11.0", features = ["exit"] }
wasi-common = "11.0"

[dev-dependencies]
containerd-shim-wasm-test = { workspace = true }
containerd-shim-wasm = { workspace = true, features = ["testing"] }
serial_test = "*"

[[bin]]
Expand Down
4 changes: 2 additions & 2 deletions crates/containerd-shim-wasmtime/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::time::Duration;

//use containerd_shim_wasm::sandbox::Instance;
use containerd_shim_wasm_test::modules::*;
use containerd_shim_wasm_test::WasiTest;
use containerd_shim_wasm::testing::modules::*;
use containerd_shim_wasm::testing::WasiTest;
use serial_test::serial;

use crate::instance::WasmtimeInstance as WasiInstance;
Expand Down

0 comments on commit 118a3ff

Please sign in to comment.