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 newly with ruby3.4.0dev #997

Open
mtasaka opened this issue Dec 10, 2024 · 1 comment
Open

rspec testsuite failure newly with ruby3.4.0dev #997

mtasaka opened this issue Dec 10, 2024 · 1 comment

Comments

@mtasaka
Copy link

mtasaka commented Dec 10, 2024

ruby 3.4 is to be released on 2024-Dec-25,
and trying with ruby 3.4.0dev (2024-12-10 master cfc2b21a05) +PRISM [x86_64-linux]
ruby/ruby@cfc2b21

guard git head d9def79
causes additional rspec test failure compared with #996 as:

  6) Guard::Plugin#hook notifies the hooks
     Failure/Error: self.class.notify(self, hook_name.to_sym, *args)

       #<Guard::Plugin (class)> received :notify with unexpected arguments
         expected: (#<Guard::Dummy:14240 @name=dummy @group= @watchers=[] @callbacks=[] @options={engine: #<Guard::Engine... @options={watchdirs: "/builddir/build/GIT/guard", inline: "guard :dummy", no_interactions: true}>}>, :run_all_begin)
              got: (#<Guard::Dummy:14240 @name=dummy @group= @watchers=[] @callbacks=[] @options={engine: #<Guard::Engine... @options={watchdirs: "/builddir/build/GIT/guard", inline: "guard :dummy", no_interactions: true}>}>, :_begin)
       Diff:
       @@ -1,3 +1,3 @@
        [#<Guard::Dummy:14240 @name=dummy @group= @watchers=[] @callbacks=[] @options={engine: #<Guard::Engine:14256 @options={watchdirs: "/builddir/build/GIT/guard", inline: "guard :dummy", no_interactions: true}>}>,
       - :run_all_begin]
       + :_begin]
     # ./lib/guard/plugin.rb:127:in 'Guard::Plugin#hook'
     # ./spec/lib/guard/plugin_spec.rb:180:in 'Guard::Dummy#run_all'
     # ./spec/lib/guard/plugin_spec.rb:189:in 'block (3 levels) in <top (required)>'

  7) Guard::Plugin#hook accepts extra arguments
     Failure/Error: self.class.notify(self, hook_name.to_sym, *args)

       #<Guard::Plugin (class)> received :notify with unexpected arguments
         expected: (#<Guard::Dummy:14280 @name=dummy @group= @watchers=[] @callbacks=[] @options={engine: #<Guard::Engine... @options={watchdirs: "/builddir/build/GIT/guard", inline: "guard :dummy", no_interactions: true}>}>, :stop_begin, "args")
              got: (#<Guard::Dummy:14280 @name=dummy @group= @watchers=[] @callbacks=[] @options={engine: #<Guard::Engine... @options={watchdirs: "/builddir/build/GIT/guard", inline: "guard :dummy", no_interactions: true}>}>, :_begin, "args")
       Diff:
       @@ -1,4 +1,4 @@
        [#<Guard::Dummy:14280 @name=dummy @group= @watchers=[] @callbacks=[] @options={engine: #<Guard::Engine:14296 @options={watchdirs: "/builddir/build/GIT/guard", inline: "guard :dummy", no_interactions: true}>}>,
       - :stop_begin,
       + :_begin,
         "args"]
     # ./lib/guard/plugin.rb:127:in 'Guard::Plugin#hook'
     # ./spec/lib/guard/plugin_spec.rb:210:in 'Guard::Dummy#stop'
     # ./spec/lib/guard/plugin_spec.rb:222:in 'block (3 levels) in <top (required)>'
@mtasaka
Copy link
Author

mtasaka commented Dec 10, 2024

So this is due to ruby3.4 backtrace change:

https://github.com/ruby/ruby/blob/cfc2b21a05ab1a6602a70331d895924851a527e9/NEWS.md?plain=1#L233-L250

Especially, now single quote is used instead of backtick .
So now this regex does not match:

calling_method = caller(1..1).first[/`([^']*)'/, 1]

Extra change is that backtrace now shows class name.

Fix for this would be something like:

diff --git a/lib/guard/plugin.rb b/lib/guard/plugin.rb
index 469a06b..17a5885 100644
--- a/lib/guard/plugin.rb
+++ b/lib/guard/plugin.rb
@@ -116,7 +116,8 @@ module Guard
     #
     def hook(event, *args)
       hook_name = if event.is_a? Symbol
-                    calling_method = caller(1..1).first[/`([^']*)'/, 1]
+                    calling_method = caller(1..1).first[/['`]([^']*)'/, 1]
+                    calling_method.gsub!(/^.*#/, "")
                     "#{calling_method}_#{event}"
                   else
                     event

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