mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Avoid platform-specific NewPatternMatcher function in TestCompile
Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
This commit is contained in:
parent
8d250be008
commit
38e2e756c9
1 changed files with 10 additions and 5 deletions
|
@ -737,14 +737,19 @@ func TestCompile(t *testing.T) {
|
|||
func testCompile(sl string) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
for _, tt := range compileTests {
|
||||
pattern := tt.pattern
|
||||
// Avoid NewPatternMatcher, which has platform-specific behavior
|
||||
pm := &PatternMatcher{
|
||||
patterns: make([]*Pattern, 1),
|
||||
}
|
||||
pattern := path.Clean(tt.pattern)
|
||||
if sl != "/" {
|
||||
pattern = strings.ReplaceAll(pattern, "/", sl)
|
||||
}
|
||||
pm, err := NewPatternMatcher([]string{pattern})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create PatternMatcher for pattern %q: %v", pattern, err)
|
||||
}
|
||||
newp := &Pattern{}
|
||||
newp.cleanedPattern = pattern
|
||||
newp.dirs = strings.Split(pattern, sl)
|
||||
pm.patterns[0] = newp
|
||||
|
||||
if err := pm.patterns[0].compile(sl); err != nil {
|
||||
t.Fatalf("Failed to compile pattern %q: %v", pattern, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue