Skip to content

Commit

Permalink
Probe directory tree for wildcard matching (#3472)
Browse files Browse the repository at this point in the history
Co-authored-by: Kyle Ju <[email protected]>
  • Loading branch information
KyleJu and Kyle Ju authored Aug 23, 2023
1 parent f6bc946 commit 9f00b3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
15 changes: 4 additions & 11 deletions api/query/cache/index/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,23 +323,16 @@ func (tl TestLabel) Filter(t TestID) bool {
return false
}

labels, ok := tl.metadata[name]
labels := tl.metadata[name]
dir := filepath.Dir(name)
// Dir terminates with either '.' (when the top-level is a file) or '/'
// (when the top-level is a directory).
for !ok && len(dir) > 1 {
labels, ok = tl.metadata[dir+"/*"]
if ok {
break
}

for len(dir) > 1 {
lbs := tl.metadata[dir+"/*"]
labels = append(labels, lbs...)
dir = filepath.Dir(dir)
}

if !ok {
return false
}

for _, label := range labels {
if strings.EqualFold(label, tl.label) {
return true
Expand Down
1 change: 1 addition & 0 deletions api/query/cache/index/index_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ func TestBindExecute_LabelWithWildcards(t *testing.T) {
"/foo/bar/b.html": {"random"},
"/a/*": {"interop1", "INTEROP2"},
"/d/e/f": {""},
matchingTestName: {"foo"},
}

// Create an execute a plan for `label:interop1 & label:interop2`. Inside the metadata
Expand Down

0 comments on commit 9f00b3c

Please sign in to comment.