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
cmd/cover: inconsistent NumStmt with prometheus #45361
Comments
It still does not work on my laptop.
Any update on this issue? |
I encountered the same problem with the latest Go 1.20. Unfortunately, it's in a proprietary software, but also applies to a generated file -- in our case by Ragel. I'll try to find reproducer for this. |
friendly ping @golang/runtime ? |
This is also still broken for our repo and hampers development |
@neild the line directive strikes again it seems (messing up line numbers between the generated file and the generating file) |
Is there a workaround? My project does have generated code from goyacc FWIW. |
Use ./... instead of loop over packages. Originally loop over packages was added by #359 that introduced glide package manager. This manager fetches dependencies into vendor/ subdirectory (see https://glide.readthedocs.io/en/latest/getting-started/) and apparently loop over packages was nessesary back then. glide usage was removed by #764 The change now also runs testable examples. Also: * fixes cmd/eskip etcd shutdown similar to #2359 * fixes cmd/eskip test intruduced by #2202 * fixes lua example * removed bench target as it makes little sense * .coverprofile-all can not be simplified yet due to golang/go#45361 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Use ./... instead of loop over packages. Originally loop over packages was added by #359 that introduced glide package manager. This manager fetches dependencies into vendor/ subdirectory (see https://glide.readthedocs.io/en/latest/getting-started/) and apparently loop over packages was nessesary back then. glide usage was removed by #764 The change now also runs testable examples. Also: * fixes cmd/eskip etcd shutdown similar to #2359 * fixes cmd/eskip test intruduced by #2202 * fixes lua example * removed bench target as it makes little sense * .coverprofile-all can not be simplified yet due to golang/go#45361 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Use ./... instead of loop over packages. Originally loop over packages was added by #359 that introduced glide package manager. This manager fetches dependencies into vendor/ subdirectory (see https://glide.readthedocs.io/en/latest/getting-started/) and apparently loop over packages was necessary back then. glide usage was removed by #764 The change now also runs testable examples. Also: * fixes cmd/eskip etcd shutdown similar to #2359 * fixes cmd/eskip test intruduced by #2202 * fixes lua example * removed bench target as it makes little sense * .coverprofile-all can not be simplified yet due to golang/go#45361 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Use ./... instead of loop over packages. Originally loop over packages was added by #359 that introduced glide package manager. This manager fetches dependencies into vendor/ subdirectory (see https://glide.readthedocs.io/en/latest/getting-started/) and apparently loop over packages was necessary back then. glide usage was removed by #764 The change now also runs testable examples. Also: * fixes cmd/eskip etcd shutdown similar to #2359 * fixes cmd/eskip test introduced by #2202 * fixes lua example * removed bench target as it makes little sense * .coverprofile-all can not be simplified yet due to golang/go#45361 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Use ./... instead of loop over packages. Originally loop over packages was added by #359 that introduced glide package manager. This manager fetches dependencies into vendor/ subdirectory (see https://glide.readthedocs.io/en/latest/getting-started/) and apparently loop over packages was necessary back then. glide usage was removed by #764 The change now also runs testable examples. Also: * fixes cmd/eskip etcd shutdown similar to #2359 * fixes cmd/eskip test introduced by #2202 * fixes lua example * removed bench target as it makes little sense * .coverprofile-all can not be simplified yet due to golang/go#45361 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Use ./... instead of loop over packages. Originally loop over packages was added by #359 that introduced glide package manager. This manager fetches dependencies into vendor/ subdirectory (see https://glide.readthedocs.io/en/latest/getting-started/) and apparently loop over packages was necessary back then. glide usage was removed by #764 The change now also runs testable examples. Also: * increases redis testcontainer ping and shutdown timeouts after observed CI failures * fixes cmd/eskip etcd shutdown similar to #2359 * fixes cmd/eskip test introduced by #2202 * fixes lua example * removed bench target as it makes little sense * .coverprofile-all can not be simplified yet due to golang/go#45361 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
go tool cover fails for eskip package: ``` $ go test ./eskip/ -coverprofile=.coverprofile && go tool cover -func .coverprofile ok github.com/zalando/skipper/eskip 0.026s coverage: 88.2% of statements cover: inconsistent NumStmt: changed from 1 to 2 ``` this apparently happens due to malformed .coverprofile containing non-go files ```sh $ cut -d: -f1 .coverprofile | grep -v -F '.go' | sort -u github.com/zalando/skipper/eskip/parser.y github.com/zalando/skipper/eskip/yaccpar mode ``` added by line directives in generated parser.go. It looks similar to the issue golang/go#45361 To fix the problem updated go:generate directive omit line directives (-l) and parsing tables (-v "") and re-generated parser: ```sh $ rm $(which goyacc) $ go install golang.org/x/tools/cmd/goyacc $ go generate ./eskip ``` Benchmark results did not change after re-generate: ``` name old time/op new time/op delta ParsePredicates-8 4.58µs ± 7% 4.42µs ± 0% ~ (p=0.064 n=10+8) LBBackendString-8 2.40µs ±12% 2.53µs ±11% ~ (p=0.060 n=10+10) name old alloc/op new alloc/op delta ParsePredicates-8 744B ± 0% 744B ± 0% ~ (all equal) LBBackendString-8 4.65kB ± 0% 4.65kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta ParsePredicates-8 35.0 ± 0% 35.0 ± 0% ~ (all equal) LBBackendString-8 12.0 ± 0% 12.0 ± 0% ~ (all equal) ``` Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
go tool cover fails for eskip package: ``` $ go test ./eskip/ -coverprofile=.coverprofile && go tool cover -func .coverprofile ok github.com/zalando/skipper/eskip 0.026s coverage: 88.2% of statements cover: inconsistent NumStmt: changed from 1 to 2 ``` this apparently happens due to malformed .coverprofile containing non-go files ```sh $ cut -d: -f1 .coverprofile | grep -v -F '.go' | sort -u github.com/zalando/skipper/eskip/parser.y github.com/zalando/skipper/eskip/yaccpar mode ``` added by line directives in generated parser.go. The problem looks similar to the issue golang/go#45361. To fix the problem updated go:generate directive to omit line directives (-l) and parsing tables (-v "") and re-generated the parser: ```sh $ rm $(which goyacc) $ go install golang.org/x/tools/cmd/goyacc $ go generate ./eskip ``` Benchmark results did not change after re-generate: ``` name old time/op new time/op delta ParsePredicates-8 4.58µs ± 7% 4.42µs ± 0% ~ (p=0.064 n=10+8) LBBackendString-8 2.40µs ±12% 2.53µs ±11% ~ (p=0.060 n=10+10) name old alloc/op new alloc/op delta ParsePredicates-8 744B ± 0% 744B ± 0% ~ (all equal) LBBackendString-8 4.65kB ± 0% 4.65kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta ParsePredicates-8 35.0 ± 0% 35.0 ± 0% ~ (all equal) LBBackendString-8 12.0 ± 0% 12.0 ± 0% ~ (all equal) ``` Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
It seems that |
go tool cover fails for eskip package: ``` $ go test ./eskip/ -coverprofile=.coverprofile && go tool cover -func .coverprofile ok github.com/zalando/skipper/eskip 0.026s coverage: 88.2% of statements cover: inconsistent NumStmt: changed from 1 to 2 ``` this apparently happens due to malformed .coverprofile containing non-go files ```sh $ cut -d: -f1 .coverprofile | grep -v -F '.go' | sort -u github.com/zalando/skipper/eskip/parser.y github.com/zalando/skipper/eskip/yaccpar mode ``` added by line directives in generated parser.go. The problem looks similar to the issue golang/go#45361. To fix the problem updated go:generate directive to omit line directives (-l) and parsing tables (-v "") and re-generated the parser: ```sh $ rm $(which goyacc) $ go install golang.org/x/tools/cmd/goyacc $ go generate ./eskip ``` Benchmark results did not change after re-generate: ``` name old time/op new time/op delta ParsePredicates-8 4.58µs ± 7% 4.42µs ± 0% ~ (p=0.064 n=10+8) LBBackendString-8 2.40µs ±12% 2.53µs ±11% ~ (p=0.060 n=10+10) name old alloc/op new alloc/op delta ParsePredicates-8 744B ± 0% 744B ± 0% ~ (all equal) LBBackendString-8 4.65kB ± 0% 4.65kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta ParsePredicates-8 35.0 ± 0% 35.0 ± 0% ~ (all equal) LBBackendString-8 12.0 ± 0% 12.0 ± 0% ~ (all equal) ``` Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Use ./... instead of loop over packages. Originally loop over packages was added by #359 that introduced glide package manager. This manager fetches dependencies into vendor/ subdirectory (see https://glide.readthedocs.io/en/latest/getting-started/) and apparently loop over packages was necessary back then. glide usage was removed by #764 The change now also runs testable examples. Also: * increases redis testcontainer ping and shutdown timeouts after observed CI failures * fixes cmd/eskip etcd shutdown similar to #2359 * fixes cmd/eskip test introduced by #2202 * fixes lua example * removed bench target as it makes little sense * .coverprofile-all can not be simplified yet due to golang/go#45361 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
It is indeed the latest release
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
git clone https://github.com/prometheus/prometheus
cd prometheus/promql/parser
go test -coverprofile=wrong.out
go tool cover -html wrong.out
What did you expect to see?
Get the HTML coverage report
What did you see instead?
Error message
cover: inconsistent NumStmt: changed from 2 to 1
The wrong.out contains indeed (running
grep generated_parser.y.go wrong.out | grep 178
I found this by modifying the
cover
message with adding%#+v
about other fieldsThe text was updated successfully, but these errors were encountered: