]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: add -halt flag to ease debugging in test mode
authorRobert Griesemer <gri@golang.org>
Tue, 13 Aug 2019 19:56:51 +0000 (12:56 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 26 Aug 2019 16:36:10 +0000 (16:36 +0000)
Specifying -halt in `go test -run Check$ -halt` causes a panic
upon encountering the first error. The stack trace is useful to
determine what code path issued the error.

Change-Id: I2e17e0014ba87505b01786980b98565f468065bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/190257
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/go/types/check_test.go

index 358e7c5cc81c8f675c9b05f2646127c30ac7f2d9..61bcf13c1a548e2f0b81b8f59b92faf93aa198ea 100644 (file)
@@ -42,8 +42,9 @@ import (
 )
 
 var (
-       listErrors = flag.Bool("errlist", false, "list errors")
-       testFiles  = flag.String("files", "", "space-separated list of test files")
+       haltOnError = flag.Bool("halt", false, "halt on error")
+       listErrors  = flag.Bool("errlist", false, "list errors")
+       testFiles   = flag.String("files", "", "space-separated list of test files")
 )
 
 // The test filenames do not end in .go so that they are invisible
@@ -262,6 +263,9 @@ func checkFiles(t *testing.T, testfiles []string) {
        }
        conf.Importer = importer.Default()
        conf.Error = func(err error) {
+               if *haltOnError {
+                       defer panic(err)
+               }
                if *listErrors {
                        t.Error(err)
                        return