test_time_tz.rb: right timezone
* test/ruby/test_time_tz.rb (has_right_tz): check if right timezones are installed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2a0cca3c89
commit
7a666d95f7
@ -6,33 +6,39 @@ class TestTimeTZ < Test::Unit::TestCase
|
|||||||
force_tz_test = ENV["RUBY_FORCE_TIME_TZ_TEST"] == "yes"
|
force_tz_test = ENV["RUBY_FORCE_TIME_TZ_TEST"] == "yes"
|
||||||
case RUBY_PLATFORM
|
case RUBY_PLATFORM
|
||||||
when /linux/
|
when /linux/
|
||||||
# has_right_tz = false
|
|
||||||
force_tz_test = true
|
force_tz_test = true
|
||||||
when /darwin|freebsd/
|
when /darwin|freebsd/
|
||||||
has_right_tz = false
|
|
||||||
has_lisbon_tz = false
|
has_lisbon_tz = false
|
||||||
force_tz_test = true
|
force_tz_test = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if force_tz_test
|
if force_tz_test
|
||||||
def with_tz(tz)
|
module Util
|
||||||
old = ENV["TZ"]
|
def with_tz(tz)
|
||||||
begin
|
old = ENV["TZ"]
|
||||||
ENV["TZ"] = tz
|
begin
|
||||||
yield
|
ENV["TZ"] = tz
|
||||||
ensure
|
yield
|
||||||
ENV["TZ"] = old
|
ensure
|
||||||
|
ENV["TZ"] = old
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
def with_tz(tz)
|
module Util
|
||||||
if ENV["TZ"] == tz
|
def with_tz(tz)
|
||||||
yield
|
if ENV["TZ"] == tz
|
||||||
|
yield
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module Util
|
module Util
|
||||||
|
def have_tz_offset(tz)
|
||||||
|
with_tz(tz) {!Time.now.utc_offset.zero?}
|
||||||
|
end
|
||||||
|
|
||||||
def format_gmtoff(gmtoff, colon=false)
|
def format_gmtoff(gmtoff, colon=false)
|
||||||
if gmtoff < 0
|
if gmtoff < 0
|
||||||
expected = "-"
|
expected = "-"
|
||||||
@ -75,6 +81,9 @@ class TestTimeTZ < Test::Unit::TestCase
|
|||||||
include Util
|
include Util
|
||||||
extend Util
|
extend Util
|
||||||
|
|
||||||
|
has_right_tz &&= have_tz_offset("right/America/Los_Angeles")
|
||||||
|
has_lisbon_tz &&= have_tz_offset("Europe/Lisbon")
|
||||||
|
|
||||||
def time_to_s(t)
|
def time_to_s(t)
|
||||||
t.to_s
|
t.to_s
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user