Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement initial-cwd for wasi:cli/environment #9831

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stephenmuss
Copy link

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 stephenmuss requested a review from a team as a code owner December 16, 2024 10:56
@stephenmuss stephenmuss requested review from fitzgen and removed request for a team December 16, 2024 10:56
@github-actions github-actions bot added the wasi Issues pertaining to WASI label Dec 16, 2024
@alexcrichton
Copy link
Member

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
Copy link
Author

I assume I should be able to use something like this in crates/test-programs/bin/*.rs to test

fn 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 in src/commands/run.rs and src/commands/serve.rs etc.

@alexcrichton
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi Issues pertaining to WASI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement initial-cwd for wasi:cli/environment
2 participants