diff options
| author | Colin Cross <ccross@android.com> | 2018-02-23 11:09:18 -0800 |
|---|---|---|
| committer | Colin Cross <ccross@android.com> | 2018-02-23 14:03:56 -0800 |
| commit | 54cb95a53f4e41311c5307da5c5911e31330ce2c (patch) | |
| tree | a073a5356f3b8cac282db4357c984260f1a2027d /glob.go | |
| parent | 759bb61dd5be2c386ed52ed9064d4c0766695cb9 (diff) | |
| download | platform_build_blueprint-54cb95a53f4e41311c5307da5c5911e31330ce2c.tar.gz platform_build_blueprint-54cb95a53f4e41311c5307da5c5911e31330ce2c.tar.bz2 platform_build_blueprint-54cb95a53f4e41311c5307da5c5911e31330ce2c.zip | |
Fix glob cache conflict when excludes=nil and excludes=[]string{}
Performing the same glob twice, once with excludes=nil and once
with excludes=[]string{} would hit the same entry in the glob
cache (since the glob filename would be the same), but fail
the verifyGlob check because DeepEqual considers []string(nil)
and []string{} to be different. Use a manual array check
instead.
Test: glob_test.go
Change-Id: If0d4fe80163a871077b7276e1b4a3e888a4a4898
Diffstat (limited to 'glob.go')
| -rw-r--r-- | glob.go | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -17,7 +17,6 @@ package blueprint import ( "crypto/md5" "fmt" - "reflect" "sort" "strings" ) @@ -34,9 +33,15 @@ func verifyGlob(fileName, pattern string, excludes []string, g GlobPath) { if pattern != g.Pattern { panic(fmt.Errorf("Mismatched patterns %q and %q for glob file %q", pattern, g.Pattern, fileName)) } - if !reflect.DeepEqual(g.Excludes, excludes) { + if len(excludes) != len(g.Excludes) { panic(fmt.Errorf("Mismatched excludes %v and %v for glob file %q", excludes, g.Excludes, fileName)) } + + for i := range excludes { + if g.Excludes[i] != excludes[i] { + panic(fmt.Errorf("Mismatched excludes %v and %v for glob file %q", excludes, g.Excludes, fileName)) + } + } } func (c *Context) glob(pattern string, excludes []string) ([]string, error) { |
