diff options
-rw-r--r-- | src/cmd/compile/internal/base/flag.go | 1 | ||||
-rw-r--r-- | test/run.go | 29 | ||||
-rw-r--r-- | test/typeparam/smoketest.go | 2 |
3 files changed, 18 insertions, 14 deletions
diff --git a/src/cmd/compile/internal/base/flag.go b/src/cmd/compile/internal/base/flag.go index b8b205f412..942659bcc0 100644 --- a/src/cmd/compile/internal/base/flag.go +++ b/src/cmd/compile/internal/base/flag.go @@ -140,6 +140,7 @@ type CmdFlags struct { // ParseFlags parses the command-line flags into Flag. func ParseFlags() { + Flag.G = 3 Flag.I = addImportDir Flag.LowerC = 1 diff --git a/test/run.go b/test/run.go index f5971d2d15..22e94b767c 100644 --- a/test/run.go +++ b/test/run.go @@ -32,6 +32,10 @@ import ( "unicode" ) +// CompilerDefaultGLevel is the -G level used by default when not overridden by a +// command-line flag +const CompilerDefaultGLevel = 3 + var ( verbose = flag.Bool("v", false, "verbose. if set, parallelism is set to 1.") keep = flag.Bool("k", false, "keep. keep temporary directory.") @@ -340,13 +344,18 @@ type test struct { } // initExpectFail initializes t.expectFail based on the build+test -// configuration. It should only be called for tests known to use -// types2. -func (t *test) initExpectFail() { +// configuration. +func (t *test) initExpectFail(hasGFlag bool) { if *force { return } + if t.glevel == 0 && !hasGFlag && !unifiedEnabled { + // tests should always pass when run w/o types2 (i.e., using the + // legacy typechecker, option -G=0). + return + } + failureSets := []map[string]bool{types2Failures} // Note: gccgo supports more 32-bit architectures than this, but @@ -581,14 +590,14 @@ func init() { checkShouldTest() } // over and over. func (t *test) goGcflags() string { flags := os.Getenv("GO_GCFLAGS") - if t.glevel != 0 { + if t.glevel != CompilerDefaultGLevel { flags = fmt.Sprintf("%s -G=%v", flags, t.glevel) } return "-gcflags=all=" + flags } func (t *test) goGcflagsIsEmpty() bool { - return "" == os.Getenv("GO_GCFLAGS") && t.glevel == 0 + return "" == os.Getenv("GO_GCFLAGS") && t.glevel == CompilerDefaultGLevel } var errTimeout = errors.New("command exceeded time limit") @@ -750,7 +759,7 @@ func (t *test) run() { } } - if hasGFlag && t.glevel != 0 { + if hasGFlag && t.glevel != CompilerDefaultGLevel { // test provides explicit -G flag already; don't run again if *verbose { fmt.Printf("excl\t%s\n", t.goFileName()) @@ -758,13 +767,7 @@ func (t *test) run() { return false } - if t.glevel == 0 && !hasGFlag && !unifiedEnabled { - // tests should always pass when run w/o types2 (i.e., using the - // legacy typechecker). - return true - } - - t.initExpectFail() + t.initExpectFail(hasGFlag) switch tool { case Build, Run: diff --git a/test/typeparam/smoketest.go b/test/typeparam/smoketest.go index 5243dc5c3c..f32b40062d 100644 --- a/test/typeparam/smoketest.go +++ b/test/typeparam/smoketest.go @@ -1,4 +1,4 @@ -// compile -G +// compile -G=1 // Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style |