From bcaabedc8ecfbfd97ac9860852587559dd283334 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 24 Apr 2026 09:52:50 +0200 Subject: [PATCH] chore(scanner): deflake TestStopWalk (#10664) The test expected the stopped scanner to produce at most numHashers additional results, but there's also the case where a directory is encountered (which doesn't require hashing) and sent directly. Signed-off-by: Jakob Borg --- lib/scanner/walk_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/scanner/walk_test.go b/lib/scanner/walk_test.go index 820d0988c..d75dddaf3 100644 --- a/lib/scanner/walk_test.go +++ b/lib/scanner/walk_test.go @@ -18,7 +18,6 @@ import ( rdebug "runtime/debug" "slices" "strings" - "sync" "testing" "github.com/d4l3k/messagediff" @@ -620,12 +619,9 @@ func (l testfileList) String() string { return b.String() } -var initOnce sync.Once - const ( testdataSize = 17<<20 + 1 testdataName = "_random.data" - testFsPath = "some_random_dir_path" ) func BenchmarkHashFile(b *testing.B) { @@ -717,13 +713,15 @@ func TestStopWalk(t *testing.T) { // Empty out any waiting entries and wait for the channel to close. // Count them, they should be zero or very few - essentially, each // hasher has the choice of returning a fully handled entry or - // cancelling, but they should not start on another item. + // cancelling, but they should not start on another item. The scan + // goroutine can also have one directory entry in-flight on finishedChan + // (directories bypass the hashers). extra := 0 for range fchan { extra++ } t.Log("Extra entries:", extra) - if extra > numHashers { + if extra > numHashers+1 { t.Error("unexpected extra entries received after cancel") } }