瀏覽代碼

Avoid platform-specific NewPatternMatcher function in TestCompile

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
Aaron Lehmann 3 年之前
父節點
當前提交
38e2e756c9
共有 1 個文件被更改,包括 10 次插入5 次删除
  1. 10 5
      pkg/fileutils/fileutils_test.go

+ 10 - 5
pkg/fileutils/fileutils_test.go

@@ -737,14 +737,19 @@ func TestCompile(t *testing.T) {
 func testCompile(sl string) func(*testing.T) {
 func testCompile(sl string) func(*testing.T) {
 	return func(t *testing.T) {
 	return func(t *testing.T) {
 		for _, tt := range compileTests {
 		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 != "/" {
 			if sl != "/" {
 				pattern = strings.ReplaceAll(pattern, "/", 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 {
 			if err := pm.patterns[0].compile(sl); err != nil {
 				t.Fatalf("Failed to compile pattern %q: %v", pattern, err)
 				t.Fatalf("Failed to compile pattern %q: %v", pattern, err)
 			}
 			}