Skip to content

Commit

Permalink
Some FS tests can't run in parallel
Browse files Browse the repository at this point in the history
These tests all try to create the compressed versions of files at the
same time which might lead to concurrency errors.
  • Loading branch information
erikdubbelboer committed Sep 5, 2021
1 parent ba40107 commit 3f70d78
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestPathNotFoundFunc(t *testing.T) {
}

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

var ctx RequestCtx
var req Request
Expand Down Expand Up @@ -204,7 +204,7 @@ func (pw pureWriter) Write(p []byte) (nn int, err error) {
}

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

var ctx RequestCtx
ctx.Init(&Request{}, nil, nil)
Expand Down Expand Up @@ -270,7 +270,7 @@ func TestServeFileCompressed(t *testing.T) {
}

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

var ctx RequestCtx
var req Request
Expand Down Expand Up @@ -611,25 +611,9 @@ func testFSCompress(t *testing.T, h RequestHandler, filePath string) {
}
}

func TestFileLock(t *testing.T) {
t.Parallel()

for i := 0; i < 10; i++ {
filePath := fmt.Sprintf("foo/bar/%d.jpg", i)
lock := getFileLock(filePath)
lock.Lock()
lock.Unlock() // nolint:staticcheck
}

for i := 0; i < 10; i++ {
filePath := fmt.Sprintf("foo/bar/%d.jpg", i)
lock := getFileLock(filePath)
lock.Lock()
lock.Unlock() // nolint:staticcheck
}
}

func TestFSHandlerSingleThread(t *testing.T) {
// This test can't run parallel as files in / might by changed by other tests.

requestHandler := FSHandler(".", 0)

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

func TestFSHandlerConcurrent(t *testing.T) {
// This test can't run parallel as files in / might by changed by other tests.

requestHandler := FSHandler(".", 0)

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

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

var ctx RequestCtx
var req Request
Expand Down

0 comments on commit 3f70d78

Please sign in to comment.