Skip to content

Commit 82223bf

Browse files
committed
Revert zip test, as it is too flaky and long
1 parent e1f6aa8 commit 82223bf

File tree

1 file changed

+27
-56
lines changed

1 file changed

+27
-56
lines changed

src/archive/zip/zip_test.go

Lines changed: 27 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,63 +24,34 @@ func TestOver65kFiles(t *testing.T) {
2424
if testing.Short() && testenv.Builder() == "" {
2525
t.Skip("skipping in short mode")
2626
}
27-
28-
testCases := []struct {
29-
name string
30-
method uint16
31-
}{
32-
{"Store", Store},
33-
{"Deflate", Deflate},
34-
}
35-
for _, tc := range testCases {
36-
t.Run(tc.name, func(t *testing.T) {
37-
buf := new(strings.Builder)
38-
w := NewWriter(buf)
39-
const nFiles = (1 << 16) + 42
40-
for i := 0; i < nFiles; i++ {
41-
_, err := w.CreateHeader(&FileHeader{
42-
Name: fmt.Sprintf("%d.dat", i),
43-
Method: tc.method,
44-
})
45-
if err != nil {
46-
t.Fatalf("creating file %d: %v", i, err)
47-
}
48-
}
49-
if err := w.Close(); err != nil {
50-
t.Fatalf("Writer.Close: %v", err)
51-
}
52-
53-
s := buf.String()
54-
zr, err := NewReader(strings.NewReader(s), int64(len(s)))
55-
if err != nil {
56-
t.Fatalf("NewReader: %v", err)
57-
}
58-
if got := len(zr.File); got != nFiles {
59-
t.Fatalf("File contains %d files, want %d", got, nFiles)
60-
}
61-
for i := 0; i < nFiles; i++ {
62-
want := fmt.Sprintf("%d.dat", i)
63-
if zr.File[i].Name != want {
64-
t.Fatalf("File(%d) = %q, want %q", i, zr.File[i].Name, want)
65-
}
66-
}
67-
68-
// Test Issue 59775
69-
allocs := testing.AllocsPerRun(1, func() {
70-
for i := 0; i < nFiles; i++ {
71-
f, err := zr.File[i].Open()
72-
if err != nil {
73-
t.Fatalf("File(%d).Open: %v", i, err)
74-
}
75-
if err := f.Close(); err != nil {
76-
t.Fatalf("File(%d).Open().Close: %v", i, err)
77-
}
78-
}
79-
})
80-
if allocs > 450_000 {
81-
t.Errorf("allocated too much objects (%v) opening zip files", allocs)
82-
}
27+
buf := new(strings.Builder)
28+
w := NewWriter(buf)
29+
const nFiles = (1 << 16) + 42
30+
for i := 0; i < nFiles; i++ {
31+
_, err := w.CreateHeader(&FileHeader{
32+
Name: fmt.Sprintf("%d.dat", i),
33+
Method: Store, // Deflate is too slow when it is compiled with -race flag
8334
})
35+
if err != nil {
36+
t.Fatalf("creating file %d: %v", i, err)
37+
}
38+
}
39+
if err := w.Close(); err != nil {
40+
t.Fatalf("Writer.Close: %v", err)
41+
}
42+
s := buf.String()
43+
zr, err := NewReader(strings.NewReader(s), int64(len(s)))
44+
if err != nil {
45+
t.Fatalf("NewReader: %v", err)
46+
}
47+
if got := len(zr.File); got != nFiles {
48+
t.Fatalf("File contains %d files, want %d", got, nFiles)
49+
}
50+
for i := 0; i < nFiles; i++ {
51+
want := fmt.Sprintf("%d.dat", i)
52+
if zr.File[i].Name != want {
53+
t.Fatalf("File(%d) = %q, want %q", i, zr.File[i].Name, want)
54+
}
8455
}
8556
}
8657

0 commit comments

Comments
 (0)