mirror of
https://github.com/golang/go.git
synced 2025-05-29 11:25:43 +00:00
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 <mdempsky@google.com>
This commit is contained in:
parent
8b03a3992b
commit
89f02eb837
@ -42,8 +42,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
listErrors = flag.Bool("errlist", false, "list errors")
|
haltOnError = flag.Bool("halt", false, "halt on error")
|
||||||
testFiles = flag.String("files", "", "space-separated list of test files")
|
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
|
// 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.Importer = importer.Default()
|
||||||
conf.Error = func(err error) {
|
conf.Error = func(err error) {
|
||||||
|
if *haltOnError {
|
||||||
|
defer panic(err)
|
||||||
|
}
|
||||||
if *listErrors {
|
if *listErrors {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user