diff options
author | Bryan C. Mills <bcmills@google.com> | 2022-03-10 00:19:05 -0500 |
---|---|---|
committer | Bryan Mills <bcmills@google.com> | 2022-03-18 20:57:35 +0000 |
commit | 9465878114232d4a9cd755fee9241fff1d63bbea (patch) | |
tree | 6b3e413343335618bbef322516584eacc697ef9a /src/time/time_test.go | |
parent | a682a5c711097378a72e6cf3d498832e813a14e8 (diff) | |
download | go-9465878114232d4a9cd755fee9241fff1d63bbea.tar.gz go-9465878114232d4a9cd755fee9241fff1d63bbea.zip |
time: fix zoneinfo.zip locating logic when built with -trimpath
When the test binary is built with the -trimpath flag,
runtime.GOROOT() is invalid, and must not be used to locate
GOROOT/lib/time/zoneinfo.zip. (We can use other sources instead.)
However, the test for the package expects zoneinfo.zip to definitely
exist. 'go test' runs the test binary in the directory containing its
source code — in this case GOROOT/src/time — so we can use that
information to find the zoneinfo.zip file when runtime.GOROOT isn't
available.
For #51483
Change-Id: I9de35252a988d146b5d746794323214d400e64e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/391814
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/time/time_test.go')
-rw-r--r-- | src/time/time_test.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/time/time_test.go b/src/time/time_test.go index 6a4049617c..ea13ffe3c9 100644 --- a/src/time/time_test.go +++ b/src/time/time_test.go @@ -1557,8 +1557,8 @@ func TestConcurrentTimerResetStop(t *testing.T) { } func TestTimeIsDST(t *testing.T) { - ForceZipFileForTesting(true) - defer ForceZipFileForTesting(false) + undo := DisablePlatformSources() + defer undo() tzWithDST, err := LoadLocation("Australia/Sydney") if err != nil { @@ -1619,8 +1619,8 @@ func TestTimeAddSecOverflow(t *testing.T) { // Issue 49284: time: ParseInLocation incorrectly because of Daylight Saving Time func TestTimeWithZoneTransition(t *testing.T) { - ForceZipFileForTesting(true) - defer ForceZipFileForTesting(false) + undo := DisablePlatformSources() + defer undo() loc, err := LoadLocation("Asia/Shanghai") if err != nil { |