mirror of
https://github.com/golang/go
synced 2024-11-22 19:24:59 -07:00
9465878114
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 lines
438 B
Go
17 lines
438 B
Go
// Copyright 2016 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package time
|
|
|
|
func ForceAndroidTzdataForTest() (undo func()) {
|
|
allowGorootSource = false
|
|
origLoadFromEmbeddedTZData := loadFromEmbeddedTZData
|
|
loadFromEmbeddedTZData = nil
|
|
|
|
return func() {
|
|
allowGorootSource = true
|
|
loadFromEmbeddedTZData = origLoadFromEmbeddedTZData
|
|
}
|
|
}
|