Skip to content

Commit 3f70d78

Browse files
Some FS tests can't run in parallel
These tests all try to create the compressed versions of files at the same time which might lead to concurrency errors.
1 parent ba40107 commit 3f70d78

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

fs_test.go

+8-22
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func TestPathNotFoundFunc(t *testing.T) {
112112
}
113113

114114
func TestServeFileHead(t *testing.T) {
115-
t.Parallel()
115+
// This test can't run parallel as files in / might by changed by other tests.
116116

117117
var ctx RequestCtx
118118
var req Request
@@ -204,7 +204,7 @@ func (pw pureWriter) Write(p []byte) (nn int, err error) {
204204
}
205205

206206
func TestServeFileCompressed(t *testing.T) {
207-
t.Parallel()
207+
// This test can't run parallel as files in / might by changed by other tests.
208208

209209
var ctx RequestCtx
210210
ctx.Init(&Request{}, nil, nil)
@@ -270,7 +270,7 @@ func TestServeFileCompressed(t *testing.T) {
270270
}
271271

272272
func TestServeFileUncompressed(t *testing.T) {
273-
t.Parallel()
273+
// This test can't run parallel as files in / might by changed by other tests.
274274

275275
var ctx RequestCtx
276276
var req Request
@@ -611,25 +611,9 @@ func testFSCompress(t *testing.T, h RequestHandler, filePath string) {
611611
}
612612
}
613613

614-
func TestFileLock(t *testing.T) {
615-
t.Parallel()
616-
617-
for i := 0; i < 10; i++ {
618-
filePath := fmt.Sprintf("foo/bar/%d.jpg", i)
619-
lock := getFileLock(filePath)
620-
lock.Lock()
621-
lock.Unlock() // nolint:staticcheck
622-
}
623-
624-
for i := 0; i < 10; i++ {
625-
filePath := fmt.Sprintf("foo/bar/%d.jpg", i)
626-
lock := getFileLock(filePath)
627-
lock.Lock()
628-
lock.Unlock() // nolint:staticcheck
629-
}
630-
}
631-
632614
func TestFSHandlerSingleThread(t *testing.T) {
615+
// This test can't run parallel as files in / might by changed by other tests.
616+
633617
requestHandler := FSHandler(".", 0)
634618

635619
f, err := os.Open(".")
@@ -650,6 +634,8 @@ func TestFSHandlerSingleThread(t *testing.T) {
650634
}
651635

652636
func TestFSHandlerConcurrent(t *testing.T) {
637+
// This test can't run parallel as files in / might by changed by other tests.
638+
653639
requestHandler := FSHandler(".", 0)
654640

655641
f, err := os.Open(".")
@@ -796,7 +782,7 @@ func testFileExtension(t *testing.T, path string, compressed bool, compressedFil
796782
}
797783

798784
func TestServeFileContentType(t *testing.T) {
799-
t.Parallel()
785+
// This test can't run parallel as files in / might by changed by other tests.
800786

801787
var ctx RequestCtx
802788
var req Request

0 commit comments

Comments
 (0)