diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-10-20 10:21:43 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-10-26 17:01:20 +0300 |
commit | f761c58189521884daa7ef9a981b7fa6b0a88cab (patch) | |
tree | 173c83805fb2f7ffb9da7487b4286a6673077256 | |
parent | 156e65d1de93e779091a0915cf77b2aefa85fadf (diff) |
testhelper: Fix test configuration not printing errors on failure
When the testhelper fails to set up tests correctly, then it uses
`log.Fatalf("%v", err)` to abort the tests. This does not print the
error message though, where all you see is the unhelpful "exit code 1"
error. This is because we configure the log level to only print "panic"
messages, where `Fatalf()` will create a log message with "fatal" level.
Fix this by explicitly using `fmt.Printf()` to print the error and using
`os.Exit(1)`.
-rw-r--r-- | internal/testhelper/configure.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/testhelper/configure.go b/internal/testhelper/configure.go index 68f014082..d5cc32f3f 100644 --- a/internal/testhelper/configure.go +++ b/internal/testhelper/configure.go @@ -64,7 +64,7 @@ func Run(m *testing.M, opts ...RunOption) { cleanup, err := configure() if err != nil { - return err + return fmt.Errorf("test configuration: %w", err) } defer cleanup() @@ -78,7 +78,8 @@ func Run(m *testing.M, opts ...RunOption) { return nil }(); err != nil { - log.Fatalf("%v", err) + fmt.Printf("%s", err) + os.Exit(1) } } |