Skip to content
Draft
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
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ test-ui::

test::
@echo "Running testsuite"
CGO_ENABLED=0 go test $(BUILD_TAGS) ./...
@OS=$$(go env GOOS); \
if [ "$$OS" = "linux" ]; then \
CGO_ENABLED=1 go test -race $(BUILD_TAGS) ./...; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CGO_ENABLED=1 go test -race $(BUILD_TAGS) ./...; \
CGO_ENABLED=0 go test -race $(BUILD_TAGS) ./...; \

Copy link
Contributor Author

@xBlaz3kx xBlaz3kx Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, this is required - #25870 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the bot says so? I can test, that's for sure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CGO_ENABLED=0 got -race . -timeout 5s -run TestRace
==================
WARNING: DATA RACE
Read at 0x00c000674a58 by goroutine 31:
  github.com/evcc-io/evcc.TestRace.func2()
      /Users/a25058/htdocs/evcc/race_test.go:16 +0x2c

Previous write at 0x00c000674a58 by goroutine 30:
  github.com/evcc-io/evcc.TestRace.func1()
      /Users/a25058/htdocs/evcc/race_test.go:10 +0x3c

Goroutine 31 (running) created at:
  github.com/evcc-io/evcc.TestRace()
      /Users/a25058/htdocs/evcc/race_test.go:14 +0xf8
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.25.5/libexec/src/testing/testing.go:1934 +0x164
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.25.5/libexec/src/testing/testing.go:1997 +0x3c

Goroutine 30 (running) created at:
  github.com/evcc-io/evcc.TestRace()
      /Users/a25058/htdocs/evcc/race_test.go:8 +0x98
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.25.5/libexec/src/testing/testing.go:1934 +0x164
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.25.5/libexec/src/testing/testing.go:1997 +0x3c
==================
==================
WARNING: DATA RACE
Write at 0x00c000674a58 by goroutine 31:
  github.com/evcc-io/evcc.TestRace.func2()
      /Users/a25058/htdocs/evcc/race_test.go:16 +0x3c

Previous write at 0x00c000674a58 by goroutine 30:
  github.com/evcc-io/evcc.TestRace.func1()
      /Users/a25058/htdocs/evcc/race_test.go:10 +0x3c

Goroutine 31 (running) created at:
  github.com/evcc-io/evcc.TestRace()
      /Users/a25058/htdocs/evcc/race_test.go:14 +0xf8
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.25.5/libexec/src/testing/testing.go:1934 +0x164
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.25.5/libexec/src/testing/testing.go:1997 +0x3c

Goroutine 30 (running) created at:
  github.com/evcc-io/evcc.TestRace()
      /Users/a25058/htdocs/evcc/race_test.go:8 +0x98
  testing.tRunner()
      /opt/homebrew/Cellar/go/1.25.5/libexec/src/testing/testing.go:1934 +0x164
  testing.(*T).Run.gowrap1()
      /opt/homebrew/Cellar/go/1.25.5/libexec/src/testing/testing.go:1997 +0x3c
==================
FAIL
FAIL	github.com/evcc-io/evcc	1.352s
FAIL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package main

import "testing"

func TestRace(t *testing.T) {
	var i int

	go func() {
		for {
			i += 1
		}
	}()

	go func() {
		for {
			i -= 1
		}
	}()
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we can use a different race detector (in the issue thread) or leave as-is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we split the cases once more? No CGO would be preferred since it may not always build when you pull in the wrong dependency...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean split osx and linux?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can split this further

elif [ "$$OS" = "darwin" ]; then \
CGO_ENABLED=0 go test -race $(BUILD_TAGS) ./...; \
else \
CGO_ENABLED=0 go test $(BUILD_TAGS) ./...; \
fi

porcelain::
gofmt -w -l $$(find . -name '*.go')
Expand Down
Loading