mirror of
https://github.com/golang/go
synced 2024-09-15 14:10:17 +00:00
mime: remove test ordering dependency
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>
This commit is contained in:
parent
9a4685f220
commit
52dfdc5e1e
|
@ -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() {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue