searcher: fix benchmarks (#64292)

Column helper now returns 0 based indexes. FilterTar became a required
function on diskcache.

Test Plan: go test -run '^$' -bench . ./cmd/searcher/internal/search

Fixes
https://linear.app/sourcegraph/issue/SPLF-183/benchmarks-in-searcher-broken
This commit is contained in:
Keegan Carruthers-Smith 2024-08-06 11:33:52 +02:00 committed by GitHub
parent 155975259a
commit c09552ed15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -370,8 +370,8 @@ func BenchmarkColumnHelper(b *testing.B) {
offset := 0
for offset < len(data) {
col := columnHelper.get(lineOffset, offset)
if col != offset+1 {
b.Fatal("column is not offset even though data is ASCII")
if col != offset {
b.Fatal("column is not offset even though data is ASCII", col, offset)
}
offset += dist
}

View File

@ -1,6 +1,7 @@
package search
import (
"archive/tar"
"archive/zip"
"bytes"
"context"
@ -463,6 +464,7 @@ func TestPathMatches(t *testing.T) {
// githubStore fetches from github and caches across test runs.
var githubStore = &Store{
FetchTar: fetchTarFromGithub,
FilterTar: noFilterTar,
Path: "/tmp/search_test/store",
Logger: observation.TestContext.Logger,
ObservationCtx: &observation.TestContext,
@ -473,6 +475,10 @@ func fetchTarFromGithub(ctx context.Context, repo api.RepoName, commit api.Commi
return r, err
}
func noFilterTar(ctx context.Context, repo api.RepoName, commit api.CommitID) (FilterFunc, error) {
return func(hdr *tar.Header) bool { return false }, nil
}
func init() {
// Clear out store so we pick up changes in our store writing code.
os.RemoveAll(githubStore.Path)