Skip to content

Commit 8dffad4

Browse files
committed
Display an accurate message when the test fails
Currently, the message when the test fails is overridden by a test that checks if the remote debuggee is terminated. For example, when `assert_line_text` method is failed, the message should be `Expected to include ~ in ~`, but it will be overridden and the message will be `Expected the remote program to finish ~`. We should not assert in ensure block to prevent the problem.
1 parent 0caebcc commit 8dffad4

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

test/support/console_test_case.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ def run_test_scenario cmd, test_info
176176
check_error(/DEBUGGEE Exception/, test_info)
177177
assert_empty_queue test_info
178178
end
179+
180+
if r = test_info.remote_info
181+
assert_program_finish test_info, r.pid, :debuggee
182+
end
183+
184+
assert_program_finish test_info, pid, :debugger
179185
# result of `gets` return this exception in some platform
180186
# https://github.com/ruby/ruby/blob/master/ext/pty/pty.c#L729-L736
181187
rescue Errno::EIO => e
@@ -189,13 +195,16 @@ def run_test_scenario cmd, test_info
189195
read.close
190196
write.close
191197
kill_safely pid, :debugger, test_info
192-
if name = test_info.failed_process
193-
assert_block(create_message("Expected the #{name} program to finish", test_info)) { false }
194-
end
195198
end
196199
end
197200
end
198201

202+
def assert_program_finish test_info, pid, name
203+
unless wait_pid pid, TIMEOUT_SEC
204+
assert_block(create_message("Expected the #{name} program to finish", test_info)) { false }
205+
end
206+
end
207+
199208
def prepare_test_environment(program, test_steps, &block)
200209
ENV['RUBY_DEBUG_NO_COLOR'] = 'true'
201210
ENV['RUBY_DEBUG_TEST_UI'] = 'terminal'

test/support/test_case.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ def wait_pid pid, sec
118118
end
119119

120120
false
121+
rescue Errno::ECHILD
122+
true
121123
end
122124

123125
def kill_safely pid, name, test_info

0 commit comments

Comments
 (0)