-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for trace inspector and record inspector
- Loading branch information
Showing
4 changed files
with
289 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../support/protocol_test_case' | ||
|
||
module DEBUGGER__ | ||
class RdbgRecordInspectorTest < ProtocolTestCase | ||
PROGRAM = <<~RUBY | ||
1| module Foo | ||
2| class Bar | ||
3| def self.a | ||
4| "hello" | ||
5| end | ||
6| end | ||
7| Bar.a | ||
8| bar = Bar.new | ||
9| end | ||
RUBY | ||
|
||
def test_defaut_setting | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["recordInspector"] | ||
run_protocol_scenario(PROGRAM, cdp: false) do | ||
req_rdbgRecordInspector_enable | ||
req_add_breakpoint 5 | ||
req_continue | ||
assert_rdbgRecordInspector_collect_result( | ||
[ | ||
{ | ||
name: "<module:Foo>", | ||
location: { | ||
line: 2, | ||
} | ||
}, | ||
{ | ||
name: "<class:Bar>", | ||
location: { | ||
line: 3, | ||
} | ||
} | ||
] | ||
) | ||
req_rdbgRecordInspector_step_back 4 | ||
assert_line_num 2 | ||
req_rdbgRecordInspector_step 1 | ||
assert_line_num 3 | ||
req_terminate_debuggee | ||
end | ||
ensure | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension | ||
end | ||
|
||
def test_restart_trace | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["recordInspector"] | ||
run_protocol_scenario(PROGRAM, cdp: false) do | ||
req_rdbgRecordInspector_enable | ||
req_rdbgRecordInspector_disable | ||
req_rdbgRecordInspector_enable | ||
req_add_breakpoint 5 | ||
req_continue | ||
assert_rdbgRecordInspector_collect_result( | ||
[ | ||
{ | ||
name: "<module:Foo>", | ||
location: { | ||
line: 2, | ||
} | ||
}, | ||
{ | ||
name: "<class:Bar>", | ||
location: { | ||
line: 3, | ||
} | ||
} | ||
] | ||
) | ||
req_rdbgRecordInspector_step_back 4 | ||
assert_line_num 2 | ||
req_rdbgRecordInspector_step 1 | ||
assert_line_num 3 | ||
req_terminate_debuggee | ||
end | ||
ensure | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../support/protocol_test_case' | ||
|
||
module DEBUGGER__ | ||
class RdbgTraceInspectorTest < ProtocolTestCase | ||
PROGRAM = <<~RUBY | ||
1| def foo | ||
2| 'bar' | ||
3| end | ||
4| foo | ||
5| foo | ||
RUBY | ||
|
||
def test_defaut_setting | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"] | ||
run_protocol_scenario(PROGRAM, cdp: false) do | ||
req_rdbgTraceInspector_enable | ||
req_add_breakpoint 5 | ||
req_continue | ||
assert_rdbgTraceInspector_collect_result( | ||
[ | ||
{ | ||
returnValue: "\"bar\"", | ||
name: 'Object#foo', | ||
location: { | ||
line: 3, | ||
} | ||
}, | ||
{ | ||
name: 'Object#foo', | ||
location: { | ||
line: 1, | ||
} | ||
}, | ||
{ | ||
location: { | ||
line: 4, | ||
} | ||
}, | ||
] | ||
) | ||
req_terminate_debuggee | ||
end | ||
ensure | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension | ||
end | ||
|
||
def test_call_event | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"] | ||
run_protocol_scenario(PROGRAM, cdp: false) do | ||
req_rdbgTraceInspector_enable(events: ['call']) | ||
req_add_breakpoint 5 | ||
req_continue | ||
assert_rdbgTraceInspector_collect_result( | ||
[ | ||
{ | ||
name: 'Object#foo', | ||
location: { | ||
line: 1, | ||
} | ||
}, | ||
] | ||
) | ||
req_terminate_debuggee | ||
end | ||
ensure | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension | ||
end | ||
|
||
def test_return_event | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"] | ||
run_protocol_scenario(PROGRAM, cdp: false) do | ||
req_rdbgTraceInspector_enable(events: ['return']) | ||
req_add_breakpoint 5 | ||
req_continue | ||
assert_rdbgTraceInspector_collect_result( | ||
[ | ||
{ | ||
returnValue: "\"bar\"", | ||
name: 'Object#foo', | ||
location: { | ||
line: 3, | ||
} | ||
}, | ||
] | ||
) | ||
req_terminate_debuggee | ||
end | ||
ensure | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension | ||
end | ||
|
||
def test_line_event | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"] | ||
run_protocol_scenario(PROGRAM, cdp: false) do | ||
req_rdbgTraceInspector_enable(events: ['line']) | ||
req_add_breakpoint 5 | ||
req_continue | ||
assert_rdbgTraceInspector_collect_result( | ||
[ | ||
{ | ||
location: { | ||
line: 4, | ||
} | ||
}, | ||
] | ||
) | ||
req_terminate_debuggee | ||
end | ||
ensure | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension | ||
end | ||
|
||
def test_restart_trace | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"] | ||
run_protocol_scenario(PROGRAM, cdp: false) do | ||
req_rdbgTraceInspector_enable | ||
req_rdbgTraceInspector_disable | ||
req_rdbgTraceInspector_enable(events: ['line']) | ||
req_add_breakpoint 5 | ||
req_continue | ||
assert_rdbgTraceInspector_collect_result( | ||
[ | ||
{ | ||
location: { | ||
line: 4, | ||
} | ||
}, | ||
] | ||
) | ||
req_terminate_debuggee | ||
end | ||
ensure | ||
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters