diff options
author | Michael Matloob <matloob@golang.org> | 2024-05-01 13:51:20 -0400 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2024-05-03 18:15:22 +0000 |
commit | 23f760fd58a0609b9e03da944e7949f7e26a7e29 (patch) | |
tree | 36857432946687cb0696d1ef9588844302dcaa69 /src/cmd/go/script_test.go | |
parent | 7b5206bdf37863aee416358b695f6dd2a9f087fc (diff) | |
download | go-23f760fd58a0609b9e03da944e7949f7e26a7e29.tar.gz go-23f760fd58a0609b9e03da944e7949f7e26a7e29.zip |
cmd/go: remove checks that all counters incremented are in counters.txt
This change removes cmd/go/testdata/counters.txt. It also removes the
code that prepares it and checks that it contains all registered
counters as well as counters for all flags and subcommands. It removes
the counter registration mechanism, and uses telemetry.NewCounter to
create new counters instead. It keeps the tests that check that at least
one counter is incremented if the go command is invoked in a script test.
Change-Id: Ic6bda5c64e90f0dd7e221968fce0e375e84d6e17
Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/582715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Diffstat (limited to 'src/cmd/go/script_test.go')
-rw-r--r-- | src/cmd/go/script_test.go | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go index fa660bafc8..a38dec3610 100644 --- a/src/cmd/go/script_test.go +++ b/src/cmd/go/script_test.go @@ -22,7 +22,6 @@ import ( "path/filepath" "runtime" "strings" - "sync" "testing" "time" @@ -395,32 +394,13 @@ func readCounters(t *testing.T, telemetryDir string) map[string]uint64 { return totals } -//go:embed testdata/counters.txt -var countersTxt string - -var ( - allowedCountersOnce sync.Once - allowedCounters = map[string]bool{} // Set of allowed counters. -) - func checkCounters(t *testing.T, telemetryDir string) { - allowedCountersOnce.Do(func() { - for _, counter := range strings.Fields(countersTxt) { - allowedCounters[counter] = true - } - }) counters := readCounters(t, telemetryDir) if _, ok := scriptGoInvoked.Load(testing.TB(t)); ok { if !disabledOnPlatform && len(counters) == 0 { t.Fatal("go was invoked but no counters were incremented") } } - for name := range counters { - if !allowedCounters[name] { - t.Fatalf("incremented counter %q is not in testdata/counters.txt. "+ - "Please update counters_test.go to produce an entry for it.", name) - } - } } // Copied from https://go.googlesource.com/telemetry/+/5f08a0cbff3f/internal/telemetry/mode.go#122 |