Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/test2json: 'exec format error' for os/exec when exec is set to go_js_wasm_exec #32442
What version of Go are you using (
changed the title
test2json fails with 'exec format error' when exec is set to go_js_wasm_exec
Jun 6, 2019
Hello @artspb, thank you for reporting this issue and welcome to the Go project!
So I believe that
Kindly paging @neelance too.
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 -
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
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
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.
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
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.