From 7d14d61deb45884da63a58bb738938d77f9e15a5 Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Tue, 5 Sep 2023 18:19:16 +0200 Subject: [PATCH] tests: Add regression test for file system merging error Tests merging as done in the `Console`. --- lib/wasix/src/os/console/mod.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/wasix/src/os/console/mod.rs b/lib/wasix/src/os/console/mod.rs index e8be39e2eec..e8129f50cda 100644 --- a/lib/wasix/src/os/console/mod.rs +++ b/lib/wasix/src/os/console/mod.rs @@ -364,4 +364,32 @@ mod tests { assert_eq!(out, "hello VAL1\n"); } + + /// Regression test to ensure merging of multiple packages works correctly. + #[test] + fn test_console_python_merge() { + std::env::set_var("RUST_LOG", "wasmer_wasix=trace"); + tracing_subscriber::fmt::init(); + let tokio_rt = tokio::runtime::Runtime::new().unwrap(); + let rt_handle = tokio_rt.handle().clone(); + let _guard = rt_handle.enter(); + + let tm = TokioTaskManager::new(tokio_rt); + let mut rt = PluggableRuntime::new(Arc::new(tm)); + rt.set_engine(Some(wasmer::Engine::default())) + .set_package_loader(BuiltinPackageLoader::from_env().unwrap()); + + let cmd = "wasmer-tests/python-env-dump --help"; + + let (mut handle, _proc) = Console::new(cmd, Arc::new(rt)).run().unwrap(); + + let code = rt_handle + .block_on(async move { + let res = handle.wait_finished().await?; + Ok::<_, anyhow::Error>(res) + }) + .unwrap(); + + assert_eq!(code.raw(), 0); + } }