Skip to content

Commit d0af75c

Browse files
evankandersonpjbgf
authored andcommitted
Fix test handling on go < 1.23
1 parent bcc31e9 commit d0af75c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

helper/iofs/iofs_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func checkFsTestError(t *testing.T, err error, files map[string]string) {
113113
}
114114
// filter lines from the error text corresponding to the above errors;
115115
// output looks like:
116+
// TestFS found errors:
116117
// bar.txt: mismatch:
117118
// entry.Info() = bar.txt IsDir=false Mode=-rw-rw-rw- Size=14 ModTime=2024-09-17 10:09:00.377023639 +0000 UTC m=+0.002625548
118119
// file.Stat() = bar.txt IsDir=false Mode=-rw-rw-rw- Size=14 ModTime=2024-09-17 10:09:00.376907011 +0000 UTC m=+0.002508970
@@ -124,19 +125,22 @@ func checkFsTestError(t *testing.T, err error, files map[string]string) {
124125
// We filter on "empty line" or "ModTime" or "$filename: mismatch" to ignore these.
125126
lines := strings.Split(err.Error(), "\n")
126127
filtered := make([]string, 0, len(lines))
127-
filename_mismatches := make(map[string]struct{}, len(files) * 2)
128-
for name, _ := range files {
128+
filename_mismatches := make(map[string]struct{}, len(files)*2)
129+
for name := range files {
129130
for dirname := name; dirname != "."; dirname = filepath.Dir(dirname) {
130-
filename_mismatches[dirname + ": mismatch:"] = struct{}{}
131+
filename_mismatches[dirname+": mismatch:"] = struct{}{}
131132
}
132133
}
134+
if strings.TrimSpace(lines[0]) == "TestFS found errors:" {
135+
lines = lines[1:]
136+
}
133137
for _, line := range lines {
134-
line = strings.TrimSpace(line)
135-
if line == "" || strings.Contains(line, "ModTime=") {
138+
trimmed := strings.TrimSpace(line)
139+
if trimmed == "" || strings.Contains(trimmed, "ModTime=") {
136140
continue
137141
}
138142

139-
if _, ok := filename_mismatches[line]; ok {
143+
if _, ok := filename_mismatches[trimmed]; ok {
140144
continue
141145
}
142146
filtered = append(filtered, line)

0 commit comments

Comments
 (0)