Skip to content

Commit 9a9a3c8

Browse files
committed
Don't check flags attribute when JRuby parser is used
Ignore flags attribute when run specs against JRuby parser as far as YARP generates NEW LINE flag more accurate. So YAML files contain correct NEW LINE flags and thus will fail on JRuby parser otherwise.
1 parent b64cd1d commit 9a9a3c8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

spec/truffle/parsing/parsing_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
# So just replace AST in a YAML file using a regexp.
5050

5151
overwrite = ENV['OVERWRITE_PARSING_RESULTS'] == 'true'
52+
original_parser = ENV['TRUFFLE_PARSING_USE_ORIGINAL_TRANSLATOR'] == 'true'
5253

5354
describe "Parsing" do
5455
require 'yaml'
@@ -65,7 +66,7 @@
6566

6667
guard -> { Primitive.vm_single_context? && !TruffleRuby.jit? } do
6768
it "a #{subject} (#{description.strip}) case is parsed correctly" do
68-
if ENV['TRUFFLE_PARSING_USE_ORIGINAL_TRANSLATOR'] == 'true'
69+
if original_parser
6970
actual_ast = Truffle::Debug.parse_and_dump_truffle_ast(source_code, focused_on_node, index).strip
7071
else
7172
actual_ast = Truffle::Debug.parse_with_yarp_and_dump_truffle_ast(source_code, focused_on_node, index).strip
@@ -88,6 +89,13 @@
8889
end
8990
else
9091
# actual test check
92+
93+
if original_parser
94+
# ignore flags attribute generated by JRuby parser as far as it's not accurate
95+
actual_ast.gsub!(/^\s+flags = \d+\n?/, "")
96+
expected_ast.gsub!(/^\s+flags = \d+\n?/, "")
97+
end
98+
9199
unless actual_ast == expected_ast
92100
$stderr.puts "\nYARP AST:", Truffle::Debug.yarp_parse(source_code)
93101
end

0 commit comments

Comments
 (0)