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

Fix a random test failure for Performance/Sum #458

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

Earlopain
Copy link
Contributor

@Earlopain Earlopain commented Aug 21, 2024

The skipped tests fail with the following command: bundle exec rspec ./spec/rubocop/cli/autocorrect_spec.rb[1:1] ./spec/rubocop/cop/performance/sum_spec.rb[1:13] --seed 26805 (or maybe not, there is something extra going on I don't understand)

This is fine to do in the rubocop main repository but here we inject additional config values that are not restored.

There are some things going on that I don't entirely understand:

  • Why only failures in this one file
  • Why did koic not manage to reproduce with the exact same seed
  • Why did the failures seemingly disappear and reappear without any changes to the code

But regardless, this is more correct. Removing the JRuby skips is a bit of a guess on my side but I don't see what else should prevent them from passing. Let's see how it goes.

Bit of extra context starting at #398 (comment)

The skipped tests fail with the following command:
`bundle exec rspec ./spec/rubocop/cli/autocorrect_spec.rb[1:1] ./spec/rubocop/cop/performance/sum_spec.rb[1:13] --seed 26805`

This is fine to do in the rubocop main repository but here we inject
additional config values that are not restored.

There are some things going on that I don't entirely understand:
* Why only failures in this one file
* Why did koic not manage to reproduce with the exact same seed
* Why did the failures seemingly disappear and reappear without any changes to the code

But regardless, this is more correct
@koic
Copy link
Member

koic commented Aug 22, 2024

Why did koic not manage to reproduce with the exact same seed

When I ran it again, the following error occurred:

$ bundle exec rspec './spec/rubocop/cli/autocorrect_spec.rb[1:1]' './spec/rubocop/cop/performance/sum_spec.rb[1:13]' --seed 26805
Run options: include {:ids=>{"./spec/rubocop/cli/autocorrect_spec.rb"=>["1:1"], "./spec/rubocop/cop/performance/sum_spec.rb"=>["1:13"]}}

Randomized with seed 26805
.F

Failures:

  1) RuboCop::Cop::Performance::Sum autocorrects `&:+` when initial value is not provided
     Failure/Error:
       expect_correction(<<~RUBY)
         array.sum
       RUBY

     RuntimeError:
       Expected correction but no corrections were made
     # ./spec/rubocop/cop/performance/sum_spec.rb:278:in 'block (3 levels) in <top (required)>'

Finished in 0.39425 seconds (files took 2.33 seconds to load)
2 examples, 1 failure

Failed examples:

rspec './spec/rubocop/cop/performance/sum_spec.rb[1:13]' # RuboCop::Cop::Performance::Sum autocorrects `&:+` when initial value is not provided

Randomized with seed 26805

@Earlopain
Copy link
Contributor Author

Ah, right. Yeah, that is what I was getting as well. Still, I would expect this to come up all the for other cops as well and I don't know why Sum is special here.

@koic koic merged commit 6f170ac into rubocop:master Aug 22, 2024
14 checks passed
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

Successfully merging this pull request may close these issues.

2 participants