Project

General

Profile

Bug #13723

Change to use RubyVM for syntax check in test suite breaks suite for non-MRI

Added by headius (Charles Nutter) almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:81935]

Description

In revision 57158 (6b5f9277 on github) nobu modified the syntax checks in test/lib/test/unit/assertions.rb to use MRI-specific features.

https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/57158

Specifically, instead of using eval to check syntax, it now uses RubyVM::InstructionSequence, which only exists on MRI.

Because of the way the MRI tests are structured, we need to use test/lib contents on JRuby to run the tests. This change means a number of tests that passed before now fail, because we don't support RubyVM::InstructionSequence.

Associated revisions

Revision 1d6c1d20
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

assertions.rb: syntax_check for other impl

  • test/lib/test/unit/assertions.rb (syntax_check): use eval instead of RubyVM::InstructionSequence.compile so that other implementations can share the tests. [ruby-core:81935] [Bug #13723]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59287
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

assertions.rb: syntax_check for other impl

  • test/lib/test/unit/assertions.rb (syntax_check): use eval instead of RubyVM::InstructionSequence.compile so that other implementations can share the tests. [ruby-core:81935] [Bug #13723]

Revision 59287
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

assertions.rb: syntax_check for other impl

  • test/lib/test/unit/assertions.rb (syntax_check): use eval instead of RubyVM::InstructionSequence.compile so that other implementations can share the tests. [ruby-core:81935] [Bug #13723]

Revision 59287
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

assertions.rb: syntax_check for other impl

  • test/lib/test/unit/assertions.rb (syntax_check): use eval instead of RubyVM::InstructionSequence.compile so that other implementations can share the tests. [ruby-core:81935] [Bug #13723]

History

Updated by headius (Charles Nutter) almost 2 years ago

I have the following patch that uses eval when RubyVM::InstructionSequence is not available.

diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
index a01871f05c..b110855f45 100644
--- a/test/lib/test/unit/assertions.rb
+++ b/test/lib/test/unit/assertions.rb
@@ -471,11 +471,19 @@ def prepare_syntax_check(code, fname = caller_locations(2, 1)[0], mesg = fname.t
         $VERBOSE = verbose
       end

+      def check_syntax(src, filename, line)
+        if defined? RubyVM::InstructionSequence
+          RubyVM::InstructionSequence.compile(src, filename, filename, line)
+        else
+          eval src, binding, filename, line
+        end
+      end
+
       def assert_valid_syntax(code, *args)
         prepare_syntax_check(code, *args) do |src, fname, line, mesg|
           yield if defined?(yield)
           assert_nothing_raised(SyntaxError, mesg) do
-            RubyVM::InstructionSequence.compile(src, fname, fname, line)
+            check_syntax(src, fname, line)
           end
         end
       end
@@ -484,7 +492,7 @@ def assert_syntax_error(code, error, *args)
         prepare_syntax_check(code, *args) do |src, fname, line, mesg|
           yield if defined?(yield)
           e = assert_raise(SyntaxError, mesg) do
-            RubyVM::InstructionSequence.compile(src, fname, fname, line)
+            check_syntax(src, fname, line)
           end
           assert_match(error, e.message, mesg)
         end

Ok?

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

In some cases, RubyVM::InstructionSequence.compile and eval fail in different manor.

RubyVM::InstructionSequence.compile("break") #=> Invalid break
eval("break") #=> Can't escape from eval with break
#3

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

  • Description updated (diff)

Updated by headius (Charles Nutter) almost 2 years ago

nobu (Nobuyoshi Nakada) wrote:

In some cases, RubyVM::InstructionSequence.compile and eval fail in different manor.

Ok, but I still need a way to run the tests. The original code used eval...is there a reason it needed to change to InstructionSequence.compile?

#5

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r59287.


assertions.rb: syntax_check for other impl

  • test/lib/test/unit/assertions.rb (syntax_check): use eval instead of RubyVM::InstructionSequence.compile so that other implementations can share the tests. [ruby-core:81935] [Bug #13723]

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

I missed the name, syntax_check instead of check_syntax :(

Also available in: Atom PDF