Skip to content

Add the new test framework for DAP and CDP - #547

Merged
ko1 merged 8 commits into
ruby:masterfrom
ono-max:patch-53
Mar 8, 2022
Merged

Add the new test framework for DAP and CDP#547
ko1 merged 8 commits into
ruby:masterfrom
ono-max:patch-53

Conversation

@ono-max

@ono-maxono-max commented Feb 22, 2022

Copy link
Copy Markdown
Member

This test framework is designed to test both DAP and CDP for a single method.

Example

# frozen_string_literal: truerequire_relative'../support/test_case'moduleDEBUGGER__classBreakTest < TestCasePROGRAM=<<~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 RUBYdeftest_break1run_protocol_scenarioPROGRAMdoreq_set_breakpoints5req_set_breakpoints8req_continueassert_line_num5req_continueassert_line_num8req_terminate_debuggeeendendendend

API

  • run_protocol_scenario program, dap: true, cdp: true, &scenario

Execute debugging program with &scenario. If you want to test it only for DAP, you can write as follows:

run_protocol_scenario program, cdp: false ...

  • req_add_breakpoint(lineno, path: temp_file_path, cond: nil)

Sends request to rdbg to add a breakpoint.

  • req_delete_breakpoint bpnum

Sends request to rdbg to delete a breakpoint.

  • req_set_exception_breakpoints

Sends request to rdbg to set exception breakpoints.

  • req_continue

Sends request to rdbg to resume the program.

  • req_step

Sends request to rdbg to step into next method.

  • req_next

Sends request to rdbg to step over next method.

  • req_finish

Sends request to rdbg to step out of current method.

  • req_step_back

Sends request to rdbg to step back from current method.

  • req_terminate_debuggee

Sends request to rdbg to terminate the debuggee.

  • assert_reattach

Passes if reattaching to rdbg is successful.

  • assert_hover_result(expected, expression: nil)

Passes if result of expression is equal to expected.

  • assert_repl_result(expected, expression: nil)

Passes if result of expression is equal to expected.

  • assert_watch_result(expected, expression: nil)

Passes if result of expression is equal to expected.

  • assert_line_num(expected)

Passes if expected is equal to the location where debugger stops.

@ono-maxono-max changed the title Patch 53Add the new test framework for DAPFeb 22, 2022
@ono-max
ono-maxforce-pushed the patch-53 branch 6 times, most recently from 2057cbc to 11336fbCompareFebruary 28, 2022 11:18
@ono-max
ono-max marked this pull request as ready for review February 28, 2022 11:18
@ono-max
ono-maxforce-pushed the patch-53 branch 3 times, most recently from fa3a58d to eaadd92CompareFebruary 28, 2022 12:47
@st0012

Copy link
Copy Markdown
Member

@ono-max the new APIs look amazing! Thanks for the great work 🎉

Comment threadtest/support/protocol_utils.rb Outdated
last_msg = @backlog.reverse[0..3].map{|m|
h = m.sub(/(D|V)(<|>)(D|V)\s/, '')
JSON.pretty_generate(JSON.parse h)
}.reverse.join("\n")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that this part may need a comment for explanation.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this part is complex.
I'll refactor the logic.

Comment threadtest/support/protocol_utils.rb Outdated
return if File.exist? DAP_JSON_PATH

json = Net::HTTP.get(URI.parse('https://microsoft.github.io/debug-adapter-protocol/debugAdapterProtocol.json'))
File.write DAP_JSON_PATH, json

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we store this file as a source of truth? From this method, it looks like each developer and the CI could have different versions of the protocol if it's changed?
If we want to keep up with the latest protocol, we can have a CI action comparing the project's version and the latest version.

@ono-maxono-maxMar 3, 2022

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to keep up with the latest protocol, we can have a CI action comparing the project's version and the latest version.

Yes, I want to keep up with the latest version, but requesting every time is all I can come up with now.

@ono-max
ono-max marked this pull request as draft March 5, 2022 08:14
@ono-max
ono-maxforce-pushed the patch-53 branch 2 times, most recently from 7f62889 to 49f2b08CompareMarch 5, 2022 10:09
@ono-max
ono-maxforce-pushed the patch-53 branch 3 times, most recently from 21ae0c2 to 2ca6ef3CompareMarch 6, 2022 13:06
@ono-maxono-max changed the title Add the new test framework for DAPAdd the new test framework for DAP and CDPMar 6, 2022
@ono-max
ono-maxforce-pushed the patch-53 branch 5 times, most recently from 64e4d4a to 6da7a15CompareMarch 8, 2022 02:29
@ono-max
ono-max marked this pull request as ready for review March 8, 2022 04:25
@ko1
ko1 merged commit 2c6a941 into ruby:masterMar 8, 2022
@ono-max
ono-max deleted the patch-53 branch March 8, 2022 22:28
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@ono-max@st0012@ko1