summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-04-28 14:39:37 +0200
committerBenoit Daloze <eregontp@gmail.com>2019-04-28 14:44:12 +0200
commit13abf5519a8c00ac2b05409e667c58f05c75123a (patch)
tree837b3dc1bbb947de5e58d207cb84e82c9b6b0d0e
parent14965c5f4b0160d22febd94f258b2ba1491a585e (diff)
Workaround a CentOS bug in Process.clock_getres specs
-rw-r--r--spec/ruby/core/process/clock_getres_spec.rb32
1 files changed, 18 insertions, 14 deletions
diff --git a/spec/ruby/core/process/clock_getres_spec.rb b/spec/ruby/core/process/clock_getres_spec.rb
index dc78fc4c88..5e5eb0246c 100644
--- a/spec/ruby/core/process/clock_getres_spec.rb
+++ b/spec/ruby/core/process/clock_getres_spec.rb
@@ -11,20 +11,24 @@ describe "Process.clock_getres" do
end
reported = Process.clock_getres(value, :nanosecond)
- # The clock should not be more accurate than reported (times should be
- # a multiple of reported precision.)
- times.select { |t| t % reported > 0 }.should be_empty
-
- # We're assuming precision is a multiple of ten - it may or may not
- # be an incompatibility if it isn't but we'd like to notice this,
- # and the spec following these wouldn't work if it isn't.
- reported.should > 0
- (reported == 1 || reported % 10 == 0).should be_true
-
- # The clock should not be less accurate than reported (times should
- # not all be a multiple of the next precision up, assuming precisions
- # are multiples of ten.)
- times.select { |t| t % (reported * 10) == 0 }.size.should_not == times.size
+ # CentOS seems to report a negative resolution:
+ # https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos6/ruby-trunk/log/20190428T093004Z.fail.html.gz
+ unless name == :CLOCK_MONOTONIC_RAW and reported < 0
+ # The clock should not be more accurate than reported (times should be
+ # a multiple of reported precision.)
+ times.select { |t| t % reported > 0 }.should be_empty
+
+ # We're assuming precision is a multiple of ten - it may or may not
+ # be an incompatibility if it isn't but we'd like to notice this,
+ # and the spec following these wouldn't work if it isn't.
+ reported.should > 0
+ (reported == 1 || reported % 10 == 0).should be_true
+
+ # The clock should not be less accurate than reported (times should
+ # not all be a multiple of the next precision up, assuming precisions
+ # are multiples of ten.)
+ times.select { |t| t % (reported * 10) == 0 }.size.should_not == times.size
+ end
end
end
end