mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-11-22 08:13:59 +00:00
Merge pull request #6: stop reporting readiness without an engine
A runtime built without wasmtime-runtime now exits with an error instead of printing READY; its env-dependent tests are serialised.
This commit is contained in:
commit
818a831895
2 changed files with 30 additions and 3 deletions
|
|
@ -87,8 +87,9 @@ fn run_module(
|
|||
_preopen: &[(String, String)],
|
||||
_ipc_socket: Option<&str>,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("READY");
|
||||
Ok(())
|
||||
anyhow::bail!(
|
||||
"weft-runtime was built without the wasmtime-runtime feature and cannot execute components"
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(feature = "wasmtime-runtime")]
|
||||
|
|
@ -506,9 +507,32 @@ fn package_store_roots() -> Vec<PathBuf> {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Serialises the tests that read or change WEFT_APP_STORE; the test
|
||||
/// harness runs tests on parallel threads that share the environment.
|
||||
static ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
|
||||
|
||||
fn env_lock() -> std::sync::MutexGuard<'static, ()> {
|
||||
ENV_LOCK.lock().unwrap_or_else(|p| p.into_inner())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "wasmtime-runtime"))]
|
||||
#[test]
|
||||
fn engine_disabled_build_refuses_to_run_components() {
|
||||
let err = run_module(std::path::Path::new("app.wasm"), &[], None)
|
||||
.expect_err("a build without wasmtime-runtime must not report success");
|
||||
assert!(err.to_string().contains("wasmtime-runtime"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn package_store_roots_includes_system_path() {
|
||||
let _env = env_lock();
|
||||
let prior = std::env::var_os("WEFT_APP_STORE");
|
||||
// SAFETY: env_lock serialises every test that touches the environment.
|
||||
unsafe { std::env::remove_var("WEFT_APP_STORE") };
|
||||
let roots = package_store_roots();
|
||||
if let Some(v) = prior {
|
||||
unsafe { std::env::set_var("WEFT_APP_STORE", v) };
|
||||
}
|
||||
assert!(
|
||||
roots
|
||||
.iter()
|
||||
|
|
@ -518,6 +542,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn package_store_roots_uses_weft_app_store_when_set() {
|
||||
let _env = env_lock();
|
||||
// SAFETY: test binary is single-threaded at this point.
|
||||
unsafe { std::env::set_var("WEFT_APP_STORE", "/custom/store") };
|
||||
let roots = package_store_roots();
|
||||
|
|
@ -527,6 +552,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn resolve_package_finds_installed_package() {
|
||||
let _env = env_lock();
|
||||
use std::fs;
|
||||
let store =
|
||||
std::env::temp_dir().join(format!("weft_runtime_resolve_{}", std::process::id()));
|
||||
|
|
@ -557,6 +583,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn resolve_package_errors_on_unknown_id() {
|
||||
let _env = env_lock();
|
||||
let store =
|
||||
std::env::temp_dir().join(format!("weft_runtime_resolve_empty_{}", std::process::id()));
|
||||
let _ = std::fs::create_dir_all(&store);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ cargo build --release
|
|||
cargo build -p weft-runtime --features wasmtime-runtime,net-fetch
|
||||
```
|
||||
|
||||
Without `--features wasmtime-runtime`, the runtime prints READY and exits (stub mode, used in CI on platforms without Linux system dependencies).
|
||||
Without `--features wasmtime-runtime`, the runtime compiles for type, lint and unit checks (the portable CI configuration) but exits with an error when asked to run a component; it never reports readiness.
|
||||
|
||||
## Signing packages
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue