[commit: packages/time] master: Regression test for getTimeZone. (27173fc)
git at git.haskell.org
git at git.haskell.org
Sun Dec 20 07:54:26 UTC 2015
Repository : ssh://git@git.haskell.org/time
On branch : master
Link : http://git.haskell.org/packages/time.git/commitdiff/27173fcefbcaf8d699a3929585758597191ca313
>---------------------------------------------------------------
commit 27173fcefbcaf8d699a3929585758597191ca313
Author: oconnorr <oconnorr at google.com>
Date: Fri Jun 14 12:19:45 2013 -0700
Regression test for getTimeZone.
Ignore-this: e113a43c80f89126aa12b2fdcd73ae9f
The localtime_r call made from getTimeZone may or may not perform a tzset().
In particular, in glibc, a tzset() will only be performed the first time a process runs localtime_r.
This added regression test will fail on implementations like glibc that only
perform a tzset() on the first call to localtime_r.
A fix to make getTimeZone always call tzset() can be found in patch:
[Make getTimeZone cross-platform consistent by always considering the TZ environment variable.
oconnorr at google.com**20130610222254
darcs-hash:20130614191945-a4c94-8b89e390a71d3b46bf56997ad103bec7a5144f13
>---------------------------------------------------------------
27173fcefbcaf8d699a3929585758597191ca313
Test/TestTimeZone.hs | 17 +++++++++++++++++
Test/Tests.hs | 4 +++-
time.cabal | 5 +++--
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/Test/TestTimeZone.hs b/Test/TestTimeZone.hs
new file mode 100644
index 0000000..8e79baa
--- /dev/null
+++ b/Test/TestTimeZone.hs
@@ -0,0 +1,17 @@
+{-# OPTIONS -Wall -Werror #-}
+
+module Test.TestTimeZone where
+
+import Data.Time
+import System.Posix.Env (putEnv)
+import Test.TestUtil
+
+testTimeZone :: Test
+testTimeZone = ioTest "getTimeZone respects TZ env var" $ do
+ putEnv "TZ=UTC+0"
+ zone1 <- getTimeZone epoch
+ putEnv "TZ=EST+5"
+ zone2 <- getTimeZone epoch
+ return $ diff False (zone1 == zone2)
+ where
+ epoch = UTCTime (ModifiedJulianDay 0) 0
diff --git a/Test/Tests.hs b/Test/Tests.hs
index 512b64e..3900e45 100644
--- a/Test/Tests.hs
+++ b/Test/Tests.hs
@@ -13,6 +13,7 @@ import Test.TestMonthDay
import Test.TestParseDAT
import Test.TestParseTime
import Test.TestTime
+import Test.TestTimeZone
tests :: [Test]
tests = [ addDaysTest
@@ -25,4 +26,5 @@ tests = [ addDaysTest
, testMonthDay
, testParseDAT
, testParseTime
- , testTime ]
+ , testTime
+ , testTimeZone ]
diff --git a/time.cabal b/time.cabal
index 5e38d2a..e1f7d79 100644
--- a/time.cabal
+++ b/time.cabal
@@ -114,8 +114,9 @@ test-suite tests
old-locale,
process,
QuickCheck >= 2.5.1,
- test-framework >= 0.6.1,
- test-framework-quickcheck2 >= 0.2.12
+ test-framework >= 0.6.1 && < 0.7,
+ test-framework-quickcheck2 >= 0.2.12,
+ unix
main-is: Test.hs
other-modules:
Test.Tests
More information about the ghc-commits
mailing list