Skip to content

Commit f2a389a

Browse files
Merge pull request #142 from dmcgowan/fix-fstests
Fix fstest missing file updates
2 parents aaeac12 + 9ca0eb9 commit f2a389a

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

fs/fstest/compare.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,7 @@ func CheckDirectoryEqual(d1, d2 string) error {
4949

5050
diff := diffResourceList(m1.Resources, m2.Resources)
5151
if diff.HasDiff() {
52-
if len(diff.Deletions) != 0 {
53-
return errors.Errorf("directory diff between %s and %s\n%s", d1, d2, diff.String())
54-
}
55-
// TODO: Also skip Recycle Bin contents in Windows layers which is used to store deleted files in some cases
56-
for _, add := range diff.Additions {
57-
if ok, _ := metadataFiles[add.Path()]; !ok {
58-
return errors.Errorf("directory diff between %s and %s\n%s", d1, d2, diff.String())
59-
}
60-
}
52+
return errors.Errorf("directory diff between %s and %s\n%s", d1, d2, diff.String())
6153
}
6254

6355
return nil

fs/fstest/compare_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package fstest
1818

1919
// TODO: Any more metadata files generated by Windows layers?
20+
// TODO: Also skip Recycle Bin contents in Windows layers which is used to store deleted files in some cases
2021
var metadataFiles = map[string]bool{
2122
"\\System Volume Information": true,
2223
"\\WcSandboxState": true,

fs/fstest/continuity_util.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,17 @@ type resourceListDifference struct {
4242
}
4343

4444
func (l resourceListDifference) HasDiff() bool {
45-
return len(l.Additions) > 0 || len(l.Deletions) > 0 || len(l.Updates) > 0
45+
if len(l.Deletions) > 0 || len(l.Updates) > 0 || (len(metadataFiles) == 0 && len(l.Additions) > 0) {
46+
return true
47+
}
48+
49+
for _, add := range l.Additions {
50+
if ok, _ := metadataFiles[add.Path()]; !ok {
51+
return true
52+
}
53+
}
54+
55+
return false
4656
}
4757

4858
func (l resourceListDifference) String() string {

0 commit comments

Comments
 (0)