diff --git a/model/walk.go b/model/walk.go index 088669f70..0dd99fe71 100644 --- a/model/walk.go +++ b/model/walk.go @@ -227,15 +227,6 @@ func (m *Model) cleanTempFiles() { filepath.Walk(m.dir, m.cleanTempFile) } -func ignoreFilter(patterns map[string][]string, files []File) (filtered []File) { - for _, f := range files { - if !ignoreFile(patterns, f.Name) { - filtered = append(filtered, f) - } - } - return filtered -} - func ignoreFile(patterns map[string][]string, file string) bool { first, last := path.Split(file) for prefix, pats := range patterns { diff --git a/model/walk_test.go b/model/walk_test.go index 3e706eda8..331c86983 100644 --- a/model/walk_test.go +++ b/model/walk_test.go @@ -55,32 +55,28 @@ func TestIgnore(t *testing.T) { "foo": {"bar", "z*"}, "foo/baz": {"quux", ".*"}, } - var files = []File{ - {Name: "foo/bar"}, - {Name: "foo/quux"}, - {Name: "foo/zuux"}, - {Name: "foo/qzuux"}, - {Name: "foo/baz/t1"}, - {Name: "foo/baz/t2"}, - {Name: "foo/baz/bar"}, - {Name: "foo/baz/quuxa"}, - {Name: "foo/baz/aquux"}, - {Name: "foo/baz/.quux"}, - {Name: "foo/baz/zquux"}, - {Name: "foo/baz/quux"}, - {Name: "foo/bazz/quux"}, - } - var remaining = []File{ - {Name: "foo/quux"}, - {Name: "foo/qzuux"}, - {Name: "foo/baz/t1"}, - {Name: "foo/baz/quuxa"}, - {Name: "foo/baz/aquux"}, - {Name: "foo/bazz/quux"}, + var tests = []struct { + f string + r bool + }{ + {"foo/bar", true}, + {"foo/quux", false}, + {"foo/zuux", true}, + {"foo/qzuux", false}, + {"foo/baz/t1", false}, + {"foo/baz/t2", true}, + {"foo/baz/bar", true}, + {"foo/baz/quuxa", false}, + {"foo/baz/aquux", false}, + {"foo/baz/.quux", true}, + {"foo/baz/zquux", true}, + {"foo/baz/quux", true}, + {"foo/bazz/quux", false}, } - var filtered = ignoreFilter(patterns, files) - if !reflect.DeepEqual(filtered, remaining) { - t.Errorf("Filtering mismatch\n %v\n %v", remaining, filtered) + for i, tc := range tests { + if r := ignoreFile(patterns, tc.f); r != tc.r { + t.Errorf("Incorrect ignoreFile() #%d; E: %v, A: %v", i, tc.r, r) + } } }