]> Cypherpunks repositories - gostls13.git/commit
cmd/covdata: relax mode clash policy for selected operations
authorThan McIntosh <thanm@google.com>
Tue, 27 Dec 2022 19:34:11 +0000 (14:34 -0500)
committerThan McIntosh <thanm@google.com>
Tue, 23 May 2023 11:36:37 +0000 (11:36 +0000)
commita371fa5e7042ee5d07b18045aefa8e9c4bfd4efa
tree872d564dd5f5daa25f4a8cff43a20d8b5403c5af
parent5322e66a121abd65a5c19f4bdada12851e7f5857
cmd/covdata: relax mode clash policy for selected operations

Relax the policy on counter mode clashes in certain cases for "go tool
covdata" operations. Specifically, when generating 'percent',
'pkglist' or 'func' reports, we only care about whether a given
statement is executed, thus counter mode clashes are irrelevant; there
is no need to report clashes for these ops.

Example:

  $ go build -covermode=count -o myprog.count.exe myprog
  $ go build -covermode=set -o myprog.set.exe myprog
  $ GOCOVERDIR=dir1 ./myprog.count.exe
  ...
  $ GOCOVERDIR=dir2 ./myprog.set.exe
  ...
  $ go tool covdata percent i=dir1,dir2
  error: counter mode clash while reading meta-data file dir2/covmeta.1a0cd0c8ccab07d3179f0ac3dd98159a: previous file had count, new file has set
  $

With this patch the command above will "do the right thing" and work
properly, and in addition merges using the "-pcombine" flag will also
operate with relaxed rules. Note that textfmt operations still require
inputs with consistent coverage modes.

Change-Id: I01e97530d9780943c99b399d03d4cfff05aafd8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/495440
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
src/cmd/covdata/dump.go
src/cmd/covdata/merge.go
src/cmd/covdata/tool_test.go
src/internal/coverage/cmerge/merge.go
src/internal/coverage/cmerge/merge_test.go