From 7595e453b0bcc02e2f311f9fe2f9f517a530f18f Mon Sep 17 00:00:00 2001 From: st0012 Date: Tue, 7 Jun 2022 23:31:26 +0100 Subject: [PATCH 1/3] Avoid using Exception#inspect Main reason: if https://github.com/ruby/ruby/pull/4857 is implemented, using `#inspect` will lose the newlines from the formatted message. Another reason: test frameworks usually fetch exceptions' class name and message separately to compose the full message, instead of just calling `#inspect`. So our test framework should be implemented similarly. --- test/support/console_test_case.rb | 2 +- test/support/protocol_test_case.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/support/console_test_case.rb b/test/support/console_test_case.rb index 79d774129..006ad7038 100644 --- a/test/support/console_test_case.rb +++ b/test/support/console_test_case.rb @@ -92,7 +92,7 @@ def debug_code(program, remote: true, &test_steps) end rescue Exception => e th.each(&:kill) - flunk e.inspect + flunk "#{e.class.name}: #{e.message}" end elsif remote && !NO_REMOTE debug_code_on_local diff --git a/test/support/protocol_test_case.rb b/test/support/protocol_test_case.rb index 54cf783cd..0e654e881 100644 --- a/test/support/protocol_test_case.rb +++ b/test/support/protocol_test_case.rb @@ -483,7 +483,7 @@ def send_request command, **kw params: kw end rescue StandardError => e - flunk create_protocol_message "Failed to send request because of #{e.inspect}" + flunk create_protocol_message "Failed to send request because of #{e.class.name}: #{e.message}" end def send_dap_request command, **kw From 3896db05af16e8e0938b749e4b3f694f5c1db3ed Mon Sep 17 00:00:00 2001 From: st0012 Date: Thu, 9 Jun 2022 10:39:03 +0100 Subject: [PATCH 2/3] Avoid matching exception message with format info This will avoid tests from failing because of format changes like https://github.com/ruby/ruby/pull/4857 --- test/console/debugger_local_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/console/debugger_local_test.rb b/test/console/debugger_local_test.rb index 4c803e3ab..08e7d73ac 100644 --- a/test/console/debugger_local_test.rb +++ b/test/console/debugger_local_test.rb @@ -34,7 +34,7 @@ def test_raised_is_accessible_from_repl type "catch Exception" type "c" type "_raised" - assert_line_text(/# Date: Tue, 5 Jul 2022 10:41:29 +0100 Subject: [PATCH 3/3] Fix record test --- test/console/record_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/console/record_test.rb b/test/console/record_test.rb index 8a9a6947f..bdd402576 100644 --- a/test/console/record_test.rb +++ b/test/console/record_test.rb @@ -139,18 +139,18 @@ def test_1629263892 end end - class RecordOnAfterStoppingOnceTest < TestCase + class RecordOnAfterStoppingOnceTest < ConsoleTestCase def program <<~RUBY 1| a=1 - 2| + 2| 3| b=1 - 4| + 4| 5| c=1 6| p a RUBY end - + def test_1656237686 debug_code(program) do type 'record on'