Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a helper to start debug session with the test program #75

Merged
merged 2 commits into from
Jun 16, 2021

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jun 9, 2021

When writing tests, sometimes we may test the script manually. But currently this could take a few steps:

  1. Copy the test program into a file, say target.rb
  2. Remove all the line numbers.
  3. Run exe/rdbg -e target.rb from the terminal.

And whenever we change the script or switched to another test case, we need to go through these steps again.

So in the PR, I introduced a new helper called _start_manual_debug_session(program). You can place it in any test case:

def program
  # ....
end

def test_something_about_debugger
  _start_manual_debug_session(program) # just add this line
  debug_code(program) do
    # your original test code
  end
end

And then run the test case as you usually do, it'll enter a debug session with your test script 😄

截圖 2021-06-10 下午5 11 51

(btw, the remote debugging session is pretty neat. I love it 😍 )

@st0012 st0012 force-pushed the start-debug-session-with-test-program branch from 3a914c3 to 2eed8df Compare June 9, 2021 15:08
test/support/utils.rb Outdated Show resolved Hide resolved
@ono-max
Copy link
Member

ono-max commented Jun 10, 2021

I'm concerned that this method should be placed in utils.rb because I suppose that test files are script files that can be tested automatically such as rake test.

@st0012 st0012 force-pushed the start-debug-session-with-test-program branch from 2eed8df to 1f37697 Compare June 10, 2021 01:32
@st0012
Copy link
Member Author

st0012 commented Jun 10, 2021

I don't get the concern. it's not suppose to be committed to the final test scripts, it's only used when "writing" the scripts.
or are you worry about the method visibility? I just defined it as a private method though

@ono-max
Copy link
Member

ono-max commented Jun 10, 2021

Ok, it looks fine to me. The method visibility is also good.

test/support/utils.rb Outdated Show resolved Hide resolved
test/support/utils.rb Outdated Show resolved Hide resolved
test/support/utils.rb Outdated Show resolved Hide resolved
@st0012 st0012 force-pushed the start-debug-session-with-test-program branch from 1f37697 to 6c05ec6 Compare June 10, 2021 09:12
@st0012 st0012 requested a review from ko1 June 10, 2021 09:13
test/support/utils.rb Outdated Show resolved Hide resolved
@st0012 st0012 force-pushed the start-debug-session-with-test-program branch from 6c05ec6 to 156f27f Compare June 16, 2021 05:33
@st0012 st0012 requested a review from ko1 June 16, 2021 05:35
@ko1 ko1 merged commit 5dc82ac into ruby:master Jun 16, 2021
@st0012 st0012 deleted the start-debug-session-with-test-program branch June 18, 2021 03:41
ono-max referenced this pull request in ono-max/debug Jul 6, 2021
We don't have to take a few step in #75 because we can use test-builder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants