Commit bcd10c71 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2973 from mattn/fix-windows-tests

fix tests on windows.
parents 81ec5f5d 545d649e
require 'tempfile' require 'tempfile'
assert('regression for #1564') do 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" 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" assert_equal o, "-e:1:3: syntax error, unexpected tLSHFT\n"
end end
assert('regression for #1572') do assert('regression for #1572') do
script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb') script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb')
system "echo 'p \"ok\"' > #{script.path}" File.write script.path, 'p "ok"'
system "bin/mrbc -g -o #{bin.path} #{script.path}" system "#{cmd('mrbc')} -g -o #{bin.path} #{script.path}"
o = `bin/mruby -b #{bin.path}`.strip o = `#{cmd('mruby')} -b #{bin.path}`.strip
assert_equal o, '"ok"' assert_equal o, '"ok"'
end end
...@@ -21,14 +21,14 @@ assert '$0 value' do ...@@ -21,14 +21,14 @@ assert '$0 value' do
# .rb script # .rb script
script.write "p $0\n" script.write "p $0\n"
script.flush script.flush
assert_equal "\"#{script.path}\"", `./bin/mruby "#{script.path}"`.chomp assert_equal "\"#{script.path}\"", `#{cmd('mruby')} "#{script.path}"`.chomp
# .mrb file # .mrb file
`./bin/mrbc -o "#{bin.path}" "#{script.path}"` `#{cmd('mrbc')} -o "#{bin.path}" "#{script.path}"`
assert_equal "\"#{bin.path}\"", `./bin/mruby -b "#{bin.path}"`.chomp assert_equal "\"#{bin.path}\"", `#{cmd('mruby')} -b "#{bin.path}"`.chomp
# one liner # one liner
assert_equal '"-e"', `./bin/mruby -e 'p $0'`.chomp assert_equal '"-e"', `#{cmd('mruby')} -e #{shellquote('p $0')}`.chomp
end end
assert '__END__', '8.6' do assert '__END__', '8.6' do
...@@ -42,5 +42,5 @@ __END__ ...@@ -42,5 +42,5 @@ __END__
p 'legend' p 'legend'
EOS EOS
script.flush script.flush
assert_equal "\"test\"\n\"fin\"\n", `./bin/mruby #{script.path}` assert_equal "\"test\"\n\"fin\"\n", `#{cmd('mruby')} #{script.path}`
end end
require 'tempfile' require 'tempfile'
assert('no files') do assert('no files') do
o = `bin/mruby-strip 2>&1` o = `#{cmd('mruby-strip')} 2>&1`
assert_equal 1, $?.exitstatus assert_equal 1, $?.exitstatus
assert_equal "no files to strip", o.split("\n")[0] assert_equal "no files to strip", o.split("\n")[0]
end end
assert('file not found') do 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 1, $?.exitstatus
assert_equal "can't open file for reading not_found.mrb\n", o assert_equal "can't open file for reading not_found.mrb\n", o
end end
...@@ -16,7 +16,7 @@ assert('not irep file') do ...@@ -16,7 +16,7 @@ assert('not irep file') do
t = Tempfile.new('script.rb') t = Tempfile.new('script.rb')
t.write 'p test\n' t.write 'p test\n'
t.flush t.flush
o = `bin/mruby-strip #{t.path} 2>&1` o = `#{cmd('mruby-strip')} #{t.path} 2>&1`
assert_equal 1, $?.exitstatus assert_equal 1, $?.exitstatus
assert_equal "can't read irep file #{t.path}\n", o assert_equal "can't read irep file #{t.path}\n", o
end end
...@@ -26,15 +26,15 @@ assert('success') do ...@@ -26,15 +26,15 @@ assert('success') do
Tempfile.new('script.rb'), Tempfile.new('c1.mrb'), Tempfile.new('c2.mrb') Tempfile.new('script.rb'), Tempfile.new('c1.mrb'), Tempfile.new('c2.mrb')
script_file.write "p 'test'\n" script_file.write "p 'test'\n"
script_file.flush script_file.flush
`bin/mrbc -g -o #{compiled1.path} #{script_file.path}` `#{cmd('mrbc')} -g -o #{compiled1.path} #{script_file.path}`
`bin/mrbc -g -o #{compiled2.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 0, $?.exitstatus
assert_equal "", o 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 0, $?.exitstatus
assert_equal "", o assert_equal "", o
end end
...@@ -44,12 +44,12 @@ assert('check debug section') do ...@@ -44,12 +44,12 @@ assert('check debug section') do
Tempfile.new('script.rb'), Tempfile.new('c1.mrb'), Tempfile.new('c2.mrb') Tempfile.new('script.rb'), Tempfile.new('c1.mrb'), Tempfile.new('c2.mrb')
script_file.write "p 'test'\n" script_file.write "p 'test'\n"
script_file.flush script_file.flush
`bin/mrbc -o #{without_debug.path} #{script_file.path}` `#{cmd('mrbc')} -o #{without_debug.path} #{script_file.path}`
`bin/mrbc -g -o #{with_debug.path} #{script_file.path}` `#{cmd('mrbc')} -g -o #{with_debug.path} #{script_file.path}`
assert_true with_debug.size >= without_debug.size 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 assert_equal without_debug.size, with_debug.size
end end
...@@ -62,12 +62,12 @@ a += b ...@@ -62,12 +62,12 @@ a += b
p Kernel.local_variables p Kernel.local_variables
EOS EOS
script_file.flush script_file.flush
`bin/mrbc -o #{with_lv.path} #{script_file.path}` `#{cmd('mrbc')} -o #{with_lv.path} #{script_file.path}`
`bin/mrbc -o #{without_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_true without_lv.size < with_lv.size
assert_equal '[:a, :b]', `bin/mruby -b #{with_lv.path}`.chomp assert_equal '[:a, :b]', `#{cmd('mruby')} -b #{with_lv.path}`.chomp
assert_equal '[]', `bin/mruby -b #{without_lv.path}`.chomp assert_equal '[]', `#{cmd('mruby')} -b #{without_lv.path}`.chomp
end end
...@@ -6,7 +6,7 @@ assert('Compiling multiple files without new line in last line. #2361') do ...@@ -6,7 +6,7 @@ assert('Compiling multiple files without new line in last line. #2361') do
a.flush a.flush
b.write('module B; end') b.write('module B; end')
b.flush b.flush
result = `bin/mrbc -c -o #{out.path} #{a.path} #{b.path} 2>&1` result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} #{b.path} 2>&1`
assert_equal "bin/mrbc:#{a.path}:Syntax OK", result.chomp assert_equal "#{cmd('mrbc')}:#{a.path}:Syntax OK", result.chomp
assert_equal 0, $?.exitstatus assert_equal 0, $?.exitstatus
end end
$:.unshift File.dirname(File.dirname(File.expand_path(__FILE__))) $:.unshift File.dirname(File.dirname(File.expand_path(__FILE__)))
require 'test/assert.rb' 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| ARGV.each do |gem|
Dir["#{gem}/bintest/**/*.rb"].each do |file| Dir["#{gem}/bintest/**/*.rb"].each do |file|
load file load file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment