From 6b6368158dd2556007c036e4f01bf45fec2039f0 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 19 Nov 2016 03:02:47 +0000 Subject: merge revision(s) 56267,56268: [Backport #12943] based on a patch provided by Aaron Patterson. assertions.rb: success option * test/lib/test/unit/assertions.rb (assert_in_out_err): add success option to check the exit status. * iseq.c (iseqw_s_compile_file): deal with syntax error as well as compile, and should not abort when rescued. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@56838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_iseq.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index 4561eeb952..9f9f5418e0 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -1,4 +1,5 @@ require 'test/unit' +require 'tempfile' class TestISeq < Test::Unit::TestCase ISeq = RubyVM::InstructionSequence @@ -212,4 +213,21 @@ class TestISeq < Test::Unit::TestCase at_exit { assert_equal([:n, :x], Segfault.new.segfault.sort) } end; end + + def test_compile_file_error + Tempfile.create(%w"test_iseq .rb") do |f| + f.puts "end" + f.close + path = f.path + assert_in_out_err(%W[- #{path}], "#{<<-"begin;"}\n#{<<-"end;"}", /compile error/, /keyword_end/, success: true) + begin; + path = ARGV[0] + begin + RubyVM::InstructionSequence.compile_file(path) + rescue SyntaxError => e + puts e.message + end + end; + end + end end -- cgit v1.2.3