[ruby-core:81940] [Ruby trunk Bug#13723] Change to use RubyVM for syntax check in test suite breaks suite for non-MRI

From: headius@...
Date: 2017-07-06 19:10:48 UTC
List: ruby-core #81940
Issue #13723 has been updated by headius (Charles Nutter).


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

```diff
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?

----------------------------------------
Bug #13723: Change to use RubyVM for syntax check in test suite breaks suite for non-MRI
https://bugs.ruby-lang.org/issues/13723#change-65663

* Author: headius (Charles Nutter)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
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.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next