diff options
author | makoto kuwata <kwa@kuwata-lab.com> | 2008-06-12 12:08:47 +0000 |
---|---|---|
committer | makoto kuwata <kwa@kuwata-lab.com> | 2008-06-12 12:08:47 +0000 |
commit | 90927ecab519a4c83bff23d71a2b2eb9dec4755d (patch) | |
tree | 63563036e2f7964edd193bfe7d7b61127f611e9f | |
parent | 738c2a167611f86837186673975514997c59c69b (diff) | |
download | erubis-90927ecab519a4c83bff23d71a2b2eb9dec4755d.tar.gz |
* [change] use "#{ENV['_']} -wc" instead of 'ruby -wc' to check syntax (-z) if ENV['_'] is not nil
-rw-r--r-- | lib/erubis/main.rb | 3 | ||||
-rw-r--r-- | test/test-main.rb | 19 | ||||
-rw-r--r-- | test/testutil.rb | 15 |
3 files changed, 34 insertions, 3 deletions
diff --git a/lib/erubis/main.rb b/lib/erubis/main.rb index 1cdba6d..22cdfbd 100644 --- a/lib/erubis/main.rb +++ b/lib/erubis/main.rb @@ -472,7 +472,8 @@ module Erubis def check_syntax(filename, src) require 'open3' - stdin, stdout, stderr = Open3.popen3('ruby -wc') + command = (ENV['_'] || 'ruby') + ' -wc' # ENV['_'] stores command name + stdin, stdout, stderr = Open3.popen3(command) stdin.write(src) stdin.close result = stdout.read() diff --git a/test/test-main.rb b/test/test-main.rb index 65a0059..50cf3ad 100644 --- a/test/test-main.rb +++ b/test/test-main.rb @@ -231,7 +231,21 @@ END basename = 'tmp.test_syntax2_%d.rhtml' filenames = [ basename % 0, basename % 1 ] errmsgs = [] - errmsgs << <<'END' + if ruby19? + errmsgs << <<'END' +3: syntax error, unexpected ']', expecting ')' + _buf << ' <li>'; _buf << ( item[:name]] ).to_s; _buf << '</li> + ^ +-:4: syntax error, unexpected keyword_end, expecting ')' +'; end + ^ +-:7: syntax error, unexpected $end, expecting ')' +END + errmsgs << <<'END' +7: syntax error, unexpected $end, expecting keyword_end or keyword_endfor +END + else + errmsgs << <<'END' 3: syntax error, unexpected ']', expecting ')' _buf << ' <li>'; _buf << ( item[:name]] ).to_s; _buf << '</li> ^ @@ -240,9 +254,10 @@ END ^ -:7: syntax error, unexpected $end, expecting ')' END - errmsgs << <<'END' + errmsgs << <<'END' 7: syntax error, unexpected $end, expecting kEND END + end # max = inputs.length (0...max).each do |i| diff --git a/test/testutil.rb b/test/testutil.rb index 8fd49b7..ac458b7 100644 --- a/test/testutil.rb +++ b/test/testutil.rb @@ -9,6 +9,21 @@ require 'yaml' require 'test/unit/testcase' + +def _ruby_ver_str # :nodoc: + return /\d+\.\d+/.match(RUBY_VERSION)[0] +end + +def ruby18? # :nodoc: + _ruby_ver_str() == "1.8" +end + +def ruby19? # :nodoc: + _ruby_ver_str() > "1.8" +end + + + class Test::Unit::TestCase |