Skip to content

Commit 2154375

Browse files
committed
Avoid raising debuggee not finished error if assertions failed
When assertions failed, we should let the AssertionFailedError surface and not calling flunk so we can get correct failure messages.
1 parent a9bec25 commit 2154375

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

test/support/protocol_test_case.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,12 @@ def execute_dap_scenario scenario
334334

335335
attach_to_dap_server
336336
scenario.call
337+
rescue Test::Unit::AssertionFailedError => e
338+
is_assertion_failure = true
339+
raise e
337340
ensure
338341
kill_remote_debuggee test_info
339-
if test_info.failed_process
342+
if test_info.failed_process && !is_assertion_failure
340343
flunk create_protocol_message "Expected the debuggee program to finish"
341344
end
342345
# Because the debuggee may be terminated by executing the following operations, we need to run them after `kill_remote_debuggee` method.
@@ -365,9 +368,12 @@ def execute_cdp_scenario_ scenario
365368
res = find_response :method, 'Debugger.paused', 'C<D'
366369
@crt_frames = res.dig(:params, :callFrames)
367370
scenario.call
371+
rescue Test::Unit::AssertionFailedError => e
372+
is_assertion_failure = true
373+
raise e
368374
ensure
369375
kill_remote_debuggee test_info
370-
if test_info.failed_process
376+
if test_info.failed_process && !is_assertion_failure
371377
flunk create_protocol_message "Expected the debuggee program to finish"
372378
end
373379
# Because the debuggee may be terminated by executing the following operations, we need to run them after `kill_remote_debuggee` method.

test/support/protocol_test_case_test.rb

+21-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,29 @@
33
require_relative 'protocol_test_case'
44

55
module DEBUGGER__
6-
class TestFrameworkTestHOge < ProtocolTestCase
7-
PROGRAM = <<~RUBY
8-
1| a=1
9-
RUBY
10-
6+
class TestProtocolTestCase < ProtocolTestCase
117
def test_the_test_fails_when_debuggee_doesnt_exit
8+
program = <<~RUBY
9+
1| a=1
10+
RUBY
11+
1212
assert_fail_assertion do
13-
run_protocol_scenario PROGRAM do
13+
run_protocol_scenario program do
14+
end
15+
end
16+
end
17+
18+
def test_the_assertion_failure_takes_presedence_over_debuggee_not_exiting
19+
program = <<~RUBY
20+
1| a = 2
21+
2| b = 3
22+
RUBY
23+
24+
assert_raise_message(/<\"100\"> expected but was/) do
25+
run_protocol_scenario program do
26+
req_add_breakpoint 2
27+
req_continue
28+
assert_repl_result({value: '100', type: 'Integer'}, 'a')
1429
end
1530
end
1631
end

0 commit comments

Comments
 (0)