]> Cypherpunks repositories - gostls13.git/commit
time: fix zoneinfo.zip locating logic when built with -trimpath
authorBryan C. Mills <bcmills@google.com>
Thu, 10 Mar 2022 05:19:05 +0000 (00:19 -0500)
committerBryan Mills <bcmills@google.com>
Fri, 18 Mar 2022 20:57:35 +0000 (20:57 +0000)
commit9465878114232d4a9cd755fee9241fff1d63bbea
tree6b3e413343335618bbef322516584eacc697ef9a
parenta682a5c711097378a72e6cf3d498832e813a14e8
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>
17 files changed:
src/time/export_android_test.go
src/time/export_test.go
src/time/format_test.go
src/time/internal_test.go
src/time/time_test.go
src/time/tzdata_test.go
src/time/zoneinfo.go
src/time/zoneinfo_android.go
src/time/zoneinfo_android_test.go
src/time/zoneinfo_goroot.go [new file with mode: 0644]
src/time/zoneinfo_ios.go
src/time/zoneinfo_js.go
src/time/zoneinfo_plan9.go
src/time/zoneinfo_read.go
src/time/zoneinfo_test.go
src/time/zoneinfo_unix.go
src/time/zoneinfo_windows.go