)
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) {
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")
}
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)
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
}
}
conf.Check(pkgName, files, nil)
- if *listErrors {
+ if listErrors {
return
}
//
// 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()
}
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