test-reporter
test-reporter copied to clipboard
gocov + Jenkins setup: no such file or directory
Just want to share my experience of setting up code climate test reporter with golang on Jenkins.
Following this example:
- Downloaded
cc-test-reporterinto the project root (i.e. GOPATH/src/github/org/project) - Executed
go test -coverprofileand generatedc.outon project root - Executed
./cc-test-reporter after-buildwithout--prefixflag, since I'm assuming--prefixis for some custom use case. - Encountered
no such file or directoryerror on a source file, where source file will look likegithub/org/project/file.goas per standardgo test -coverprofile. Noticed that the error is encountered whenafter-buildis trying to upload coverage here
As a workaround, I had to add --prefix github/org/project on after-build because:
cc-test-reporteris on the project root, and when it tries to open the source files, the path has to be relative to where cc-test-reporter is.- I tried placing
cc-test-reporterin theGOPATH/srcdirectory so that I don't need to add--prefix, but encountered some issues here becauseGOPATH/srcis not a git repository.
Noticed that it's stated here the need to add --prefix.
But just feel that the steps I followed is not out of the norm (idiomatic) for Golang and maybe the trimming of prefix has to be handled in gocov formatter or if not, maybe documented this behaviour in go examples?
Thanks @severedsea! I had the same problem until you pointed out the --prefix.
A question, do you have a loop to test all your packages and append the coverage result to a file? And then did you need to remove all the rows with "mode: set" lines?
Using Go 1.10, you can output coverage result even if you’re testing multiple packages like so:
go test -coverprofile=c.out ./...
Didn't need to manually sanitise c.out