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

rspec testsuite failure with syntax_suggest 2.0.2 #3125

Open
mtasaka opened this issue Nov 17, 2024 · 1 comment
Open

rspec testsuite failure with syntax_suggest 2.0.2 #3125

mtasaka opened this issue Nov 17, 2024 · 1 comment

Comments

@mtasaka
Copy link

mtasaka commented Nov 17, 2024

Trying with recent ruby3.4.0 dev: ruby/ruby@0024387 , rspec-core 3.13.2 shows additional rspec testsuite falure.

Even with using ruby 3.3.6, when updating syntax_suggest to 2.0.2, the same rspec testsuite failure is reproduced. Using syntax_suggest 2.0.1 does not show this error.

Failures:

  1) Spec file load errors handling syntax errors uses syntax_suggest formatting when available
     Failure/Error:
       expect(formatted_output).to include unindent(<<-EOS)
       SyntaxError:
         --> ./tmp/aruba/broken_file.rb
         Unmatched keyword, missing `end' ?
           1  class WorkInProgress
         > 2    def initialize(arg)
           3    def foo
           4    end
           5  end
       EOS

       expected "\nWhile loading ./broken_file a `raise SyntaxError` occurred, RSpec will now quit.\nFailure/Error: __send__(method, file)\n\nSyntaxError:\n  --> ./tmp/aruba/broken_file.rb\n\n  Unmatched keyword, missing `end' ?\n\n    1  class WorkInProgress\n  > 2    def initialize(arg)\n    3    def foo\n    4    end\n    5  end\n  \n  ./tmp/aruba/broken_file.rb:5: syntax error, unexpected end-of-input, expecting `end' or dummy end (SyntaxError\e[m)\e[m\n# ./lib/rspec/core/configuration.rb:2144:in `load_file_.../rspec/core/runner.rb:89:in `run'\n# ./lib/rspec/core/runner.rb:71:in `run'\n# ./lib/rspec/core/runner.rb:45:in `invoke'\n# exe/rspec:4:in `<main>'\n# \n#   Showing full backtrace because every line was filtered out.\n#   See docs for RSpec::Configuration#backtrace_exclusion_patterns and\n#   RSpec::Configuration#backtrace_inclusion_patterns for more information.\n\n\nFinished in n.nnnn seconds (files took n.nnnn seconds to load)\n0 examples, 0 failures, 1 error occurred outside of examples\n\n" to include "SyntaxError:\n  --> ./tmp/aruba/broken_file.rb\n  Unmatched keyword, missing `end' ?\n    1  class WorkInProgress\n  > 2    def initialize(arg)\n    3    def foo\n    4    end\n    5  end\n"
       Diff:
       @@ -1,91 +1,181 @@
       -SyntaxError:\n  --> ./tmp/aruba/broken_file.rb\n  Unmatched keyword, missing `end' ?\n    1  class WorkInProgress\n  > 2    def initialize(arg)\n    3    def foo\n    4    end\n    5  end\n
       +
       +While loading ./broken_file a `raise SyntaxError` occurred, RSpec will now quit.
       +Failure/Error: __send__(method, file)
       +
       +SyntaxError:
       +  --> ./tmp/aruba/broken_file.rb
       +
       +  Unmatched keyword, missing `end' ?
       +
       +    1  class WorkInProgress
       +  > 2    def initialize(arg)
       +    3    def foo
       +    4    end
       +    5  end
       +  
       +  ./tmp/aruba/broken_file.rb:5: syntax error, unexpected end-of-input, expecting `end' or dummy end (SyntaxError)
       +# ./lib/rspec/core/configuration.rb:2144:in `load_file_handling_errors'
       +# ./lib/rspec/core/configuration.rb:1601:in `block in requires='
       +# ./lib/rspec/core/configuration.rb:1600:in `each'
       +# ./lib/rspec/core/configuration.rb:1600:in `requires='
       +# ./lib/rspec/core/configuration_options.rb:117:in `block in process_options_into'
       +# ./lib/rspec/core/configuration_options.rb:116:in `each'
       +# ./lib/rspec/core/configuration_options.rb:116:in `process_options_into'
       +# ./lib/rspec/core/configuration_options.rb:22:in `configure'
       +# ./lib/rspec/core/runner.rb:132:in `configure'
       +# ./lib/rspec/core/runner.rb:99:in `setup'
       +# ./lib/rspec/core/runner.rb:86:in `run'
       +# ./lib/rspec/core/runner.rb:71:in `run'
       +# ./spec/support/aruba_support.rb:53:in `block (3 levels) in run_command'
       +# /usr/share/gems/gems/rspec-support-3.13.1/lib/rspec/support/spec/with_isolated_stderr.rb:9:in `with_isolated_stderr'
       +# ./spec/support/aruba_support.rb:52:in `block (2 levels) in run_command'
       +# /usr/share/gems/gems/aruba-2.2.0/lib/aruba/platforms/local_environment.rb:22:in `call'
       +# /usr/share/gems/gems/aruba-2.2.0/lib/aruba/platforms/unix_platform.rb:79:in `with_environment'
       +# /usr/share/gems/gems/aruba-2.2.0/lib/aruba/api/core.rb:222:in `block in with_environment'
       +# /usr/share/gems/gems/aruba-2.2.0/lib/aruba/platforms/unix_environment_variables.rb:189:in `nest'
       +# /usr/share/gems/gems/aruba-2.2.0/lib/aruba/api/core.rb:220:in `with_environment'
       +# /usr/share/gems/gems/aruba-2.2.0/lib/aruba/api/core.rb:80:in `cd'
       +# ./spec/support/aruba_support.rb:51:in `block in run_command'
       +# ./spec/spec_helper.rb:65:in `handle_current_dir_change'
       +# ./spec/support/aruba_support.rb:50:in `run_command'
       +# ./spec/integration/spec_file_load_errors_spec.rb:218:in `block (4 levels) in <top (required)>'
       +# /usr/share/gems/gems/rspec-support-3.13.1/lib/rspec/support/spec/in_sub_process.rb:24:in `block in in_sub_process'
       +# /usr/share/gems/gems/rspec-support-3.13.1/lib/rspec/support/spec/in_sub_process.rb:20:in `fork'
       +# /usr/share/gems/gems/rspec-support-3.13.1/lib/rspec/support/spec/in_sub_process.rb:20:in `in_sub_process'
       +# ./spec/integration/spec_file_load_errors_spec.rb:215:in `block (3 levels) in <top (required)>'
       +# ./lib/rspec/core/example.rb:263:in `instance_exec'
       +# ./lib/rspec/core/example.rb:263:in `block in run'
       +# ./lib/rspec/core/example.rb:511:in `block in with_around_and_singleton_context_hooks'
       +# ./lib/rspec/core/example.rb:468:in `block in with_around_example_hooks'
       +# ./lib/rspec/core/hooks.rb:486:in `block in run'
       +# ./lib/rspec/core/hooks.rb:626:in `block in run_around_example_hooks_for'
       +# ./lib/rspec/core/example.rb:352:in `call'
       +# ./spec/support/sandboxing.rb:16:in `block (3 levels) in <top (required)>'
       +# ./lib/rspec/core/sandbox.rb:29:in `sandboxed'
       +# ./spec/support/sandboxing.rb:7:in `block (2 levels) in <top (required)>'
       +# ./lib/rspec/core/example.rb:457:in `instance_exec'
       +# ./lib/rspec/core/example.rb:457:in `instance_exec'
       +# ./lib/rspec/core/hooks.rb:390:in `execute_with'
       +# ./lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
       +# ./lib/rspec/core/example.rb:352:in `call'
       +# ./lib/rspec/core/hooks.rb:629:in `run_around_example_hooks_for'
       +# ./lib/rspec/core/hooks.rb:486:in `run'
       +# ./lib/rspec/core/example.rb:468:in `with_around_example_hooks'
       +# ./lib/rspec/core/example.rb:511:in `with_around_and_singleton_context_hooks'
       +# ./lib/rspec/core/example.rb:259:in `run'
       +# ./lib/rspec/core/example_group.rb:646:in `block in run_examples'
       +# ./lib/rspec/core/example_group.rb:642:in `map'
       +# ./lib/rspec/core/example_group.rb:642:in `run_examples'
       +# ./lib/rspec/core/example_group.rb:607:in `run'
       +# ./lib/rspec/core/example_group.rb:608:in `block in run'
       +# ./lib/rspec/core/example_group.rb:608:in `map'
       +# ./lib/rspec/core/example_group.rb:608:in `run'
       +# ./lib/rspec/core/runner.rb:121:in `block (3 levels) in run_specs'
       +# ./lib/rspec/core/runner.rb:121:in `map'
       +# ./lib/rspec/core/runner.rb:121:in `block (2 levels) in run_specs'
       +# ./lib/rspec/core/configuration.rb:2097:in `with_suite_hooks'
       +# ./lib/rspec/core/runner.rb:116:in `block in run_specs'
       +# ./lib/rspec/core/reporter.rb:74:in `report'
       +# ./lib/rspec/core/runner.rb:115:in `run_specs'
       +# ./lib/rspec/core/runner.rb:89:in `run'
       +# ./lib/rspec/core/runner.rb:71:in `run'
       +# ./lib/rspec/core/runner.rb:45:in `invoke'
       +# exe/rspec:4:in `<main>'
       +# 
       +#   Showing full backtrace because every line was filtered out.
       +#   See docs for RSpec::Configuration#backtrace_exclusion_patterns and
       +#   RSpec::Configuration#backtrace_inclusion_patterns for more information.
       +
       +
       +Finished in n.nnnn seconds (files took n.nnnn seconds to load)
       +0 examples, 0 failures, 1 error occurred outside of examples
     # ./spec/integration/spec_file_load_errors_spec.rb:227:in `block (4 levels) in <top (required)>'
     # ./spec/integration/spec_file_load_errors_spec.rb:215:in `block (3 levels) in <top (required)>'
     # ./spec/support/sandboxing.rb:16:in `block (3 levels) in <top (required)>'
     # ./spec/support/sandboxing.rb:7:in `block (2 levels) in <top (required)>'

Finished in 15.47 seconds (files took 0.72626 seconds to load)
2234 examples, 1 failure, 6 pending

This is due to the change:
ruby/ruby@226cfda
ruby/syntax_suggest#232

@mtasaka
Copy link
Author

mtasaka commented Nov 17, 2024

simple workaround:

iff -urp -x examples.txt rspec-core-3.13.2.orig/spec/integration/spec_file_load_errors_spec.rb rspec-core-3.13.2/spec/integration/spec_file_load_errors_spec.rb
--- rspec-core-3.13.2.orig/spec/integration/spec_file_load_errors_spec.rb       2024-11-17 15:44:24.856119952 +0900
+++ rspec-core-3.13.2/spec/integration/spec_file_load_errors_spec.rb    2024-11-17 16:39:55.929770026 +0900
@@ -224,6 +224,7 @@ RSpec.describe 'Spec file load errors' d
 
           # A fix was backported to 3.2.3
           if RUBY_VERSION > '3.2.2'
+            formatted_output.gsub!(/\n+/m, "\n")
             expect(formatted_output).to include unindent(<<-EOS)
             SyntaxError:
               --> ./tmp/aruba/broken_file.rb

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

1 participant