stephenmuss opened PR #9831 from stephenmuss:initial-cwd
to bytecodealliance:main
:
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
This implements initial-cwd for wasi:cli/environment.My biggest struggle was finding the appropriate places to add tests. Any guidance would be appreciated. Thank you.
Closes #9695
stephenmuss requested fitzgen for a review on PR #9831.
stephenmuss requested wasmtime-core-reviewers for a review on PR #9831.
alexcrichton commented on PR #9831:
Thanks! I'd recommend adding a test to
crates/test-programs/bin/*.rs
and there's a small README about the tests in that directory.
stephenmuss commented on PR #9831:
I assume I should be able to use something like this in
crates/test-programs/bin/*.rs
to testfn main() -> std::io::Result<()> { let cwd = std::env::current_dir()?; assert_eq!(cwd.to_str(), Some("/tmp")); Ok(()) }
and run with
-S cwd=/tmp
.Is that understanding correct?
However, I always get
Some("/")
indicating that I still need to set the path somewhere I've missed, presumably insrc/commands/run.rs
andsrc/commands/serve.rs
etc.
alexcrichton commented on PR #9831:
Ah you'll probably need to use the WASI API directly rather than the standard library because the standard library isn't hooked up to this API yet.
Last updated: Dec 23 2024 at 13:07 UTC