Navigation Menu

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

cmd/cover: inconsistent NumStmt: changed from 1 to 2 #45506

Closed
hitzhangjie opened this issue Apr 11, 2021 · 3 comments
Closed

cmd/cover: inconsistent NumStmt: changed from 1 to 2 #45506

hitzhangjie opened this issue Apr 11, 2021 · 3 comments

Comments

@hitzhangjie
Copy link
Contributor

hitzhangjie commented Apr 11, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/zhangjie/Library/Caches/go-build"
GOENV="/Users/zhangjie/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/zhangjie/go/pkg/mod"
GONOPROXY="git.code.oa.com/*"
GONOSUMDB="git.code.oa.com/*"
GOOS="darwin"
GOPATH="/Users/zhangjie/go"
GOPRIVATE="git.code.oa.com/*"
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/zhangjie/Projects/Tencent/techmap/trpc-go-cmdline/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0j/mvtnlhyj5j9cyqqq1b27bgg40000gn/T/go-build2861231693=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.16.3 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.16.3
uname -v: Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.15.7
BuildVersion:	19H524
lldb --version: lldb-1200.0.44.2
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
gdb --version: GNU gdb (GDB) 10.1

What did you do?

I have a project, I want to do a coverage test, so I run:

go test -v -gcflags 'all=-N -l' -p 1 -cover -coverpkg all -coverprofile 1.out  ./...

go tool cover -html 1.out

And, I have gofmt the code ( reference to the suggestion from #30746)

What did you expect to see?

I want to see the result of testing coverage.

What did you see instead?

see the error:

cover: inconsistent NumStmt: changed from 1 to 2
@hitzhangjie
Copy link
Contributor Author

hitzhangjie commented Apr 11, 2021

After I change from -coverpkg all to -coverpkg $(go list ./... | sed 's/\n/,/g'), it works.

The test cases run, and cover profile 1.out is generated, and go tool cover -html 1.out works, too.
But the coverage totally wrong, it displays only func init() is covered.

@seankhliao
Copy link
Member

duplicate of #45361 ?

@seankhliao seankhliao changed the title cover: inconsistent NumStmt: changed from 1 to 2 cmd/cover: inconsistent NumStmt: changed from 1 to 2 Apr 11, 2021
@hitzhangjie
Copy link
Contributor Author

@sean-jc Oh, yes.

@golang golang locked and limited conversation to collaborators Apr 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants