summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-bin-strip/bintest
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-02-28 00:55:11 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-02-28 00:55:11 +0900
commitc39e2a4e5d966959a05fc61451ddf5419c9e67ba (patch)
treeb2d517b37ca4f43c2211146a38df17ce677e1a29 /mrbgems/mruby-bin-strip/bintest
parent9a9548eb0e493d1480caa7d1176ebf0e0b8e8e30 (diff)
parent1266ab6500d57f0457645c511c4051798f676156 (diff)
downloadmruby-c39e2a4e5d966959a05fc61451ddf5419c9e67ba.tar.gz
mruby-c39e2a4e5d966959a05fc61451ddf5419c9e67ba.zip
Merge pull request #1761 from take-cheeze/mruby-strip
Add mruby-strip tool to strip irep's debug info.
Diffstat (limited to 'mrbgems/mruby-bin-strip/bintest')
-rw-r--r--mrbgems/mruby-bin-strip/bintest/mruby-strip.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb b/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
new file mode 100644
index 000000000..4f27d2fce
--- /dev/null
+++ b/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
@@ -0,0 +1,53 @@
+require 'tempfile'
+
+assert('no files') do
+ o = `bin/mruby-strip 2>&1`
+ assert_equal 1, $?.exitstatus
+ assert_equal "no files to strip\n", o
+end
+
+assert('file not found') do
+ o = `bin/mruby-strip not_found.mrb 2>&1`
+ assert_equal 1, $?.exitstatus
+ assert_equal "can't open file not_found.mrb\n", o
+end
+
+assert('not irep file') do
+ t = Tempfile.new('script.rb')
+ t.write 'p test\n'
+ t.flush
+ o = `bin/mruby-strip #{t.path} 2>&1`
+ assert_equal 1, $?.exitstatus
+ assert_equal "can't read irep file #{t.path}\n", o
+end
+
+assert('success') do
+ script_file, compiled1, compiled2 =
+ Tempfile.new('script.rb'), Tempfile.new('c1.mrb'), Tempfile.new('c2.mrb')
+ script_file.write "p 'test'\n"
+ script_file.flush
+ `bin/mrbc -g -o #{compiled1.path} #{script_file.path}`
+ `bin/mrbc -g -o #{compiled2.path} #{script_file.path}`
+
+ o = `bin/mruby-strip #{compiled1.path}`
+ assert_equal 0, $?.exitstatus
+ assert_equal "", o
+
+ o = `bin/mruby-strip #{compiled1.path} #{compiled2.path}`
+ assert_equal 0, $?.exitstatus
+ assert_equal "", o
+end
+
+assert('check debug section') do
+ script_file, with_debug, without_debug =
+ Tempfile.new('script.rb'), Tempfile.new('c1.mrb'), Tempfile.new('c2.mrb')
+ script_file.write "p 'test'\n"
+ script_file.flush
+ `bin/mrbc -o #{without_debug.path} #{script_file.path}`
+ `bin/mrbc -g -o #{with_debug.path} #{script_file.path}`
+
+ assert_true with_debug.size >= without_debug.size
+
+ `bin/mruby-strip #{with_debug.path}`
+ assert_equal without_debug.size, with_debug.size
+end