Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix check to enable the race detector in supported platforms #40764

Merged
merged 5 commits into from
Sep 16, 2024
Merged
Changes from 1 commit
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
13 changes: 10 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,9 +274,15 @@ 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.
raceAmd64 := os.Getenv("DEV_ARCH") == "amd64"
raceArm64 := os.Getenv("DEV_ARCH") == "arm64" &&
slices.Contains([]string{"linux", "darwin"}, os.Getenv("DEV_OS"))
if raceAmd64 || raceArm64 {
testArgs = append(testArgs, "-race")
mauri870 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down
Loading