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

error generating coverage report #46

Closed
mlctrez opened this issue Aug 25, 2023 · 7 comments
Closed

error generating coverage report #46

mlctrez opened this issue Aug 25, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@mlctrez
Copy link
Contributor

mlctrez commented Aug 25, 2023

First off 😎 thanks for your work on this!

When a recent version of go I'm getting an error when generating code coverage:

error generating coverage report: output directory "/tmp/go-build888418937/b001/gocoverdir" inaccessible (err: stat /tmp/go-build888418937/b001/gocoverdir: not implemented on js); no coverage data written

go test . works with later versions of go but breaks when adding -cover

This repository contains my test case wbtexample

When running with go1.18.4 there are no errors.
shell script

When running with go1.20.7 I get the error generating coverage.
shell script

I've added logging statements in github.com/agnivade/wasmbrowsertest and have tracked it down to a non-zero exit code at main.go

I'm using google chrome 116.0.5845.96 on Ubuntu 22.04.3 LTS if that matters.

@agnivade
Copy link
Owner

Thanks, yes there seems to be some issues with Go 1.20 onwards. Even CI fails with 1.20. I need to spend some time to take a look.

We also need to bump the version in go.mod file.

cc @JohnStarich in case you want to take a look.

@agnivade agnivade added the bug Something isn't working label Aug 26, 2023
@mlctrez
Copy link
Contributor Author

mlctrez commented Aug 26, 2023

This appears to be caused by design/51430-revamp-code-coverage

Here's the location the stat call occurs:
https://github.com/golang/go/blob/39957b5d89fec8bc3a79f4a982452c6e3d5b3ad3/src/runtime/coverage/emit.go#L398-L405

Passing an env GOEXPERIMENT=none works with go 1.20 and later as a temp workaround.

@agnivade
Copy link
Owner

Nice catch! Looks like we need to do a bit of work to support fs.stat.

@mlctrez
Copy link
Contributor Author

mlctrez commented Aug 29, 2023

Looked into what it would take to support this. As it turns out, it is much larger than just fs.stat.

The new coverage code is accessing /tmp/go-build<nnn..>/b<nnn>/gocoverdir which appears to be created by the go tooling before calling into wasmbrowsertest. The new coverage code then tries to write, rename, list, and read files in this directory. So the fs.xxxx calls so far are stat, rename, fstat, readdir, lstat, and read.

I was thinking of other options, like the native filesystem api, but came across your comment forwarding all file-system calls to the webserver so I'm now thinking that as well.

If you have not already started on the forwarding fs calls route, I can take a look at it.

@agnivade
Copy link
Owner

Thanks for digging deep. Yes, the fs API forwarding to the webserver would be a much more robust solution. This would also finally unblock any filesystem read/write related tests, which would fix golang/go#26051!

@mlctrez
Copy link
Contributor Author

mlctrez commented Aug 29, 2023

Dug a bit deeper, ended up digging a tunnel, then found the light at the end of it. 😃

I have not tested this extensively but it appears to be fairly solid. I'll add more to it in the next few days but wanted to share it for whoever is interested. It definitely needs more testing on non-unix platforms.

@JohnStarich
Copy link
Contributor

This is awesome, thanks @mlctrez!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants