From 763c219539d76be22e589e6a5faf2d6e8937fcfc Mon Sep 17 00:00:00 2001 From: Jonathan Hefner Date: Tue, 30 Nov 2021 14:03:32 -0600 Subject: [PATCH] Fix flakey test in notifications_test.rb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Example failure: https://buildkite.com/rails/rails/builds/82905#80d6c6ec-943d-4ba3-b360-1ef6c4aa5d89/1012-1022 The test designates the event end time as 0.01 seconds (i.e. 10 milliseconds) after the start time. It then asserts that the event duration is 10 ± 0.0001 milliseconds. This sometimes fails due to floating point precision errors. This commit changes the assertion to instead check that the duration is within 1% of the expected value. --- activesupport/test/notifications_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index 645789977a..7877967ee0 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -438,7 +438,7 @@ module Notifications event = event(:foo, time, time + 0.01, random_id, {}) assert_equal :foo, event.name - assert_in_delta 10.0, event.duration, 0.0001 + assert_in_epsilon 10.0, event.duration, 0.01 end def test_event_cpu_time_does_not_raise_error_when_start_or_finished_not_called