Skip to content

Commit 89f02eb

Browse files
committed
go/types: add -halt flag to ease debugging in test mode
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 <[email protected]>
1 parent 8b03a39 commit 89f02eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/go/types/check_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ import (
4242
)
4343

4444
var (
45-
listErrors = flag.Bool("errlist", false, "list errors")
46-
testFiles = flag.String("files", "", "space-separated list of test files")
45+
haltOnError = flag.Bool("halt", false, "halt on error")
46+
listErrors = flag.Bool("errlist", false, "list errors")
47+
testFiles = flag.String("files", "", "space-separated list of test files")
4748
)
4849

4950
// The test filenames do not end in .go so that they are invisible
@@ -262,6 +263,9 @@ func checkFiles(t *testing.T, testfiles []string) {
262263
}
263264
conf.Importer = importer.Default()
264265
conf.Error = func(err error) {
266+
if *haltOnError {
267+
defer panic(err)
268+
}
265269
if *listErrors {
266270
t.Error(err)
267271
return

0 commit comments

Comments
 (0)