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 <jakob@kastelo.net>
This commit is contained in:
@@ -18,7 +18,6 @@ import (
|
|||||||
rdebug "runtime/debug"
|
rdebug "runtime/debug"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/d4l3k/messagediff"
|
"github.com/d4l3k/messagediff"
|
||||||
@@ -620,12 +619,9 @@ func (l testfileList) String() string {
|
|||||||
return b.String()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
var initOnce sync.Once
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
testdataSize = 17<<20 + 1
|
testdataSize = 17<<20 + 1
|
||||||
testdataName = "_random.data"
|
testdataName = "_random.data"
|
||||||
testFsPath = "some_random_dir_path"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func BenchmarkHashFile(b *testing.B) {
|
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.
|
// Empty out any waiting entries and wait for the channel to close.
|
||||||
// Count them, they should be zero or very few - essentially, each
|
// Count them, they should be zero or very few - essentially, each
|
||||||
// hasher has the choice of returning a fully handled entry or
|
// 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
|
extra := 0
|
||||||
for range fchan {
|
for range fchan {
|
||||||
extra++
|
extra++
|
||||||
}
|
}
|
||||||
t.Log("Extra entries:", extra)
|
t.Log("Extra entries:", extra)
|
||||||
if extra > numHashers {
|
if extra > numHashers+1 {
|
||||||
t.Error("unexpected extra entries received after cancel")
|
t.Error("unexpected extra entries received after cancel")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user