Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"os/exec"
"path"
"path/filepath"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -273,10 +274,20 @@ func GoTest(ctx context.Context, params GoTestArgs) error {

var testArgs []string

// -race is only supported on */amd64
if os.Getenv("DEV_ARCH") == "amd64" {
if params.Race {
if params.Race {
// Enable the race detector for supported platforms.
// This is an intersection of the supported platforms for Beats and Go.
//
// See https://go.dev/doc/articles/race_detector#Requirements.
devOS := os.Getenv("DEV_OS")
devArch := os.Getenv("DEV_ARCH")
raceAmd64 := devArch == "amd64"
raceArm64 := devArch == "arm64" &&
slices.Contains([]string{"linux", "darwin"}, devOS)
if raceAmd64 || raceArm64 {
testArgs = append(testArgs, "-race")
} else {
log.Printf("Warning: skipping -race flag for unsupported platform %s/%s\n", devOS, devArch)
}
}
if len(params.Tags) > 0 {
Expand Down