rillig / gobco

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

gobco doesn't work well with nested packages #12

Open anmolbabu opened 4 years ago

anmolbabu commented 4 years ago

when individual package paths are passed, gobco works like a charm However, when gobco is run at a higher levels, composed of multiple nested packages, it errors out saying no Go files....

ababu17$ gobco pkg/
can't load package: package ........./pkg: no Go files in /var/folders/dc/ffvyv57j5dzf20lp3tlqfpqw0000gn/T/gobco-f9cfa878-befb-4140-861e-56900a45e25b/src/.........../pkg
exit status 1
open /var/folders/dc/ffvyv57j5dzf20lp3tlqfpqw0000gn/T/gobco-f9cfa878-befb-4140-861e-56900a45e25b/gobco-counts.json: no such file or directory

ababu17$ ls
Makefile    README.md   coverage.out    go.mod      go.sum      pkg     vendor

ababu17$ ls pkg/
cover.sh    env     logging     messaging   models      test.sh     utils

ababu17$ ls pkg/models/
constants.go    defs.go     defs_test.go    interface.go    job.go      job_test.go mocks

ababu17$ ls pkg/utils/
file.go         file_test.go        object.go       object_test.go      schedule.go     schedule_test.go    str.go          str_test.go
rillig commented 4 years ago

My idea to implement this is to do the same that the Go compiler does when it interprets the ./... special argument. I already had a look at the code that implements this in the Go standard library, but unfortunately that code cannot be reused easily since it is in cmd/go/internal/modload/load.go, function ImportPathsQuiet, keyword "...".

Do you have an idea how this could be implemented without copying and duplicating all that code?

anmolbabu commented 4 years ago

Will take a look at this sometime this weekend

KantarBruceAdams commented 2 years ago

I think I may have the same issue.