Skip to content

Commit e9641de

Browse files
committed
Fix flaky progress elapsed time test
Use a fixed base value (100.0) instead of the real monotonic clock when stubbing Process.clock_gettime. With large clock values on long-running CI machines, float-precision errors in (now + 65.0) - now can produce a result slightly above 65.0, and .ceil rounds it to 66, causing "1m 6s" instead of the expected "1m 5s".
1 parent aacc7ec commit e9641de

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

spec/data_customs/migration_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def verify! = nil
144144
end
145145

146146
it "shows ETA after enough time has elapsed" do
147-
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
147+
now = 100.0
148148
# ProgressReporter.new, report(25) eta + throttle, report(50) eta + throttle
149149
allow(Process).to receive(:clock_gettime).and_return(now, now, now, now + 5.0, now + 5.0)
150150

@@ -163,7 +163,8 @@ def verify! = nil
163163
end
164164

165165
it "shows elapsed time at 100%" do
166-
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
166+
# Use a fixed base to avoid float-precision errors with large clock values
167+
now = 100.0
167168
# first call is from ProgressReporter.new, then report(50) at +0, report(100) at +65
168169
allow(Process).to receive(:clock_gettime).and_return(now, now, now + 65.0)
169170

0 commit comments

Comments
 (0)