aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/covdata/tool_test.go
AgeCommit message (Collapse)Author
2026-02-02cmd/cover, cmd/covdata: actually delete temp dirsIan Lance Taylor
The code was using defer in TestMain, but was also calling os.Exit, which meant that the deferred functions did not run. TestMain does not require calling os.Exit, so stop doing it. Change-Id: I25ca64c36acf65dae3dc3f46e5fa513b9460a8e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/740781 Reviewed-by: Than McIntosh <thanm@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-03all: remove coverageredesign experimentIan Lance Taylor
The coverageredesign experiment was turned on by default by CL 436236 in September, 2022. We've documented it and people are using it. This CL removes the ability to turn off the experiment. This removes some old code that is no longer being executed. For #51430 Change-Id: I88d4998c8b5ea98eef8145d7ca6ebd96f64fbc2b Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-darwin-amd64-longtest,gotip-linux-arm64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/644997 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-09-03cmd: use testenv.Executable helperKir Kolyshkin
Change-Id: I25ac0e8d25d760bfde3bb7700f0feaa23f3e8ab1 Reviewed-on: https://go-review.googlesource.com/c/go/+/609302 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07all: remove redundant string conversions when formatting []byte with %scui fliter
Change-Id: I1285ee047fd465f48028186ae04d4de60cc9969e Reviewed-on: https://go-review.googlesource.com/c/go/+/569715 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-06-14all: fix spelling errorsAlexander Yastrebov
Fix spelling errors discovered using https://github.com/codespell-project/codespell. Errors in data files and vendored packages are ignored. Change-Id: I83c7818222f2eea69afbd270c15b7897678131dc GitHub-Last-Rev: 3491615b1b82832cc0064f535786546e89aa6184 GitHub-Pull-Request: golang/go#60758 Reviewed-on: https://go-review.googlesource.com/c/go/+/502576 Auto-Submit: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
2023-05-23cmd/covdata: relax mode clash policy for selected operationsThan McIntosh
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>
2022-12-08cmd/{go,cover,covdata}: fix 'package main' inconsistent handlingThan McIntosh
Fix a buglet in cmd/cover in how we handle package name/path for the "go build -o foo.exe *.go" and "go run *.go" cases. The go command assigns a dummy import path of "command-line-arguments" to the main package built in these cases; rather than expose this dummy to the user in coverage reports, the cover tool had a special case hack intended to rewrite such package paths to "main". The hack was too general, however, and was rewriting the import path of all packages with (p.name == "main") to an import path of "main". The hack also produced unexpected results for cases such as go test -cover foo.go foo_test.go This patch removes the hack entirely, leaving the package path for such cases as "command-line-arguments". Fixes #57169. Change-Id: Ib6071db5e3485da3b8c26e16ef57f6fa1712402c Reviewed-on: https://go-review.googlesource.com/c/go/+/456237 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-15cmd/cover: use testenv.Command instead of exec.CommandBryan C. Mills
testenv.Command sets a default timeout based on the test's deadline and sends SIGQUIT (where supported) in case of a hang. Change-Id: Ic19f8b020f6d410942bb2ece8a3b71607ee6488a Reviewed-on: https://go-review.googlesource.com/c/go/+/450695 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-12cmd/{cover,covdata}: minor code cleanupsThan McIntosh
Delete some unused code, and fix a few warnings from staticcheck. Change-Id: I3d3a6f13dccffda060449948769c305d93a0389c Reviewed-on: https://go-review.googlesource.com/c/go/+/441936 Reviewed-by: Bryan Mills <bcmills@google.com>
2022-09-29cmd: add skips as needed to get tests to pass on js/wasmBryan C. Mills
For #54219. Change-Id: I9767f46a5b44beeee62a3d53c4de4f6acb6b6e73 Reviewed-on: https://go-review.googlesource.com/c/go/+/436816 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-09-29cmd{cover,covdata,go}: better coverage for tests that build toolsThan McIntosh
Some of the unit tests in Go's "cmd" tree wind up building a separate copy of the tool being tested, then exercise the freshly built tool as a way of doing regression tests. The intent is to make sure that "go test" is testing the current state of the source code, as opposed to whatever happened to be current when "go install <tool>" was last run. Doing things this way is unfriendly for coverage testing. If I run "go test -cover cmd/mumble", and the cmd/mumble test harness builds a fresh copy of mumble.exe, any runs of that new executable won't generate coverage data. This patch updates the test harnesses to use the unit test executable as a stand-in for the tool itself, so that if "go test -cover" is in effect, we get the effect of building the tool executable for coverage as well. Doing this brings up the overall test coverage number for cmd/cover quite dramatically: before change: $ go test -cover . ok cmd/cover 1.100s coverage: 1.5% of statements after change: $ go test -cover . ok cmd/cover 1.299s coverage: 84.2% of statements Getting this to work requires a small change in the Go command as well, to set GOCOVERDIR prior to executing a test binary. Updates #51430. Change-Id: Ifcf0ea85773b80fcda794aae3702403ec8e0b733 Reviewed-on: https://go-review.googlesource.com/c/go/+/404299 Reviewed-by: Bryan Mills <bcmills@google.com>
2022-09-28cmd/covdata: add tools to read/manipulate coverage data filesThan McIntosh
Add a set of helper packages for reading collections of related meta-data and counter-data files ("pods") produced by runs of coverage-instrumented binaries, and a new tool program (cmd/covdata) for dumping and/or manipulating coverage data files. Currently "go tool covdata" subcommands include 'merge', 'intersect', 'percent', 'pkglist', 'subtract', 'debugdump', and 'textfmt' (conversion to the legacy "go tool cover" format). Updates #51430. Change-Id: I44167c578f574b4636ab8726e726388531fd3258 Reviewed-on: https://go-review.googlesource.com/c/go/+/357609 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>