Skip to content

ci(test): add race detector to CI workflow and concurrent parse test coverage - #106

Open
AdamMagued wants to merge 1 commit into
ua-parser:masterfrom
AdamMagued:test-issue-104-race-detection
Open

AdamMagued wants to merge 1 commit into
ua-parser:masterfrom
AdamMagued:test-issue-104-race-detection

Conversation

@AdamMagued

Copy link
Copy Markdown

Summary

  • Add -race flag to go test in GitHub Actions CI workflow (.github/workflows/ci.yml).
  • Always clone RegexDefinitions in New() to prevent concurrent writes on shared regex pointers during initialization with custom definitions.
  • Protect individual parse methods (ParseUserAgent, ParseOs, ParseDevice) with reader locks against concurrent sorting passes.
  • Use atomic.StoreUint64 on misses counters in checkAndSort to prevent data races against atomic increments.
  • Add concurrent stress tests in uaparser/race_test.go covering shared parser usage, individual parser calls, periodic sorting, and concurrent initialization.

Fixes #104

Test Plan

  • Ran go test -race ./... -v and go vet ./... in isolated container sandbox across all unit and concurrent stress tests.
  • Verified all tests pass with zero data race warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add a -race version to our CI

1 participant