Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action View tests using Ruby 3.1.0-dev fails since https://github.com/ruby/ruby/pull/4586 #42678

Closed
yahonda opened this issue Jul 2, 2021 · 3 comments

Comments

@yahonda
Copy link
Member

yahonda commented Jul 2, 2021

Action View tests using Ruby 3.1.0-dev fails since ruby/ruby#4586 Refer https://buildkite.com/rails/rails/builds/78944#5ae555e6-0f48-4b8d-bd0f-fd722dee783f for CI failures.

Steps to reproduce

  1. Install Ruby 3.1.0-dev using rbenv and ruby-build or whatever.
  2. Clone Rails repository and execute bundle update
git clone https://github.com/rails/rails
cd rails
bundle update
  1. Execute Action View CachedCollectionViewRenderTest
cd actionview
bin/test test/template/render_test.rb:454

Expected behavior

It should pass.

Actual behavior

yahonda@mymacbookpro actionview % bin/test test/template/render_test.rb:454                                                                                                                                                                              main
Run options: --seed 12011

# Running:

F

Failure:
CachedViewRenderTest#test_render_partial_without_object_or_collection_does_not_generate_partial_name_local_variable [/Users/yahonda/src/github.com/rails/rails/actionview/test/template/render_test.rb:454]:
[ActionView::Template::Error] exception expected, not
Class: <SyntaxError>
Message: <"syntax error, unexpected '<'\n<%= partial_name_local_variabl...\n^\nunterminated string meets end of file\n... partial_name_local_variable %>\n...                               ^\n">
---Backtrace---
<internal:ast>:67:in `of'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/error_highlight/core_ext.rb:19:in `to_s'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/did_you_mean/core_ext/name_error.rb:15:in `to_s'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template/error.rb:168:in `message'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template/error.rb:168:in `initialize'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:314:in `new'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:314:in `handle_render_error'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:157:in `rescue in render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:151:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:251:in `block in render_partial_template'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications.rb:207:in `block in instrument'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications.rb:207:in `instrument'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:246:in `render_partial_template'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:237:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/renderer.rb:53:in `render_partial'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/helpers/rendering_helper.rb:45:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/test/template/render_test.rb:455:in `block in test_render_partial_without_object_or_collection_does_not_generate_partial_name_local_variable'
---------------


bin/test test/template/render_test.rb:453

F

Failure:
LazyViewRenderTest#test_render_partial_without_object_or_collection_does_not_generate_partial_name_local_variable [/Users/yahonda/src/github.com/rails/rails/actionview/test/template/render_test.rb:454]:
[ActionView::Template::Error] exception expected, not
Class: <SyntaxError>
Message: <"syntax error, unexpected '<'\n<%= partial_name_local_variabl...\n^\nunterminated string meets end of file\n... partial_name_local_variable %>\n...                               ^\n">
---Backtrace---
<internal:ast>:67:in `of'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/error_highlight/core_ext.rb:19:in `to_s'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/did_you_mean/core_ext/name_error.rb:15:in `to_s'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template/error.rb:168:in `message'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template/error.rb:168:in `initialize'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:314:in `new'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:314:in `handle_render_error'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:157:in `rescue in render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:151:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:251:in `block in render_partial_template'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications.rb:207:in `block in instrument'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications.rb:207:in `instrument'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:246:in `render_partial_template'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:237:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/renderer.rb:53:in `render_partial'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/helpers/rendering_helper.rb:45:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/test/template/render_test.rb:455:in `block in test_render_partial_without_object_or_collection_does_not_generate_partial_name_local_variable'
---------------


bin/test test/template/render_test.rb:453

F

Failure:
CachedCollectionViewRenderTest#test_render_partial_without_object_or_collection_does_not_generate_partial_name_local_variable [/Users/yahonda/src/github.com/rails/rails/actionview/test/template/render_test.rb:454]:
[ActionView::Template::Error] exception expected, not
Class: <SyntaxError>
Message: <"syntax error, unexpected '<'\n<%= partial_name_local_variabl...\n^\nunterminated string meets end of file\n... partial_name_local_variable %>\n...                               ^\n">
---Backtrace---
<internal:ast>:67:in `of'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/error_highlight/core_ext.rb:19:in `to_s'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/did_you_mean/core_ext/name_error.rb:15:in `to_s'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template/error.rb:168:in `message'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template/error.rb:168:in `initialize'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:314:in `new'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:314:in `handle_render_error'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:157:in `rescue in render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:151:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:251:in `block in render_partial_template'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications.rb:207:in `block in instrument'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications.rb:207:in `instrument'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:246:in `render_partial_template'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:237:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/renderer.rb:53:in `render_partial'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/helpers/rendering_helper.rb:45:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/test/template/render_test.rb:455:in `block in test_render_partial_without_object_or_collection_does_not_generate_partial_name_local_variable'
---------------


bin/test test/template/render_test.rb:453



Finished in 0.315806s, 9.4995 runs/s, 28.4985 assertions/s.
3 runs, 9 assertions, 3 failures, 0 errors, 0 skips
%

System configuration

Rails version: main branch

Ruby version:ruby 3.1.0dev (2021-07-02T01:49:17Z master 8ebb5e23eb) [x86_64-darwin21]

@yahonda
Copy link
Member Author

yahonda commented Jul 2, 2021

They have been failing since ruby/ruby#4586 , which introduces error_highlight gem.

I'm working on fixing them and have no idea how to address Action View failures yet.
These tests expect ActionView::Template::Error exception but it acutally raises SyntaxError at

public_send(method, locals, buffer, &block)

