Skip to content

Commit 790c9c5

Browse files
committed
Increase assert_output timeout for FullStackConsoleTest and ApplicationTests::ServerTest
This commit addresses the following failures at Rails Nightly CI with assertion enabled Ruby. that has been built with `cppflags="-DENABLE_PATH_CHECK=0 -DRUBY_DEBUG=1" optflags="-O3 -fno-inline"` https://buildkite.com/rails/rails-nightly/builds/191#018dc3d1-9032-4baa-ae8a-3c630889ab5f/1342-1348 https://buildkite.com/rails/rails-nightly/builds/191#018dc3d1-9033-4c0c-b61c-00f26d3a63fb/1198-1204 Related to rails#51140 - Failures fixed by this commit: ``` $ ruby -v ruby 3.4.0dev (2024-02-20T11:52:09Z master c22cb960cf) [x86_64-linux] $ bin/test test/application/console_test.rb -n test_sandbox Run options: -n test_sandbox --seed 3666 F Failure: FullStackConsoleTest#test_sandbox [test/console_helpers.rb:19]: "=> 0" expected, but got: app-template(dev)> quapp-template(dev)> quiapp-template(dev)> quit. Expected "\r\napp-template(dev)> quapp-template(dev)> quiapp-template(dev)> quit" to include "=> 0". bin/test test/application/console_test.rb:142 Finished in 32.180314s, 0.0311 runs/s, 0.7458 assertions/s. 1 runs, 24 assertions, 1 failures, 0 errors, 0 skips $ ``` ``` $ bin/test test/application/server_test.rb Run options: --seed 64559 F Failure: ApplicationTests::ServerTest#test_restart_rails_server_with_custom_pid_file_path [test/console_helpers.rb:19]: "Listening" expected, but got: . Expected "" to include "Listening". bin/test test/application/server_test.rb:19 F Failure: ApplicationTests::ServerTest#test_run_+server+_blocks_after_the_server_starts [test/console_helpers.rb:19]: "Hello world" expected, but got: . Expected "" to include "Hello world". bin/test test/application/server_test.rb:43 Finished in 2.117413s, 0.9445 runs/s, 1.8891 assertions/s. 2 runs, 4 assertions, 2 failures, 0 errors, 0 skips $ ``` Note: These failures depend on assert_timeout and test environment. If these failures do not reproduce locally, setting short timeout = 1 should reproduce them. ``` $ git diff diff --git a/railties/test/console_helpers.rb b/railties/test/console_helpers.rb index 10d3a54..32d333ed99 100644 --- a/railties/test/console_helpers.rb +++ b/railties/test/console_helpers.rb @@ -6,7 +6,7 @@ end module ConsoleHelpers - def assert_output(expected, io, timeout = 10) + def assert_output(expected, io, timeout = 1) timeout = Time.now + timeout output = +"" $ ```
1 parent 51ce412 commit 790c9c5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

railties/test/application/console_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def teardown
121121
def write_prompt(command, expected_output = nil)
122122
@primary.puts command
123123
assert_output command, @primary
124-
assert_output expected_output, @primary if expected_output
124+
assert_output expected_output, @primary, 100 if expected_output
125125
assert_output "> ", @primary
126126
end
127127

railties/test/application/server_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def teardown
2929

3030
Bundler.with_original_env do
3131
pid = Process.spawn("bin/rails server -b localhost -P tmp/dummy.pid", chdir: app_path, in: replica, out: replica, err: replica)
32-
assert_output("Listening", primary)
32+
assert_output("Listening", primary, 100)
3333

3434
rails("restart")
3535

36-
assert_output("Restarting", primary)
37-
assert_output("Listening", primary)
36+
assert_output("Restarting", primary, 100)
37+
assert_output("Listening", primary, 100)
3838
ensure
3939
kill(pid) if pid
4040
end
@@ -59,8 +59,8 @@ def teardown
5959

6060
Bundler.with_original_env do
6161
pid = Process.spawn("bin/rails server -b localhost", chdir: app_path, in: replica, out: primary, err: replica)
62-
assert_output("Hello world", primary)
63-
assert_output("Listening", primary)
62+
assert_output("Hello world", primary, 100)
63+
assert_output("Listening", primary, 100)
6464
ensure
6565
kill(pid) if pid
6666
end

0 commit comments

Comments
 (0)