Merge v3 with T15 into v3-t22

This commit is contained in:
2026-11-06 22:20:05 +00:00
171 changed files with 33754 additions and 481 deletions
+56 -11
View File
@@ -9,6 +9,39 @@ use std::{
sync::{Arc, Once},
time::Duration,
};
#[test]
fn world_copies_programs_and_nested_source_only_once() -> anyhow::Result<()> {
let temp = tempfile::tempdir()?;
let bundle = temp.path().join("bundle");
std::fs::create_dir_all(bundle.join("bin"))?;
std::fs::create_dir_all(bundle.join("src/sausage/.git"))?;
std::fs::write(bundle.join("bin/probe.wasm"), b"program")?;
std::fs::write(
bundle.join("src/sausage/.git/HEAD"),
b"ref: refs/heads/main\n",
)?;
std::fs::write(bundle.join("src/sausage/README.md"), b"source")?;
let path = temp.path().join("world");
let _world = World::open_with_userland(&path, Some(&bundle))?;
assert_eq!(
std::fs::read(path.join("world/bin/probe.wasm"))?,
b"program"
);
assert_eq!(
std::fs::read(path.join("world/src/sausage/README.md"))?,
b"source"
);
assert!(path.join("world/src/sausage/.git/HEAD").is_file());
std::fs::write(path.join("world/src/sausage/README.md"), b"agent patch")?;
let _world = World::open_with_userland(&path, Some(Path::new("/missing-bundle")))?;
assert_eq!(
std::fs::read(path.join("world/src/sausage/README.md"))?,
b"agent patch"
);
assert!(!path.join("host/compile-cache").exists());
Ok(())
}
mod features {
//! Acceptance coverage for preview1, identity, inherited IO, services, HTTP, and bundle aliases.
use super::*;
@@ -253,28 +286,32 @@ mod features {
empty(&processes).await;
}
#[tokio::test(flavor = "multi_thread")]
async fn relative_aliases_share_compilation() {
async fn independent_copies_share_compilation() {
let _serial = SERIAL.lock().await;
let (temp, runtime, _) = world();
let bin = temp.path().join("world/bin");
for name in ["true", "echo"] {
std::os::unix::fs::symlink("cat", bin.join(name)).unwrap();
for name in ["read-a.wasm", "read-b.wasm"] {
std::fs::copy(bin.join("cat.wasm"), bin.join(name)).unwrap();
}
assert_eq!(
run(&runtime, Command::Argv(vec!["/bin/true".into()]), "/")
.await
.0,
run(
&runtime,
Command::Argv(vec!["/bin/read-a".into(), "/f".into()]),
"/"
)
.await
.0,
0
);
assert_eq!(runtime.compiled_programs(), 1);
let (code, out, _) = run(
&runtime,
Command::Argv(vec!["/bin/echo".into(), "shared".into()]),
Command::Argv(vec!["/bin/read-b".into(), "/f".into()]),
"/",
)
.await;
assert_eq!(code, 0);
assert_eq!(out, b"shared\n");
assert_eq!(out, b"root\n");
assert_eq!(runtime.compiled_programs(), 1);
}
#[tokio::test(flavor = "multi_thread")]
@@ -402,13 +439,17 @@ fn world() -> (tempfile::TempDir, Arc<Runtime>, sausage::process::Processes) {
let world = World::open(temp.path()).unwrap();
let cache = Path::new(env!("CARGO_TARGET_TMPDIR")).join("process-host/compile-cache");
std::fs::create_dir_all(&cache).unwrap();
std::os::unix::fs::symlink(cache, world.host_dir.join("compile-cache")).unwrap();
let processes = world.processes.clone();
fixture(&temp.path().join("world"));
let artifacts = repo().join("userland/target/wasm32-wasip2/release");
let bin = temp.path().join("world/bin");
for tool in ["cat", "tr", "ls", "wc", "yes", "head", "sleep"] {
std::fs::copy(artifacts.join("sausage-coreutils.wasm"), bin.join(tool)).unwrap();
std::fs::copy(
artifacts.join(format!("{tool}.wasm")),
bin.join(format!("{tool}.wasm")),
)
.unwrap();
}
for tool in ["ps", "kill"] {
std::fs::copy(artifacts.join("sausage-procps.wasm"), bin.join(tool)).unwrap();
@@ -429,7 +470,11 @@ fn world() -> (tempfile::TempDir, Arc<Runtime>, sausage::process::Processes) {
bin.join("git"),
)
.unwrap();
(temp, Runtime::new(world).unwrap(), processes)
(
temp,
Runtime::new_with_cache(world, &cache).unwrap(),
processes,
)
}
async fn run(runtime: &Arc<Runtime>, command: Command, cwd: &str) -> (i32, Vec<u8>, Vec<u8>) {
let (mut stdout, mut stderr) = (Vec::new(), Vec::new());