golangci / misspell

Correct commonly misspelled English words in source files
MIT License
22 stars 11 forks source link

dev: fix data race in TestCheckReplace #5

Closed alexandear closed 8 months ago

alexandear commented 1 year ago

This PR fixes the following data race when running go test -v -race .:

=== RUN   TestCheckReplace
=== RUN   TestCheckReplace/foo
=== PAUSE TestCheckReplace/foo
=== RUN   TestCheckReplace/foo_junk
=== PAUSE TestCheckReplace/foo_junk
=== RUN   TestCheckReplace/junk_foo
=== PAUSE TestCheckReplace/junk_foo
=== RUN   TestCheckReplace/junk_foo_junk
=== PAUSE TestCheckReplace/junk_foo_junk
=== CONT  TestCheckReplace/foo
=== CONT  TestCheckReplace/junk_foo_junk
=== CONT  TestCheckReplace/foo_junk
=== CONT  TestCheckReplace/junk_foo
==================
WARNING: DATA RACE
Write at 0x00c0013001e0 by goroutine 173:
  github.com/golangci/misspell.TestCheckReplace.func1()
      /Users/Oleksandr_Redko/src/github.com/golangci/misspell/replace_test.go:130 +0x98
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1595 +0x194
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1648 +0x40

Previous write at 0x00c0013001e0 by goroutine 170:
  github.com/golangci/misspell.TestCheckReplace.func1()
      /Users/Oleksandr_Redko/src/github.com/golangci/misspell/replace_test.go:130 +0x98
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1595 +0x194
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1648 +0x40

Goroutine 173 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1648 +0x5d8
  github.com/golangci/misspell.TestCheckReplace()
      /Users/Oleksandr_Redko/src/github.com/golangci/misspell/replace_test.go:127 +0x534
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1595 +0x194
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1648 +0x40

Goroutine 170 (finished) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1648 +0x5d8
  github.com/golangci/misspell.TestCheckReplace()
      /Users/Oleksandr_Redko/src/github.com/golangci/misspell/replace_test.go:127 +0x534
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1595 +0x194
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1648 +0x40
==================
==================
WARNING: DATA RACE=== NAME  TestCheckReplace/junk_foo_junk

Write at 0x00c001308108 by goroutine 171:
    testing.go:1465: race detected during execution of test
  github.com/golangci/misspell.TestCheckReplace.func1()
      /Users/Oleksandr_Redko/src/github.com/golangci/misspell/replace_test.go:130 +0xd8
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1595 +0x194
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1648 +0x40

Previous write at 0x00c001308108 by goroutine 170:
  github.com/golangci/misspell.TestCheckReplace.func1()
      /Users/Oleksandr_Redko/src/github.com/golangci/misspell/replace_test.go:130 +0xd8
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1595 +0x194
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1648 +0x40

Goroutine 171 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1648 +0x5d8
  github.com/golangci/misspell.TestCheckReplace()
      /Users/Oleksandr_Redko/src/github.com/golangci/misspell/replace_test.go:127 +0x534
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1595 +0x194
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1648 +0x40

Goroutine 170 (finished) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1648 +0x5d8
  github.com/golangci/misspell.TestCheckReplace()
      /Users/Oleksandr_Redko/src/github.com/golangci/misspell/replace_test.go:127 +0x534
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1595 +0x194
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1648 +0x40
==================
=== NAME  TestCheckReplace/foo_junk
    replace_test.go:132: basic recheck failed "food pruning" vs "junk foobar junk"
    testing.go:1465: race detected during execution of test
--- FAIL: TestCheckReplace (0.00s)
    --- PASS: TestCheckReplace/foo (0.00s)
    --- PASS: TestCheckReplace/junk_foo (0.00s)
    --- FAIL: TestCheckReplace/junk_foo_junk (0.00s)
    --- FAIL: TestCheckReplace/foo_junk (0.00s)
alexandear commented 8 months ago

Hello @ldez,

I submitted this pull request a while ago and it appears to be pending review. I understand you're busy, but if you could find some time to look at it, I would greatly appreciate your feedback.

Thank you for your time and consideration.