]>
Commit | Line | Data |
---|---|---|
2a683cca JP |
1 | From edce31a2904846ae74e3c011f2cf5fddc963459e Mon Sep 17 00:00:00 2001 |
2 | From: =?UTF-8?q?Jakub=20=C4=8Cajka?= <jcajka@redhat.com> | |
3 | Date: Thu, 22 Mar 2018 12:07:32 +0100 | |
4 | Subject: [PATCH 1/3] Don't use the bundled tzdata at runtime, except for the | |
5 | internal test suite | |
6 | ||
7 | --- | |
8 | src/time/internal_test.go | 7 +++++-- | |
9 | src/time/zoneinfo_test.go | 3 ++- | |
10 | src/time/zoneinfo_unix.go | 2 -- | |
11 | 3 files changed, 7 insertions(+), 5 deletions(-) | |
12 | ||
13 | diff --git a/src/time/internal_test.go b/src/time/internal_test.go | |
14 | index 76d5524124..e81ace5f64 100644 | |
15 | --- a/src/time/internal_test.go | |
16 | +++ b/src/time/internal_test.go | |
17 | @@ -4,13 +4,15 @@ | |
18 | ||
19 | package time | |
20 | ||
21 | +import "runtime" | |
22 | + | |
23 | func init() { | |
24 | // force US/Pacific for time zone tests | |
25 | ForceUSPacificForTesting() | |
26 | } | |
27 | ||
28 | func initTestingZone() { | |
29 | - z, err := loadLocation("America/Los_Angeles", zoneSources[len(zoneSources)-1:]) | |
30 | + z, err := loadLocation("America/Los_Angeles", zoneSources) | |
31 | if err != nil { | |
32 | panic("cannot load America/Los_Angeles for testing: " + err.Error()) | |
33 | } | |
34 | @@ -21,8 +23,9 @@ func initTestingZone() { | |
35 | var OrigZoneSources = zoneSources | |
36 | ||
37 | func forceZipFileForTesting(zipOnly bool) { | |
38 | - zoneSources = make([]string, len(OrigZoneSources)) | |
39 | + zoneSources = make([]string, len(OrigZoneSources)+1) | |
40 | copy(zoneSources, OrigZoneSources) | |
41 | + zoneSources = append(zoneSources, runtime.GOROOT()+"/lib/time/zoneinfo.zip") | |
42 | if zipOnly { | |
43 | zoneSources = zoneSources[len(zoneSources)-1:] | |
44 | } | |
45 | diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go | |
46 | index 7a55d4f618..6063ca1195 100644 | |
47 | --- a/src/time/zoneinfo_test.go | |
48 | +++ b/src/time/zoneinfo_test.go | |
49 | @@ -8,6 +8,7 @@ import ( | |
50 | "fmt" | |
51 | "os" | |
52 | "reflect" | |
53 | + "runtime" | |
54 | "testing" | |
55 | "time" | |
56 | ) | |
57 | @@ -128,7 +129,7 @@ func TestLoadLocationFromTZData(t *testing.T) { | |
58 | t.Fatal(err) | |
59 | } | |
60 | ||
61 | - tzinfo, err := time.LoadTzinfo(locationName, time.OrigZoneSources[len(time.OrigZoneSources)-1]) | |
62 | + tzinfo, err := time.LoadTzinfo(locationName, runtime.GOROOT()+"/lib/time/zoneinfo.zip") | |
63 | if err != nil { | |
64 | t.Fatal(err) | |
65 | } | |
66 | diff --git a/src/time/zoneinfo_unix.go b/src/time/zoneinfo_unix.go | |
67 | index 88313aa0ed..d9596115ef 100644 | |
68 | --- a/src/time/zoneinfo_unix.go | |
69 | +++ b/src/time/zoneinfo_unix.go | |
70 | @@ -12,7 +12,6 @@ | |
71 | package time | |
72 | ||
73 | import ( | |
74 | - "runtime" | |
75 | "syscall" | |
76 | ) | |
77 | ||
78 | @@ -22,7 +21,6 @@ var zoneSources = []string{ | |
79 | "/usr/share/zoneinfo/", | |
80 | "/usr/share/lib/zoneinfo/", | |
81 | "/usr/lib/locale/TZ/", | |
82 | - runtime.GOROOT() + "/lib/time/zoneinfo.zip", | |
83 | } | |
84 | ||
85 | func initLocal() { | |
86 | -- | |
87 | 2.14.3 | |
88 |