summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2015-10-01 19:21:57 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2015-10-01 19:21:57 +0900
commitbcd10c710c665b0e4507a3372a2626baccbc4b65 (patch)
treee7010366188052a89cc659426fc4bbf55367f7a8
parent81ec5f5dc04a45d869ebf393d818cb8d08e0ffbf (diff)
parent545d649eff73021d515f7a96841b363b0001e9d9 (diff)
downloadmruby-bcd10c710c665b0e4507a3372a2626baccbc4b65.tar.gz
mruby-bcd10c710c665b0e4507a3372a2626baccbc4b65.zip
Merge pull request #2973 from mattn/fix-windows-tests
fix tests on windows.
-rw-r--r--mrbgems/mruby-bin-mruby/bintest/mruby.rb20
-rw-r--r--mrbgems/mruby-bin-strip/bintest/mruby-strip.rb32
-rw-r--r--mrbgems/mruby-compiler/bintest/mrbc.rb4
-rw-r--r--test/bintest.rb8
4 files changed, 36 insertions, 28 deletions
diff --git a/mrbgems/mruby-bin-mruby/bintest/mruby.rb b/mrbgems/mruby-bin-mruby/bintest/mruby.rb
index de211c1ba..01fc94632 100644
--- a/mrbgems/mruby-bin-mruby/bintest/mruby.rb
+++ b/mrbgems/mruby-bin-mruby/bintest/mruby.rb
@@ -1,17 +1,17 @@
require 'tempfile'
assert('regression for #1564') do
- o = `bin/mruby -e '<<' 2>&1`
+ o = `#{cmd('mruby')} -e #{shellquote('<<')} 2>&1`
assert_equal o, "-e:1:2: syntax error, unexpected tLSHFT\n"
- o = `bin/mruby -e '<<-' 2>&1`
+ o = `#{cmd('mruby')} -e #{shellquote('<<-')} 2>&1`
assert_equal o, "-e:1:3: syntax error, unexpected tLSHFT\n"
end
assert('regression for #1572') do
script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb')
- system "echo 'p \"ok\"' > #{script.path}"
- system "bin/mrbc -g -o #{bin.path} #{script.path}"
- o = `bin/mruby -b #{bin.path}`.strip
+ File.write script.path, 'p "ok"'
+ system "#{cmd('mrbc')} -g -o #{bin.path} #{script.path}"
+ o = `#{cmd('mruby')} -b #{bin.path}`.strip
assert_equal o, '"ok"'
end
@@ -21,14 +21,14 @@ assert '$0 value' do
# .rb script
script.write "p $0\n"
script.flush
- assert_equal "\"#{script.path}\"", `./bin/mruby "#{script.path}"`.chomp
+ assert_equal "\"#{script.path}\"", `#{cmd('mruby')} "#{script.path}"`.chomp
# .mrb file
- `./bin/mrbc -o "#{bin.path}" "#{script.path}"`
- assert_equal "\"#{bin.path}\"", `./bin/mruby -b "#{bin.path}"`.chomp
+ `#{cmd('mrbc')} -o "#{bin.path}" "#{script.path}"`
+ assert_equal "\"#{bin.path}\"", `#{cmd('mruby')} -b "#{bin.path}"`.chomp
# one liner
- assert_equal '"-e"', `./bin/mruby -e 'p $0'`.chomp
+ assert_equal '"-e"', `#{cmd('mruby')} -e #{shellquote('p $0')}`.chomp
end
assert '__END__', '8.6' do
@@ -42,5 +42,5 @@ __END__
p 'legend'
EOS
script.flush
- assert_equal "\"test\"\n\"fin\"\n", `./bin/mruby #{script.path}`
+ assert_equal "\"test\"\n\"fin\"\n", `#{cmd('mruby')} #{script.path}`
end
diff --git a/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb b/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
index e74a74f10..bb664a2b1 100644
--- a/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
+++ b/mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
@@ -1,13 +1,13 @@
require 'tempfile'
assert('no files') do
- o = `bin/mruby-strip 2>&1`
+ o = `#{cmd('mruby-strip')} 2>&1`
assert_equal 1, $?.exitstatus
assert_equal "no files to strip", o.split("\n")[0]
end
assert('file not found') do
- o = `bin/mruby-strip not_found.mrb 2>&1`
+ o = `#{cmd('mruby-strip')} not_found.mrb 2>&1`
assert_equal 1, $?.exitstatus
assert_equal "can't open file for reading not_found.mrb\n", o
end
@@ -16,7 +16,7 @@ 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`
+ o = `#{cmd('mruby-strip')} #{t.path} 2>&1`
assert_equal 1, $?.exitstatus
assert_equal "can't read irep file #{t.path}\n", o
end
@@ -26,15 +26,15 @@ assert('success') do
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}`
+ `#{cmd('mrbc')} -g -o #{compiled1.path} #{script_file.path}`
+ `#{cmd('mrbc')} -g -o #{compiled2.path} #{script_file.path}`
- o = `bin/mruby-strip #{compiled1.path}`
+ o = `#{cmd('mruby-strip')} #{compiled1.path}`
assert_equal 0, $?.exitstatus
assert_equal "", o
- assert_equal `bin/mruby #{script_file.path}`, `bin/mruby -b #{compiled1.path}`
+ assert_equal `#{cmd('mruby')} #{script_file.path}`, `#{cmd('mruby')} -b #{compiled1.path}`
- o = `bin/mruby-strip #{compiled1.path} #{compiled2.path}`
+ o = `#{cmd('mruby-strip')} #{compiled1.path} #{compiled2.path}`
assert_equal 0, $?.exitstatus
assert_equal "", o
end
@@ -44,12 +44,12 @@ assert('check debug section') do
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}`
+ `#{cmd('mrbc')} -o #{without_debug.path} #{script_file.path}`
+ `#{cmd('mrbc')} -g -o #{with_debug.path} #{script_file.path}`
assert_true with_debug.size >= without_debug.size
- `bin/mruby-strip #{with_debug.path}`
+ `#{cmd('mruby-strip')} #{with_debug.path}`
assert_equal without_debug.size, with_debug.size
end
@@ -62,12 +62,12 @@ a += b
p Kernel.local_variables
EOS
script_file.flush
- `bin/mrbc -o #{with_lv.path} #{script_file.path}`
- `bin/mrbc -o #{without_lv.path} #{script_file.path}`
+ `#{cmd('mrbc')} -o #{with_lv.path} #{script_file.path}`
+ `#{cmd('mrbc')} -o #{without_lv.path} #{script_file.path}`
- `bin/mruby-strip -l #{without_lv.path}`
+ `#{cmd('mruby-strip')} -l #{without_lv.path}`
assert_true without_lv.size < with_lv.size
- assert_equal '[:a, :b]', `bin/mruby -b #{with_lv.path}`.chomp
- assert_equal '[]', `bin/mruby -b #{without_lv.path}`.chomp
+ assert_equal '[:a, :b]', `#{cmd('mruby')} -b #{with_lv.path}`.chomp
+ assert_equal '[]', `#{cmd('mruby')} -b #{without_lv.path}`.chomp
end
diff --git a/mrbgems/mruby-compiler/bintest/mrbc.rb b/mrbgems/mruby-compiler/bintest/mrbc.rb
index b016378a1..e4dc6a9a8 100644
--- a/mrbgems/mruby-compiler/bintest/mrbc.rb
+++ b/mrbgems/mruby-compiler/bintest/mrbc.rb
@@ -6,7 +6,7 @@ assert('Compiling multiple files without new line in last line. #2361') do
a.flush
b.write('module B; end')
b.flush
- result = `bin/mrbc -c -o #{out.path} #{a.path} #{b.path} 2>&1`
- assert_equal "bin/mrbc:#{a.path}:Syntax OK", result.chomp
+ result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} #{b.path} 2>&1`
+ assert_equal "#{cmd('mrbc')}:#{a.path}:Syntax OK", result.chomp
assert_equal 0, $?.exitstatus
end
diff --git a/test/bintest.rb b/test/bintest.rb
index 49990abb9..e6d122047 100644
--- a/test/bintest.rb
+++ b/test/bintest.rb
@@ -1,6 +1,14 @@
$:.unshift File.dirname(File.dirname(File.expand_path(__FILE__)))
require 'test/assert.rb'
+def cmd(s)
+ ENV['SHELL'] ? "bin/#{s}" : "bin\\#{s}.exe"
+end
+
+def shellquote(s)
+ ENV['SHELL'] ? "'#{s}'" : "\"#{s}\""
+end
+
ARGV.each do |gem|
Dir["#{gem}/bintest/**/*.rb"].each do |file|
load file