ruby-changes:47369
From: naruse <ko1@a...>
Date: Thu, 3 Aug 2017 18:39:31 +0900 (JST)
Subject: [ruby-changes:47369] naruse:r59485 (trunk): Add initial test for lldb extension
naruse 2017-08-03 18:39:25 +0900 (Thu, 03 Aug 2017) New Revision: 59485 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59485 Log: Add initial test for lldb extension Added files: trunk/misc/test_lldb_cruby.rb Modified files: trunk/misc/lldb_cruby.py Index: misc/lldb_cruby.py =================================================================== --- misc/lldb_cruby.py (revision 59484) +++ misc/lldb_cruby.py (revision 59485) @@ -3,6 +3,8 @@ https://github.com/ruby/ruby/blob/trunk/misc/lldb_cruby.py#L3 # # Usage: run `command script import -r misc/lldb_cruby.py` on LLDB # +# Test: misc/test_lldb_cruby.rb +# import lldb import commands Index: misc/test_lldb_cruby.rb =================================================================== --- misc/test_lldb_cruby.rb (nonexistent) +++ misc/test_lldb_cruby.rb (revision 59485) @@ -0,0 +1,36 @@ https://github.com/ruby/ruby/blob/trunk/misc/test_lldb_cruby.rb#L1 +#!/usr/bin/env ruby +require 'open3' +require 'tempfile' +require 'test/unit' + +class TestLLDBInit < Test::Unit::TestCase + def assert_rp(expr, pattern, message=nil) + Tempfile.create('lldb') do |tf| + tf.puts <<eom +target create ./miniruby +command script import -r misc/lldb_cruby.py +b rb_p +run -e'p #{expr}' +rp obj +eom + tf.flush + o, s = Open3.capture2('lldb', '-b', '-s', tf.path) + assert_true s.success?, message + assert_match /^\(lldb\) rp obj\n#{pattern}/, o, message + end + end + + def test_rp_object + assert_rp 'Object.new', 'T_OBJECT' + end + + def test_rp_symbol + assert_rp ':abcde', /immediate\(\h+\)/ + end + + def test_rp_string + assert_rp '"abc"', /\(char \[\d+\]\) ary = "abc"/ + assert_rp "\"\u3042\"", /\(char \[\d+\]\) ary = "\u3042"/ + assert_rp '"' + "\u3042"*10 + '"', /\(RString::\(anonymous struct\)\) heap = \{/ + end +end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/