Skip to content

Commit 26cad54

Browse files
committed
tests: preserve running tests on Go 1.23.x
1 parent 0b60e43 commit 26cad54

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

main_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"bytes"
2121
"os"
2222
"os/exec"
23+
"runtime"
24+
"strings"
2325
"testing"
2426
)
2527

@@ -106,6 +108,10 @@ func goevalPrint(stdout func(...any), stderr func(...any), args ...string) {
106108
// As goeval is declared as a tool in go.mod (go get -tool .), we can call it as a tool.
107109
// "go tool" preserves the exit code while "go run" doesn't.
108110
cmd := exec.Command("go", append([]string{"tool", "goeval"}, args...)...)
111+
if strings.HasPrefix(runtime.Version(), "go1.23.") { // TODO remove this compatibility shim
112+
// Allow testing with Go < 1.24, unfortunately with all "go run" quirks
113+
cmd = exec.Command("go", append([]string{"run", "."}, args...)...)
114+
}
109115
cmd.Stdin = nil
110116
cmd.Stdout = printlnWriter(stdout)
111117
cmd.Stderr = printlnWriter(stderr)

0 commit comments

Comments
 (0)