-
Notifications
You must be signed in to change notification settings - Fork 29
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
cargo wasi test should preopen the current dir by default #128
Comments
A workaround is to run with:
|
This PR defaults `cargo wasi test` to always be run with the current working directory preopened. The goal is to allow existing tests to run without modification. Fixes bytecodealliance#128
This PR defaults `cargo wasi test` to always be run with the current working directory preopened. The goal is to allow existing tests to run without modification. Fixes bytecodealliance#128
I just hit this, and unless there's a better way to build filenames for test fixtures that I (a very new Rust learner) am unaware of, the solution probably needs to also ensure the My currently-working env-var is (PowerShell)
which makes the following work with just let manfest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let fixture = path!(
Path::new(&manfest_dir) / "tests" / "fixtures" / "2024-05-30" / "BlueprintList_info.json"
);
let data = fs::read_to_string(fixture).unwrap(); Without the Edit: Playing around a bit,
seems to work better, as it doesn't get confused by leading backslashes in CLI parameters using
This works in both cases, but tab-completion in PowerShell or CMD will convert it to the above.
Might be a good time to clarify that I'm using Windows for this, in case that affects more than just the directory-seperator. |
Related to #17, tests that rely on any kind of test file, like expected results or test data, are unable to run with
cargo wasi test
.When running tests, we should have a sensible default like
--dir=.
. We could use the same mechanism proposed in #19, but I would still want to provide a default preopen. This will make converting existing projects to Wasm and WASI as seamless as possible.The text was updated successfully, but these errors were encountered: