teodesian / Selenium-Remote-Driver

Perl Bindings to the Selenium Webdriver server
174 stars 90 forks source link

Can't locate object method "redefine" via package "Test::MockModule" #465

Closed eserte closed 3 years ago

eserte commented 3 years ago

On a few of my smoker systems the test suite fails:

Can't locate object method "redefine" via package "Test::MockModule" at t/01-driver.t line 138.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 14.
t/01-driver.t ........................... 
Dubious, test returned 255 (wstat 65280, 0xff00)
All 14 subtests passed 
t/01-webdriver3.t ....................... ok
Can't locate object method "redefine" via package "Test::MockModule" at t/02-webelement.t line 51.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 8.
t/02-webelement.t ....................... 
Dubious, test returned 255 (wstat 65280, 0xff00)
All 8 subtests passed 
... (etc) ...

Statistical analysis suggests that this happens if Test::MockModule is too old --- with 0.11 it fails, with 0.170.0 and newer it passes:

****************************************************************
Regression 'mod:Test::MockModule'
****************************************************************
Name                   Theta          StdErr     T-stat
[0='const']           0.0000          0.0000       0.00
[1='eq_0.11']         0.0000          0.0000       3.58
[2='eq_0.170.0']          1.0000          0.0000    2989289543712861.00
[3='eq_0.171.0']          1.0000          0.0000    2315493723958374.50
[4='eq_0.174.0']          1.0000          0.0000    3135193323188562.50
[5='eq_0.175.0']          1.0000          0.0000    2989289543712860.00
[6='eq_0.176.0']          1.0000          0.0000    3250073423995314.00

R^2= 1.000, N= 93, K= 7
****************************************************************
teodesian commented 3 years ago

Read my mind. Was gonna look into this tomorrow, thanks for checking.

Will patch tomorrow morning.

teodesian commented 3 years ago

v0.13 was when felipe added redefine() so I'll pin to that

eserte commented 3 years ago

@teodesian: Is the change supposed to be in 1.41? The diff between 1.40 and 1.41 does not show any relevant changes, just version increases: https://metacpan.org/diff/file?target=TEODESIAN/Selenium-Remote-Driver-1.41/&source=TEODESIAN%2FSelenium-Remote-Driver-1.40

teodesian commented 3 years ago

Gave it another shot. These things happen, will keep an eye out

teodesian commented 3 years ago

oof. I guess

use MODULE VERSION

doesn't work? Looks like the CPANTesters reports are still giving out 'no redefine' despite using a version with the method.

I'm seriously tempted to take the nuclear option on the table and

use v5.32.0

eserte commented 3 years ago

Well, just look at the version history of https://metacpan.org/release/Test-MockModule and you see the problem --- the author switched from 0.16 to v0.17.0. However when comparing the two versions the latter resolves to 0.017000, which is less than the older version. So everybody having Test::MockModule <= 0.16 installed can never upgrade automatically to the newer version, only by manually removing the old version.

teodesian commented 3 years ago

so, my only serious options are:

  1. Don't use redefine() ever
  2. SKIP_ALL if I detect any version lower than what I need with max paranoia
  3. Ignore CPANTESTERS

Fixing this is now low priority for me.

eserte commented 3 years ago
  1. Ask the Test::MockModule author to do a new release with a greater version (e.g. v0.170.0 or even v1.0.0).
  2. Ask the CPAN Tester people (for example me) to manually upgrade/delete the old Test::MockModule installations (but this does not help other real users which run into this situation)
teodesian commented 3 years ago

Like you've mentioned it'll just come up again for someone else if we go with 5. This will also happen for 3.

I consider 4. to be highly unlikely, so my practical option is just gonna be 1, as it'll be less work than 2.

In the old days I always used Least-Common-Denominator sets of functionality and deps for precisely these reasons. I guess it's time to go back to that.

Which probably means I need to quit writing perl, as I generally don't have to put up with this in node or rust.

eserte commented 3 years ago

@teodesian: Actually I did not look into the whole version history of Test::MockModule. The problematic switch between 0.16 and v0.17.0 was corrected in the following version, which was v0.170.0. So specifying v0.170.0 as the minimum version should be enough.

teodesian commented 3 years ago

ehhh, whatever. I replaced all usage of redefine() with mock() so it won't happen anymore.

Teaches me to not use new functionality in perl, I'm back to beating rocks together

eserte commented 3 years ago

Sorry, I have to comment again (in the hope that all parties learn something). I was wrong about Test::MockModule doing things wrong (well, it did with the v0.17.0 release, but this was corrected the very same day ny creating a v0.170.0 release).

The only problem was using v0.13.0 as the minimum version --- it should be 0.13.

teodesian commented 3 years ago

I just went by what was the needed versin in Changes. I guess I have to dig through backpan to find what it actually was.

This feels like it's the 'old versions of perl don't understand new version numbers' thing, but it shouldn't be thanks to using the normal tricks to require anything past 5.6.

Very interesting, thanks for looking into it. That said, I think I'm gonna keep my policy to be 'use deps as they were flash-frozen the day that perl version was first released' with modules like this that support perls as old as my nephews.

I suspect the smokers running these tests are of similar vintage, so I'll run into a similar problem eventually if I don't.

eserte commented 3 years ago

The problem is this line: https://metacpan.org/source/TEODESIAN/Selenium-Remote-Driver-1.42/t%2F01-driver.t#L9 By using "v" in the version specification you automatically switch to two-dot version numbers. That is, you actually specified v0.13.0. This translates to 0.013000, which satisfies essentially every Test::MockModule version ever released (except for 0.01).