-
Notifications
You must be signed in to change notification settings - Fork 7
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
cmd/wasirun: add --env-inherit flag from wazero #78
Conversation
This enables GOOS=wasip1 GOARCH=wasm go test -exec 'wasirun --env-inherit --dir /' <package> The go test command sets the working directory AND $PWD to the package source directory when running. This passes the PWD variable through at runtime, and not when go test is run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
It took a while to track down why go test -exec couldn't find source-relative test data. Turns out os.Getwd needs $PWD set to work on wasip1. |
Ah yes, the dependency on PWD is something we should probably have documented properly somewhere when Go 1.21 comes out, thanks for the feedback! |
Wonder if it makes sense to have I considered augmenting the |
That would probably be a useful addition, I would advise doing this only if the PWD environment variable does not already exists, then we set it to the current working directory. Which environment were you running in that did not set PWD? |
We had a Make target that set wasm-test:
$(WASM_ENV) gotip test -v -exec "wasirun --non-blocking-stdio --dir / --env PWD=$$PWD" $(TEST_PACKAGES) With wasm-test:
$(WASM_ENV) gotip test -v -exec "wasirun --non-blocking-stdio --dir / --env-inherit" $(TEST_PACKAGES) I think allowing wasm-test:
$(WASM_ENV) gotip test -v -exec "wasirun --non-blocking-stdio --dir / --env PWD" $(TEST_PACKAGES) |
This enables
GOOS=wasip1 GOARCH=wasm go test -exec 'wasirun --env-inherit --dir /' <package>
The
go test
command sets the working directory AND$PWD
to the package source directory when running. This passesPWD
through at the timewasirun
is executed, rather than the value ofPWD
at the timego test
is executed (typically the module root).