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'
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
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
......@@ -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
$:.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
......
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