-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/test2json: 'exec format error' for os/exec when exec is set to go_js_wasm_exec #32442
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
Comments
Hello @artspb, thank you for reporting this issue and welcome to the Go project! So I believe that +build !js,!wasm,!nacl since Kindly paging @neelance too. |
I don't expect |
I've never used
@artspb Can you check if using |
There are some basic misunderstandings here. You cannot use a test2json ELF binary to execute a wasm test. Both needs to be compiled to wasm.
Yes, this is only for Here is what you should be doing -
Note that
Output from some sample tests -
I think documenting this in the wiki is the best way here. Adding build tags may be fine, but it already gives a nice error when we try to run |
@agnivade Would you be up for that? You seem to have the clearest understanding of the problem + solution. 😄 |
Thank you, everyone, for your responses.
@dmitshur Unfortunately, this approach doesn't work for us as we want to debug with delve and produce JSON output at the same time. From what I know, there's no other solution but
@agnivade It doesn't sound like a scalable approach. But I found out that inverting order of arguments somehow solves the problem. When I run the following command everything works as expected.
Am I missing something or is it the most convenient way to run a test binary so far except |
You are debugging a wasm binary using delve ? Is that even possible ? #23033 was closed because there wasn't sufficient clarity on what the OP wanted.
Ah yea, it's a roundabout way. What you are doing is essentially running the test with go_js_wasm_exec and converting the output to json. This is equivalent to -
If this is what you want, then go ahead. Although, I don't understand why |
Not yet (see go-delve/delve#1325) but it'd be great to be ready.
Not really. What I want is to run tests in a platform-agnostic way. Ideally, I should only provide
The whole situation is very well described here. Long story short, it's impossible to run |
You are misunderstanding how Example -
So then coming to your example, if you are doing This is by design. If you have suggestions, you are welcome to open a new issue. To conclude, this is not a wasm specific issue. Even a binary compiled in darwin won't work with a go toolchain in linux/amd64. The easy way is to use Again, there is no bug here. Everything is working as expected. |
Thank you for the information.
Still, one has to provide |
Yes you have to. GOOS and GOARCH are just the target values. But how does the compiler know the file path to your exec binary ? It can be anywhere. Again, this is not a wasm issue. You have to set the exec param whenever you are doing cross-platform tests. Either set the PATH to |
Fair enough. Thank you again for your patience explaining how it works. |
Possibly interestingly, that's an area I've been investigating recently from a "how to get this working" point of view. 😉 Delve has a number of backends that can be run, with the specific one for a given situation depending on the OS and what the debugging user requests: https://github.com/go-delve/delve/blob/master/service/debugger/debugger.go#L156-L171 To add support for Wasm, a backend for Wasm would need adding. I've been investigating modifying the Life VM so it could fit that task, though the wagon VM looks like it may be a better choice (being investigated). eg User runs Delve in a session (via GoLand/IntelliJ or whatever), Delve spins up the Life or wagon wasm VM in the background with the given Wasm loaded. While not completely simple, it appears do-able for wasi style Wasm. eg stuff that doesn't interact with a browser. No idea yet how browser dev tools work, Wasm that interacts with a browser... is an unknown (for now). Might be possible to get the modified Life or Wagon VM to communicate with a browser debug session, but that's just pure concept guessing without any research at all behind it. eg might not actually work. No idea (yet), and am instead looking into other aspects of things first. 😉 |
That's great @justinclift. I will close the issue as this was a misunderstanding of how I am not sure what else should I add in the wiki to explain further than this. There are a lot of things that don't work in wasm, should we then mention all of those ? Not sure. If anyone has a better idea, please feel free to update the wiki. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
GOPATH
which contains the following files.main.go
main_test.go
js/wasm
and providing exec (see this instruction).GOOS=js GOARCH=wasm /usr/local/Cellar/go/1.12.5/libexec/bin/go test -c -exec=/usr/local/Cellar/go/1.12.5/libexec/misc/wasm/go_js_wasm_exec -o /Users/artspb/go/src/github.com/artspb/wasm-test-example/main.wasm
test2json
.GOOS=js GOARCH=wasm /usr/local/Cellar/go/1.12.5/libexec/bin/go tool test2json -t /Users/artspb/go/src/github.com/artspb/wasm-test-example/main.wasm -test.v -test.run '^Test_main$'
What did you expect to see?
What did you see instead?
Adding
$(go env GOROOT)/misc/wasm
to$PATH
doesn't help.The text was updated successfully, but these errors were encountered: