From 52dfdc5e1e6f4f8ddd99f238e37b6c255f5ab6bd Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 5 Aug 2022 18:36:02 -0700 Subject: [PATCH] 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 Auto-Submit: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor --- src/mime/type_test.go | 5 ++++- src/mime/type_unix_test.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mime/type_test.go b/src/mime/type_test.go index f10e6343f9..d8368e8846 100644 --- a/src/mime/type_test.go +++ b/src/mime/type_test.go @@ -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() { diff --git a/src/mime/type_unix_test.go b/src/mime/type_unix_test.go index 2e8f273fad..7b8db79d27 100644 --- a/src/mime/type_unix_test.go +++ b/src/mime/type_unix_test.go @@ -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) -- 2.50.0