mirror of
https://github.com/golang/go
synced 2024-11-12 01:00:22 -07:00
[dev.typeparams] test: skip -G=3 testing under GOEXPERIMENT=unified
In normal build configurations, we test both -G=0 and -G=3 so that we can test both typecheck and types2. However, GOEXPERIMENT=unified always uses types2, so testing both is redundant. Change-Id: I697d2ad916d8b17cfaf4f0b6b32eec380d4e7906 Reviewed-on: https://go-review.googlesource.com/c/go/+/330755 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
808dca3b2d
commit
75ad323773
59
test/run.go
59
test/run.go
@ -42,13 +42,36 @@ var (
|
|||||||
linkshared = flag.Bool("linkshared", false, "")
|
linkshared = flag.Bool("linkshared", false, "")
|
||||||
updateErrors = flag.Bool("update_errors", false, "update error messages in test file based on compiler output")
|
updateErrors = flag.Bool("update_errors", false, "update error messages in test file based on compiler output")
|
||||||
runoutputLimit = flag.Int("l", defaultRunOutputLimit(), "number of parallel runoutput tests to run")
|
runoutputLimit = flag.Int("l", defaultRunOutputLimit(), "number of parallel runoutput tests to run")
|
||||||
generics = flag.String("G", "0,3", "a comma-separated list of -G compiler flags to test with")
|
|
||||||
force = flag.Bool("f", false, "run expected-failure generics tests rather than skipping them")
|
force = flag.Bool("f", false, "run expected-failure generics tests rather than skipping them")
|
||||||
|
generics = flag.String("G", defaultGLevels, "a comma-separated list of -G compiler flags to test with")
|
||||||
|
|
||||||
shard = flag.Int("shard", 0, "shard index to run. Only applicable if -shards is non-zero.")
|
shard = flag.Int("shard", 0, "shard index to run. Only applicable if -shards is non-zero.")
|
||||||
shards = flag.Int("shards", 0, "number of shards. If 0, all tests are run. This is used by the continuous build.")
|
shards = flag.Int("shards", 0, "number of shards. If 0, all tests are run. This is used by the continuous build.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var unifiedEnabled, defaultGLevels = func() (bool, string) {
|
||||||
|
// TODO(mdempsky): Change this to just "go env GOEXPERIMENT" after
|
||||||
|
// CL 328751 is merged back to dev.typeparams. In the mean time, we
|
||||||
|
// infer whether the "unified" experiment is default enabled by
|
||||||
|
// inspecting the output from `go tool compile -V`.
|
||||||
|
output := runOutput(goTool(), "tool", "compile", "-V")
|
||||||
|
|
||||||
|
// TODO(mdempsky): This will give false negatives if the unified
|
||||||
|
// experiment is enabled by default, but presumably at that point we
|
||||||
|
// won't need to disable tests for it anymore anyway.
|
||||||
|
enabled := strings.Contains(output, "unified")
|
||||||
|
|
||||||
|
// Normal test runs should test with both -G=0 and -G=3 for types2
|
||||||
|
// coverage. But the unified experiment always uses types2, so
|
||||||
|
// testing with -G=3 is redundant.
|
||||||
|
glevels := "0,3"
|
||||||
|
if enabled {
|
||||||
|
glevels = "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
return enabled, glevels
|
||||||
|
}()
|
||||||
|
|
||||||
// defaultAllCodeGen returns the default value of the -all_codegen
|
// defaultAllCodeGen returns the default value of the -all_codegen
|
||||||
// flag. By default, we prefer to be fast (returning false), except on
|
// flag. By default, we prefer to be fast (returning false), except on
|
||||||
// the linux-amd64 builder that's already very fast, so we get more
|
// the linux-amd64 builder that's already very fast, so we get more
|
||||||
@ -60,7 +83,6 @@ func defaultAllCodeGen() bool {
|
|||||||
var (
|
var (
|
||||||
goos, goarch string
|
goos, goarch string
|
||||||
cgoEnabled bool
|
cgoEnabled bool
|
||||||
unifiedEnabled bool
|
|
||||||
|
|
||||||
// dirs are the directories to look for *.go files in.
|
// dirs are the directories to look for *.go files in.
|
||||||
// TODO(bradfitz): just use all directories?
|
// TODO(bradfitz): just use all directories?
|
||||||
@ -97,26 +119,8 @@ func main() {
|
|||||||
goos = getenv("GOOS", runtime.GOOS)
|
goos = getenv("GOOS", runtime.GOOS)
|
||||||
goarch = getenv("GOARCH", runtime.GOARCH)
|
goarch = getenv("GOARCH", runtime.GOARCH)
|
||||||
|
|
||||||
cgoCmd := exec.Command(goTool(), "env", "CGO_ENABLED")
|
cgoEnv := runOutput(goTool(), "env", "CGO_ENABLED")
|
||||||
cgoEnv, err := cgoCmd.Output()
|
cgoEnabled, _ = strconv.ParseBool(strings.TrimSpace(cgoEnv))
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("running %v: %v", cgoCmd, err)
|
|
||||||
}
|
|
||||||
cgoEnabled, _ = strconv.ParseBool(strings.TrimSpace(string(cgoEnv)))
|
|
||||||
|
|
||||||
// TODO(mdempsky): Change this to just "go env GOEXPERIMENT" after
|
|
||||||
// CL 328751 is merged back to dev.typeparams. In the mean time, we
|
|
||||||
// infer whether the "unified" experiment is defult enabled by
|
|
||||||
// inspecting the output from `go tool compile -V`.
|
|
||||||
compileCmd := exec.Command(goTool(), "tool", "compile", "-V")
|
|
||||||
compileOutput, err := compileCmd.Output()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("running %v: %v", compileCmd, err)
|
|
||||||
}
|
|
||||||
// TODO(mdempsky): This will give false negatives if the unified
|
|
||||||
// experiment is enabled by default, but presumably at that point we
|
|
||||||
// won't need to disable tests for it anymore anyway.
|
|
||||||
unifiedEnabled = strings.Contains(string(compileOutput), "unified")
|
|
||||||
|
|
||||||
findExecCmd()
|
findExecCmd()
|
||||||
|
|
||||||
@ -203,6 +207,17 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runOutput runs the specified command and returns its output as a
|
||||||
|
// string. If the command fails, runOutput logs the error and exits.
|
||||||
|
func runOutput(name string, args ...string) string {
|
||||||
|
cmd := exec.Command(name, args...)
|
||||||
|
output, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("running %v: %v", cmd, err)
|
||||||
|
}
|
||||||
|
return string(output)
|
||||||
|
}
|
||||||
|
|
||||||
// goTool reports the path of the go tool to use to run the tests.
|
// goTool reports the path of the go tool to use to run the tests.
|
||||||
// If possible, use the same Go used to run run.go, otherwise
|
// If possible, use the same Go used to run run.go, otherwise
|
||||||
// fallback to the go version found in the PATH.
|
// fallback to the go version found in the PATH.
|
||||||
|
Loading…
Reference in New Issue
Block a user