rillig / gobco

Measure branch coverage of golang tests
62 stars 12 forks source link

panic: no such file or directory #20

Closed nixmaldonado closed 3 years ago

nixmaldonado commented 3 years ago

Hello @rillig I'm trying to use gobco but I'm unable due to the following error

when running gobco in my terminal I get:

panic: open gopath/src/: no such file or directory

I'm able to run gobco successfully in the sample folder of the gobco project

Am I missing some step to use it in my project?

The $gopath variable is correctly set in my mac computer

I'm using go 1.15.2

Thanks in advance

rillig commented 3 years ago

Please run gobco -verbose -keep, which will show you which directories are copied to the temporary build directory. This may already give you a clue.

It would be best if you could set up a minimal example project that demonstrates this error. I suspect it is a bug in gobco but I'd like to know the exact circumstances in which this happens. I completely rewrote that part of the code a few days ago, and it worked for my test cases, I may have missed an edge case though.

nixmaldonado commented 3 years ago

Thanks for your timely response

running gobco -verbose -keep returns the same "no such file or directory"

followed by:

goroutine 1 [running]: main.(instrumenter).check(...) /Users/smld/go/src/github.com/rillig/gobco/instrumenter.go:385 main.(instrumenter).instrument(0xc000126000, 0xc00014e0c0, 0x3d, 0x0, 0x0, 0xc000150090, 0x85) /Users/smld/go/src/github.com/rillig/gobco/instrumenter.go:240 +0x1c5 main.(*gobco).instrument(0xc000146000) /Users/smld/go/src/github.com/rillig/gobco/main.go:263 +0x20b main.gobcoMain(0x11d8ea0, 0xc000122008, 0x11d8ea0, 0xc000122010, 0xc000104180, 0x3, 0x3, 0xc000100058) /Users/smld/go/src/github.com/rillig/gobco/main.go:27 +0x9a main.main() /Users/smld/go/src/github.com/rillig/gobco/main.go:20 +0x6e

I'm running the gobco command in the root of the project

But I've also tried adding the path to a file after the gobco

In both cases I get the same error

rillig commented 3 years ago

There's a bug in gobco in the part that copies the code to the temporary build directory, where the code is then instrumented.

The log output from gobco -verbose -keep should include a line like this one:

Instrumented sample to ...\gobco-ab5ab42c02e3d76a\module-535f928fc2a8525d\sample

If that line is not shown, please update gobco to the latest version.

If you look at that temporary directory, it should contain all the files from your original code. But somehow it doesn't, otherwise gobco wouldn't have panicked.

rillig commented 3 years ago

I reproduced the bug and am fixing it right now.

nixmaldonado commented 3 years ago

Excellent, thank you for your time.

rillig commented 3 years ago

Please update and try again. It works for me now to run gobco in a non-module.