mirror of
https://github.com/golang/go
synced 2024-11-26 22:01:27 -07:00
cmd/compile/internal/types2: list errors by default in TestManual
TestManual is used for debugging; in this case we usually want to see error messages reported rather than checked against ERROR comments in the provided files. Make this the default. Use the new -verify flag to verify reported errors against ERROR comments. With this change we cannot get an error list for the non-manual tests, but that is usually not useful anyway because there are usually many errors in those test files. Run those tests manually instead. Also, corrected -lang flag synopsys: it applies to all tests, not just TestManual. Change-Id: I56e0ea0583840fc3ea150d9ccfc330370b66191c Reviewed-on: https://go-review.googlesource.com/c/go/+/315729 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
c55d5c887e
commit
95c5f4da80
@ -40,9 +40,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
haltOnError = flag.Bool("halt", false, "halt on error")
|
||||
listErrors = flag.Bool("errlist", false, "list errors")
|
||||
goVersion = flag.String("lang", "", "Go language version (e.g. \"go1.12\") for TestManual")
|
||||
haltOnError = flag.Bool("halt", false, "halt on error")
|
||||
verifyErrors = flag.Bool("verify", false, "verify errors (rather than list them) in TestManual")
|
||||
goVersion = flag.String("lang", "", "Go language version (e.g. \"go1.12\")")
|
||||
)
|
||||
|
||||
func parseFiles(t *testing.T, filenames []string, mode syntax.Mode) ([]*syntax.File, []error) {
|
||||
@ -96,7 +96,7 @@ func asGoVersion(s string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uint, trace bool) {
|
||||
func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uint, manual bool) {
|
||||
if len(filenames) == 0 {
|
||||
t.Fatal("no source files")
|
||||
}
|
||||
@ -118,7 +118,8 @@ func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uin
|
||||
goVersion = asGoVersion(pkgName)
|
||||
}
|
||||
|
||||
if *listErrors && len(errlist) > 0 {
|
||||
listErrors := manual && !*verifyErrors
|
||||
if listErrors && len(errlist) > 0 {
|
||||
t.Errorf("--- %s:", pkgName)
|
||||
for _, err := range errlist {
|
||||
t.Error(err)
|
||||
@ -132,13 +133,13 @@ func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uin
|
||||
if len(filenames) == 1 && strings.HasSuffix(filenames[0], "importC.src") {
|
||||
conf.FakeImportC = true
|
||||
}
|
||||
conf.Trace = trace
|
||||
conf.Trace = manual && testing.Verbose()
|
||||
conf.Importer = defaultImporter()
|
||||
conf.Error = func(err error) {
|
||||
if *haltOnError {
|
||||
defer panic(err)
|
||||
}
|
||||
if *listErrors {
|
||||
if listErrors {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
@ -146,7 +147,7 @@ func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uin
|
||||
}
|
||||
conf.Check(pkgName, files, nil)
|
||||
|
||||
if *listErrors {
|
||||
if listErrors {
|
||||
return
|
||||
}
|
||||
|
||||
@ -244,8 +245,8 @@ func checkFiles(t *testing.T, filenames []string, goVersion string, colDelta uin
|
||||
//
|
||||
// go test -run Manual -- foo.go bar.go
|
||||
//
|
||||
// To get an error list rather than having the test check against
|
||||
// ERROR comments in the input files, provide the -errlist flag.
|
||||
// Provide the -verify flag to verify errors against ERROR comments in
|
||||
// the input files rather than having a list of errors reported.
|
||||
// The accepted Go language version can be controlled with the -lang flag.
|
||||
func TestManual(t *testing.T) {
|
||||
filenames := flag.Args()
|
||||
@ -254,7 +255,7 @@ func TestManual(t *testing.T) {
|
||||
}
|
||||
testenv.MustHaveGoBuild(t)
|
||||
DefPredeclaredTestFuncs()
|
||||
checkFiles(t, filenames, *goVersion, 0, testing.Verbose())
|
||||
checkFiles(t, filenames, *goVersion, 0, true)
|
||||
}
|
||||
|
||||
// TODO(gri) go/types has extra TestLongConstants and TestIndexRepresentability tests
|
||||
|
Loading…
Reference in New Issue
Block a user