]> Cypherpunks.ru repositories - gostls13.git/commitdiff
mime: remove test ordering dependency
authorIan Lance Taylor <iant@golang.org>
Sat, 6 Aug 2022 01:36:02 +0000 (18:36 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 8 Aug 2022 21:09:03 +0000 (21:09 +0000)
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 golang/go#51648

Change-Id: I8bf92b305fc4499337db06113817c9decdc5aedb
Reviewed-on: https://go-review.googlesource.com/c/go/+/421442
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

src/mime/type_test.go
src/mime/type_unix_test.go

index f10e6343f9c4592dd6e22979e8f9fb5b8e71f73a..d8368e8846f62794e98ce2ebc5f439c240374e30 100644 (file)
@@ -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() {
index 2e8f273fad636a921dc58fb62d044701aac0ca60..7b8db79d272a986b3a0df156a5489187d0fabf80 100644 (file)
@@ -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)