From 86794e96eea9852ad78c7c543b97c47b817b8398 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Thu, 10 Nov 2022 19:05:20 -0800 Subject: [PATCH] DoTestCaseFile: Don't panic Instead of panicking, report the error in the form, $file: $msg So an error might look like, foo.txt: line 12: invalid case No: [..] And then kill the test with FailNow. This is the same as calling `t.Fatalf(...)`. --- testutil/testutil.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testutil/testutil.go b/testutil/testutil.go index 4e529f3..3404a5a 100644 --- a/testutil/testutil.go +++ b/testutil/testutil.go @@ -236,7 +236,8 @@ func ParseTestCaseFile(filename string) ([]MarkdownTestCase, error) { func DoTestCaseFile(m goldmark.Markdown, filename string, t TestingT, no ...int) { allCases, err := ParseTestCaseFile(filename) if err != nil { - panic(err) + t.Errorf("%v: %v", filename, err) + t.FailNow() } cases := allCases[:0]