From 42cd0322b40faff130ada5965395d9a9ec42665b Mon Sep 17 00:00:00 2001 From: Tronje Krop Date: Mon, 23 Sep 2024 09:33:44 +0200 Subject: [PATCH] fix: data race on exit code (#88) Signed-off-by: Tronje Krop --- VERSION | 2 +- test/pattern.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index cd23180..44517d5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.17 +0.0.19 diff --git a/test/pattern.go b/test/pattern.go index 1960ca8..d0f1505 100644 --- a/test/pattern.go +++ b/test/pattern.go @@ -37,7 +37,6 @@ type MainParams struct { // setting the given additional environment variables (`Env`) to allow // modification of the test environment. func TestMain(main func()) func(t Test, param MainParams) { - errExit := &exec.ExitError{} return func(t Test, param MainParams) { // Switch to execute main function in test process. if name := os.Getenv("TEST"); name != "" { @@ -57,6 +56,7 @@ func TestMain(main func()) func(t Test, param MainParams) { cmd := exec.Command(os.Args[0], "-test.run="+t.(*Tester).t.Name()) cmd.Env = append(append(os.Environ(), "TEST="+t.Name()), param.Env...) if err := cmd.Run(); err != nil || param.ExitCode != 0 { + errExit := &exec.ExitError{} if errors.As(err, &errExit) || err != nil { require.Equal(t, param.ExitCode, errExit.ExitCode()) } else {