summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/internal/test/flagdefs_test.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 13:14:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 13:14:23 +0000
commit73df946d56c74384511a194dd01dbe099584fd1a (patch)
treefd0bcea490dd81327ddfbb31e215439672c9a068 /src/cmd/go/internal/test/flagdefs_test.go
parentInitial commit. (diff)
downloadgolang-1.16-upstream.tar.xz
golang-1.16-upstream.zip
Adding upstream version 1.16.10.upstream/1.16.10upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cmd/go/internal/test/flagdefs_test.go')
-rw-r--r--src/cmd/go/internal/test/flagdefs_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/cmd/go/internal/test/flagdefs_test.go b/src/cmd/go/internal/test/flagdefs_test.go
new file mode 100644
index 0000000..ab5440b
--- /dev/null
+++ b/src/cmd/go/internal/test/flagdefs_test.go
@@ -0,0 +1,39 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package test
+
+import (
+ "flag"
+ "strings"
+ "testing"
+)
+
+func TestPassFlagToTestIncludesAllTestFlags(t *testing.T) {
+ flag.VisitAll(func(f *flag.Flag) {
+ if !strings.HasPrefix(f.Name, "test.") {
+ return
+ }
+ name := strings.TrimPrefix(f.Name, "test.")
+ switch name {
+ case "testlogfile", "paniconexit0":
+ // These are internal flags.
+ default:
+ if !passFlagToTest[name] {
+ t.Errorf("passFlagToTest missing entry for %q (flag test.%s)", name, name)
+ t.Logf("(Run 'go generate cmd/go/internal/test' if it should be added.)")
+ }
+ }
+ })
+
+ for name := range passFlagToTest {
+ if flag.Lookup("test."+name) == nil {
+ t.Errorf("passFlagToTest contains %q, but flag -test.%s does not exist in test binary", name, name)
+ }
+
+ if CmdTest.Flag.Lookup(name) == nil {
+ t.Errorf("passFlagToTest contains %q, but flag -%s does not exist in 'go test' subcommand", name, name)
+ }
+ }
+}