Fix data race in finder_test.go

Wait for newFinder to finish writing its dump before ticking the clock.

Test: go test -race ./...
Change-Id: Ib7527ebfb4e1c989deefdb0779a4f9c0928ae15d
This commit is contained in:
Colin Cross 2024-01-17 14:57:59 -08:00
parent 84ed511ceb
commit b828213402

View file

@ -813,6 +813,7 @@ func TestFileAdded(t *testing.T) {
IncludeFiles: []string{"findme.txt"}, IncludeFiles: []string{"findme.txt"},
}, },
) )
finder.WaitForDbDump()
filesystem.Clock.Tick() filesystem.Clock.Tick()
foundPaths := finder.FindNamedAt("/tmp", "findme.txt") foundPaths := finder.FindNamedAt("/tmp", "findme.txt")
finder.Shutdown() finder.Shutdown()
@ -1445,6 +1446,7 @@ func TestUpdatingDbIffChanged(t *testing.T) {
IncludeFiles: []string{"hi.txt"}, IncludeFiles: []string{"hi.txt"},
}, },
) )
finder.WaitForDbDump()
filesystem.Clock.Tick() filesystem.Clock.Tick()
foundPaths := finder.FindAll() foundPaths := finder.FindAll()
finder.Shutdown() finder.Shutdown()
@ -1506,6 +1508,7 @@ func TestDirectoryNotPermitted(t *testing.T) {
IncludeFiles: []string{"hi.txt"}, IncludeFiles: []string{"hi.txt"},
}, },
) )
finder.WaitForDbDump()
filesystem.Clock.Tick() filesystem.Clock.Tick()
foundPaths := finder.FindAll() foundPaths := finder.FindAll()
finder.Shutdown() finder.Shutdown()
@ -1552,6 +1555,7 @@ func TestFileNotPermitted(t *testing.T) {
IncludeFiles: []string{"hi.txt"}, IncludeFiles: []string{"hi.txt"},
}, },
) )
finder.WaitForDbDump()
filesystem.Clock.Tick() filesystem.Clock.Tick()
foundPaths := finder.FindAll() foundPaths := finder.FindAll()
finder.Shutdown() finder.Shutdown()
@ -1573,6 +1577,7 @@ func TestCacheEntryPathUnexpectedError(t *testing.T) {
IncludeFiles: []string{"hi.txt"}, IncludeFiles: []string{"hi.txt"},
}, },
) )
finder.WaitForDbDump()
filesystem.Clock.Tick() filesystem.Clock.Tick()
foundPaths := finder.FindAll() foundPaths := finder.FindAll()
finder.Shutdown() finder.Shutdown()