Skip to content

Commit

Permalink
mime: remove test ordering dependency
Browse files Browse the repository at this point in the history
Arrange for tests that call setMimeInit to fully restore the old values,
by clearing the sync.Once that controls initialization.

Once we've done that, call initMime in initMimeUnixTest because
otherwise the test types loaded there will be cleared by the call to
initMime that previously was not being done.

For #51648

Change-Id: I8bf92b305fc4499337db06113817c9decdc5aedb
Reviewed-on: https://go-review.googlesource.com/c/go/+/421442
Reviewed-by: Than McIntosh <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
  • Loading branch information
ianlancetaylor authored and gopherbot committed Aug 8, 2022
1 parent 9a4685f commit 52dfdc5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mime/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import (
func setMimeInit(fn func()) (cleanup func()) {
once = sync.Once{}
testInitMime = fn
return func() { testInitMime = nil }
return func() {
testInitMime = nil
once = sync.Once{}
}
}

func clearMimeTypes() {
Expand Down
1 change: 1 addition & 0 deletions src/mime/type_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

func initMimeUnixTest(t *testing.T) {
once.Do(initMime)
err := loadMimeGlobsFile("testdata/test.types.globs2")
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 52dfdc5

Please sign in to comment.