Here are some debug result.

  1. Add binding.irb as follows.
diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb
index 295f403eba..fbe6d1ce8c 100644
--- a/actionview/lib/action_view/base.rb
+++ b/actionview/lib/action_view/base.rb
@@ -244,6 +244,7 @@ def _run(method, template, locals, buffer, add_to_stack: true, &block)
       _old_output_buffer, _old_virtual_path, _old_template = @output_buffer, @virtual_path, @current_template
       @current_template = template if add_to_stack
       @output_buffer = buffer
+      binding.irb
       public_send(method, locals, buffer, &block)
     ensure
       @output_buffer, @virtual_path, @current_template = _old_output_buffer, _old_virtual_path, _old_template
  1. Run CachedCollectionViewRenderTest
% cd actionview
% bin/test test/template/render_test.rb:454
Run options: --seed 39654

# Running:


From: /Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/base.rb @ line 247 :

    242:
    243:     def _run(method, template, locals, buffer, add_to_stack: true, &block)
    244:       _old_output_buffer, _old_virtual_path, _old_template = @output_buffer, @virtual_path, @current_template
    245:       @current_template = template if add_to_stack
    246:       @output_buffer = buffer
 => 247:       binding.irb
    248:       public_send(method, locals, buffer, &block)
    249:     ensure
    250:       @output_buffer, @virtual_path, @current_template = _old_output_buffer, _old_virtual_path, _old_template
    251:     end
    252:

irb(#<#<Class:0x000000010a2aa3e0>:0x000000010a2a9378>):001:0> method
=> "___sers_yahonda_src_github_com_rails_rails_actionview_test_fixtures_test__partial_name_local_variable_erb__3477429999150118233_6060"
irb(#<#<Class:0x000000010a2aa3e0>:0x000000010a2a9378>):002:0> locals
=> {}
irb(#<#<Class:0x000000010a2aa3e0>:0x000000010a2a9378>):003:0> buffer
=> ""
irb(#<#<Class:0x000000010a2aa3e0>:0x000000010a2a9378>):004:0> block
=> #<Proc:0x000000010a38f198 /Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:251>
irb(#<#<Class:0x000000010a2aa3e0>:0x000000010a2a9378>):005:0> public_send(method, locals, buffer, &block)
F

Failure:
CachedCollectionViewRenderTest#test_render_partial_without_object_or_collection_does_not_generate_partial_name_local_variable [/Users/yahonda/src/github.com/rails/rails/actionview/test/template/render_test.rb:454]:
[ActionView::Template::Error] exception expected, not
Class: <SyntaxError>
Message: <"syntax error, unexpected '<'\n<%= partial_name_local_variabl...\n^\nunterminated string meets end of file\n... partial_name_local_variable %>\n...                               ^\n">
---Backtrace---
<internal:ast>:67:in `of'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/error_highlight/core_ext.rb:19:in `to_s'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/did_you_mean/core_ext/name_error.rb:15:in `to_s'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:646:in `message'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:646:in `full_message'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:646:in `handle_exception'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:586:in `block (2 levels) in eval_input'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:758:in `signal_status'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:548:in `block in eval_input'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb/ruby-lex.rb:251:in `block (2 levels) in each_top_level_statement'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb/ruby-lex.rb:233:in `loop'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb/ruby-lex.rb:233:in `block in each_top_level_statement'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb/ruby-lex.rb:232:in `catch'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb/ruby-lex.rb:232:in `each_top_level_statement'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:547:in `eval_input'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:481:in `block in run'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:480:in `catch'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:480:in `run'
/Users/yahonda/.rbenv/versions/3.1.0-dev/lib/ruby/3.1.0/irb.rb:961:in `irb'
<internal:prelude>:5:in `irb'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/base.rb:247:in `_run'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:154:in `block in render'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications.rb:209:in `instrument'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:354:in `instrument_render_template'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/template.rb:152:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:251:in `block in render_partial_template'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications.rb:207:in `block in instrument'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/Users/yahonda/src/github.com/rails/rails/activesupport/lib/active_support/notifications.rb:207:in `instrument'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:246:in `render_partial_template'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/partial_renderer.rb:237:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/renderer/renderer.rb:53:in `render_partial'
/Users/yahonda/src/github.com/rails/rails/actionview/lib/action_view/helpers/rendering_helper.rb:45:in `render'
/Users/yahonda/src/github.com/rails/rails/actionview/test/template/render_test.rb:455:in `block in test_render_partial_without_object_or_collection_does_not_generate_partial_name_local_variable'
---------------

mame added a commit to ruby/error_highlight that referenced this issue Jul 2, 2021
When the original source code is erb, RubyVM::AST.of does not work well.
rails/rails#42678.
matzbot pushed a commit to ruby/ruby that referenced this issue Jul 2, 2021
@mame
Copy link
Contributor

mame commented Jul 2, 2021

Thank you for your trouble. This is not an intentional side effect. I've just pushed a fix that suppress a SyntaxError during error_highlight, so could you give it a try again? Thanks!

@yahonda
Copy link
Member Author

yahonda commented Jul 2, 2021

I have confirmed this issue has been resolved. Thanks for the fix.

% ruby -v
ruby 3.1.0dev (2021-07-02T07:48:20Z master 3a95834739) [x86_64-darwin21]
%  bin/test test/template/render_test.rb:454
Run options: --seed 35817

# Running:

...

Finished in 0.350065s, 8.5698 runs/s, 42.8492 assertions/s.
3 runs, 15 assertions, 0 failures, 0 errors, 0 skips
%

@yahonda yahonda closed this as completed Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants