summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-19 03:02:47 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-19 03:02:47 +0000
commit6b6368158dd2556007c036e4f01bf45fec2039f0 (patch)
tree66b3088557a9ed0c6e7b68760fbc77622d9b7ced
parent9b5c2baae046fc943cd31279e325d59f13f54b3b (diff)
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
-rw-r--r--ChangeLog5
-rw-r--r--iseq.c5
-rw-r--r--test/lib/test/unit/assertions.rb12
-rw-r--r--test/ruby/test_iseq.rb18
-rw-r--r--version.h6
5 files changed, 40 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2c6b603ce6..8c7bd61164 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Nov 19 11:48:47 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * iseq.c (iseqw_s_compile_file): deal with syntax error as well as
+ compile, and should not abort when rescued.
+
Wed Nov 16 23:40:29 2016 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
* vm_eval.c (vm_call0_body): refined module should not be skipped as
diff --git a/iseq.c b/iseq.c
index e679108558..797473e070 100644
--- a/iseq.c
+++ b/iseq.c
@@ -812,8 +812,7 @@ static VALUE
iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
{
VALUE file, line = INT2FIX(1), opt = Qnil;
- VALUE parser;
- VALUE f;
+ VALUE parser, f, exc = Qnil;
NODE *node;
const char *fname;
rb_compile_option_t option;
@@ -827,8 +826,10 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
parser = rb_parser_new();
node = rb_parser_compile_file(parser, fname, f, NUM2INT(line));
+ if (!node) exc = GET_THREAD()->errinfo;
rb_io_close(f);
+ if (!node) rb_exc_raise(exc);
make_compile_option(&option, opt);
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
index 9a1cacd5a9..975d343ba4 100644
--- a/test/lib/test/unit/assertions.rb
+++ b/test/lib/test/unit/assertions.rb
@@ -539,7 +539,8 @@ EOT
faildesc
end
- def assert_in_out_err(args, test_stdin = "", test_stdout = [], test_stderr = [], message = nil, **opt)
+ def assert_in_out_err(args, test_stdin = "", test_stdout = [], test_stderr = [], message = nil,
+ success: nil, **opt)
stdout, stderr, status = EnvUtil.invoke_ruby(args, test_stdin, true, true, **opt)
if signo = status.termsig
EnvUtil.diagnostic_reports(Signal.signame(signo), EnvUtil.rubybin, status.pid, Time.now)
@@ -561,6 +562,15 @@ EOT
end
end
end
+ unless success.nil?
+ a.for("success?") do
+ if success
+ assert_predicate(status, :success?)
+ else
+ assert_not_predicate(status, :success?)
+ end
+ end
+ end
end
status
end
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
diff --git a/version.h b/version.h
index 1dedf943e2..d7af154d2a 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.3.3"
-#define RUBY_RELEASE_DATE "2016-11-16"
-#define RUBY_PATCHLEVEL 219
+#define RUBY_RELEASE_DATE "2016-11-19"
+#define RUBY_PATCHLEVEL 220
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 11
-#define RUBY_RELEASE_DAY 16
+#define RUBY_RELEASE_DAY 19
#include "ruby/version.h"