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

Improve test builder #153

Merged
merged 2 commits into from
Jul 9, 2021
Merged

Improve test builder #153

merged 2 commits into from
Jul 9, 2021

Conversation

ono-max
Copy link
Member

@ono-max ono-max commented Jul 9, 2021

There are two points I implemented.

1. q! and quit! matches not only debug commands, but also backtrace log.

Example

at_exit{
  binding.bp
  eval('a = 1')
  Thread.new{}
}

binding.bp(command: 'q!')
$ bin/gentest target.rb -c HelpTest -m test_help_with_undefined_command_shows_an_error
DEBUGGER: Session start (pid: 71085)
DEBUGGER: Thread #1 is created.
DEBUGGER: Thread #2 is created.
DEBUGGER: Load /Users/ono-max/workspace/debug/target.rb
[1, 7] in ~/workspace/debug/target.rb
=>    1| at_exit{
      2|   binding.bp
      3|   eval('a = 1')
      4|   Thread.new{}
      5| }
      6|
      7| binding.bp(command: 'q!')
=>#0	<main> at ~/workspace/debug/target.rb:1
INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:1","line":1}

(rdbg)s
 s
[2, 7] in ~/workspace/debug/target.rb
      2|   binding.bp
      3|   eval('a = 1')
      4|   Thread.new{}
      5| }
      6|
=>    7| binding.bp(command: 'q!')
=>#0	<main> at ~/workspace/debug/target.rb:7
INTERNAL_INFO: {"location":"~/workspace/debug/target.rb:7","line":7}

(rdbg)q!
 q!
appended: /Users/ono-max/workspace/debug/test/tool/../debug/help_test.rb
    method: test_help_with_undefined_command_shows_an_error
Generated file(Now)
def test_help_with_undefined_command_shows_an_error
      debug_code(program) do
        type '' # we don't need this code
        type 's' # we don't need this code
        type 's'
        assert_line_num 7
        assert_line_text([
          /\[2, 7\] in .*/,
          /      2\|   binding\.bp/,
          /      3\|   eval\('a = 1'\)/,
          /      4\|   Thread\.new\{\}/,
          /      5\| \}/,
          /      6\| /,
          /=>    7\| binding\.bp\(command: 'q!'\)/,
          /=>\#0\t<main> at .*/
        ])
        type 'q!'
      end
    end
Generated file(Expected)
def test_help_with_undefined_command_shows_an_error
      debug_code(program) do
        type 's'
        assert_line_num 7
        assert_line_text([
          /\[2, 7\] in .*/,
          /      2\|   binding\.bp/,
          /      3\|   eval\('a = 1'\)/,
          /      4\|   Thread\.new\{\}/,
          /      5\| \}/,
          /      6\| /,
          /=>    7\| binding\.bp\(command: 'q!'\)/,
          /=>\#0\t<main> at .*/
        ])
        type 'q!'
      end
    end

2. Even one line, the parameter use array in test builder.

Now

def test_help_with_undefined_command_shows_an_error
      debug_code(program) do
        type ''
        type 'help foo'
        assert_line_text([
          /not found: foo/
        ])
        type 'q!'
      end
    end

Expected

def test_help_with_undefined_command_shows_an_error
      debug_code(program) do
        type 'help foo'
        assert_line_text(/not found: foo/)
        type 'q!'
      end
    end

@ko1 ko1 merged commit c3b4597 into ruby:master Jul 9, 2021
@ono-max ono-max deleted the improve-test-builder branch July 9, 2021 23:47
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.

2 participants