[前][次][番号順一覧][スレッド一覧]

ruby-changes:44765

From: nagachika <ko1@a...>
Date: Sat, 19 Nov 2016 12:02:53 +0900 (JST)
Subject: [ruby-changes:44765] nagachika:r56838 (ruby_2_3): merge revision(s) 56267, 56268: [Backport #12943]

nagachika	2016-11-19 12:02:47 +0900 (Sat, 19 Nov 2016)

  New Revision: 56838

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56838

  Log:
    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.

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/iseq.c
    branches/ruby_2_3/test/lib/test/unit/assertions.rb
    branches/ruby_2_3/test/ruby/test_iseq.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 56837)
+++ ruby_2_3/version.h	(revision 56838)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #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"
 
Index: ruby_2_3/iseq.c
===================================================================
--- ruby_2_3/iseq.c	(revision 56837)
+++ ruby_2_3/iseq.c	(revision 56838)
@@ -812,8 +812,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_3/iseq.c#L812
 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 *ar https://github.com/ruby/ruby/blob/trunk/ruby_2_3/iseq.c#L826
 
     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);
 
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 56837)
+++ ruby_2_3/ChangeLog	(revision 56838)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Sat Nov 19 11:48:47 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* vm_eval.c (vm_call0_body): refined module should not be skipped as
Index: ruby_2_3/test/lib/test/unit/assertions.rb
===================================================================
--- ruby_2_3/test/lib/test/unit/assertions.rb	(revision 56837)
+++ ruby_2_3/test/lib/test/unit/assertions.rb	(revision 56838)
@@ -539,7 +539,8 @@ EOT https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/lib/test/unit/assertions.rb#L539
         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 https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/lib/test/unit/assertions.rb#L562
                 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
Index: ruby_2_3/test/ruby/test_iseq.rb
===================================================================
--- ruby_2_3/test/ruby/test_iseq.rb	(revision 56837)
+++ ruby_2_3/test/ruby/test_iseq.rb	(revision 56838)
@@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_iseq.rb#L1
 require 'test/unit'
+require 'tempfile'
 
 class TestISeq < Test::Unit::TestCase
   ISeq = RubyVM::InstructionSequence
@@ -212,4 +213,21 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_iseq.rb#L213
       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

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r56267-56268


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]