Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 94ea9d1

Browse files
yahondaclaude
andcommitted
Stabilize say_with_time regression tests
Both `say_with_time` regression tests asserted the literal `0.0000s` elapsed-time string, which holds only when the block finishes within the `%.4f` half-rounding threshold (~50µs). On rails-nightly Buildkite build 4288 the block took 0.0001s–0.0002s, so the assertions failed on both the mysql2 and postgresql runs: ``` 3) Failure: MigrationTest#test_migration_say_with_time_with_integer_returning_in_block [test/cases/migration_test.rb:1177]: expected actual @@ -1,4 +1,4 @@ "-- Bar - -> 0.0000s + -> 0.0001s -> 123 rows " 4) Failure: MigrationTest#test_migration_say_with_time_with_non_integer_returning_in_block [test/cases/migration_test.rb:1191]: expected actual @@ -1,3 +1,3 @@ "-- Bar - -> 0.0000s + -> 0.0001s " ``` - activerecord-mysql2-yjit: https://buildkite.com/rails/rails-nightly/builds/4288/list?jid=019e420a-5a01-4ecf-97fc-731926c3b2dd&tab=output#L11079 - activerecord-postgresql-yjit: https://buildkite.com/rails/rails-nightly/builds/4288/list?jid=019e420a-5a02-4c26-a23c-2102d092ccee&tab=output#L11794 Switch to `assert_match` with anchored regexes that pin the format (header line, subitem indent, 4-decimal `%.4f`, trailing `s`, optional row count, trailing newlines) while tolerating timing jitter. Follow up #45705 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent d18739b commit 94ea9d1

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

activerecord/test/cases/migration_test.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,11 +1174,7 @@ def test_migration_say_with_time_with_integer_returning_in_block
11741174
end
11751175
end
11761176

1177-
assert_equal <<~MSG, output
1178-
-- Bar
1179-
-> 0.0000s
1180-
-> 123 rows
1181-
MSG
1177+
assert_match(/\A-- Bar\n -> \d+\.\d{4}s\n -> 123 rows\n\z/, output)
11821178
end
11831179

11841180
def test_migration_say_with_time_with_non_integer_returning_in_block
@@ -1188,10 +1184,7 @@ def test_migration_say_with_time_with_non_integer_returning_in_block
11881184
end
11891185
end
11901186

1191-
assert_equal <<~MSG, output
1192-
-- Bar
1193-
-> 0.0000s
1194-
MSG
1187+
assert_match(/\A-- Bar\n -> \d+\.\d{4}s\n\z/, output)
11951188
end
11961189

11971190
private

0 commit comments

Comments
 (0)