diff options
| author | KOBAYASHI Shuji <[email protected]> | 2019-12-24 23:20:20 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2019-12-24 23:20:20 +0900 |
| commit | f92867a59e624e46760b9e51556911638a008a26 (patch) | |
| tree | a43c2bcec9c5f4c55cc777797259287f45f76cdb /mrbgems/mruby-bin-debugger | |
| parent | d0625286533ce8fd8c63108670db8f32169e5ad8 (diff) | |
| download | mruby-f92867a59e624e46760b9e51556911638a008a26.tar.gz mruby-f92867a59e624e46760b9e51556911638a008a26.zip | |
Refine the assertion failure message in mrdb print tests
#### Before this patch:
```console
Fail: mruby-bin-debugger(print) error (mrbgems: mruby-bin-debugger)
- Assertion[2]
Expected true to be false.
```
#### After this patch:
```console
Fail: mruby-bin-debugger(print) error (mrbgems: mruby-bin-debugger)
- Assertion[2]
Expected "$2 = undefined method 'bar' (NoMethodError)\n" to be start_with? "$2 = (eval):2: undefined method".
```
Diffstat (limited to 'mrbgems/mruby-bin-debugger')
| -rw-r--r-- | mrbgems/mruby-bin-debugger/bintest/print.rb | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/mrbgems/mruby-bin-debugger/bintest/print.rb b/mrbgems/mruby-bin-debugger/bintest/print.rb index 314c7041a..a8401963f 100644 --- a/mrbgems/mruby-bin-debugger/bintest/print.rb +++ b/mrbgems/mruby-bin-debugger/bintest/print.rb @@ -1,9 +1,10 @@ require 'open3' require 'tempfile' +require 'strscan' class BinTest_MrubyBinDebugger - @debug1=false - @debug2=true +# @debug1=false +# @debug2=true def self.test(rubysource, testcase) script, bin = Tempfile.new(['test', '.rb']), Tempfile.new(['test', '.mrb']) @@ -19,10 +20,20 @@ class BinTest_MrubyBinDebugger stdin_data = testcase.map{|t| t[:cmd]}.join("\n") << "\n" + prompt = /^\(#{Regexp.escape(script.path)}:\d+\) / ["bin/mrdb #{script.path}","bin/mrdb -b #{bin.path}"].each do |cmd| o, s = Open3.capture2(cmd, :stdin_data => stdin_data) + scanner = StringScanner.new(o) + scanner.skip_until(prompt) + testcase.each do |tc| + exp = tc[:exp] + if exp + act = scanner.scan_until(/\n/) + break unless assert_operator act, :start_with?, exp + end + scanner.skip_until(prompt) + end - exp_vals = testcase.map{|t| t.fetch(:exp, nil)} =begin if @debug1 o.split("\n").each_with_index do |i,actual| @@ -41,14 +52,6 @@ end assert_true actual.include?(exp) unless exp.nil? end =end - idx = 0 - exp_vals.each do |exp| - next if exp.nil? - idx = o.index(exp, idx) - assert_false idx.nil? - break unless idx - idx += 1 - end end end end @@ -698,4 +701,3 @@ SRC BinTest_MrubyBinDebugger.test(src, tc) end - |
