dry-rb / dry-logic

Predicate logic with rule composition
https://dry-rb.org/gems/dry-logic/
MIT License
179 stars 66 forks source link

Test failures on i386 architecture #91

Closed dleidert closed 2 years ago

dleidert commented 2 years ago

The tests fail in an i386 environment. The failures are reproducible:

https://salsa.debian.org/ruby-team/ruby-dry-logic/-/jobs/2211364 https://salsa.debian.org/ruby-team/ruby-dry-logic/-/jobs/2211361

Failures:
  1) Dry::Logic::Predicates#size? with value size is less than n behaves like a failing predicate is expected to equal false
     Failure/Error: expect(predicate.call(*args)).to be(false)
       expected false
            got true
     Shared Example Group: "a failing predicate" called from ./spec/unit/predicates/size_spec.rb:48
     # ./spec/shared/predicates.rb:56:in `block (3 levels) in <top (required)>'
     # ./spec/shared/predicates.rb:55:in `each'
     # ./spec/shared/predicates.rb:55:in `block (2 levels) in <top (required)>'
  2) Dry::Logic::Predicates#size? when value size is greater than n behaves like a failing predicate is expected to equal false
     Failure/Error: expect(predicate.call(*args)).to be(false)
       expected false
            got true
     Shared Example Group: "a failing predicate" called from ./spec/unit/predicates/size_spec.rb:34
     # ./spec/shared/predicates.rb:56:in `block (3 levels) in <top (required)>'
     # ./spec/shared/predicates.rb:55:in `each'
     # ./spec/shared/predicates.rb:55:in `block (2 levels) in <top (required)>'
  3) Dry::Logic::Predicates#size? when value size is equal to n behaves like a passing predicate is expected to equal true
     Got 2 failures:
     Shared Example Group: "a passing predicate" called from ./spec/unit/predicates/size_spec.rb:20
     3.1) Failure/Error: expect(predicate.call(*args)).to be(true)
            expected true
                 got false
          # ./spec/shared/predicates.rb:46:in `block (3 levels) in <top (required)>'
          # ./spec/shared/predicates.rb:45:in `each'
          # ./spec/shared/predicates.rb:45:in `block (2 levels) in <top (required)>'
     3.2) Failure/Error: expect(predicate.call(*args)).to be(true)
            expected true
                 got false
          # ./spec/shared/predicates.rb:46:in `block (3 levels) in <top (required)>'
          # ./spec/shared/predicates.rb:45:in `each'
          # ./spec/shared/predicates.rb:45:in `block (2 levels) in <top (required)>'
  4) Dry::Logic::Predicates#min_size? when value size is greater than n behaves like a passing predicate is expected to equal true
     Failure/Error: expect(predicate.call(*args)).to be(true)
       expected true
            got false
     Shared Example Group: "a passing predicate" called from ./spec/unit/predicates/min_size_spec.rb:20
     # ./spec/shared/predicates.rb:46:in `block (3 levels) in <top (required)>'
     # ./spec/shared/predicates.rb:45:in `each'
     # ./spec/shared/predicates.rb:45:in `block (2 levels) in <top (required)>'
  5) Dry::Logic::Predicates#min_size? when value size is equal to n behaves like a passing predicate is expected to equal true
     Failure/Error: expect(predicate.call(*args)).to be(true)
       expected true
            got false
     Shared Example Group: "a passing predicate" called from ./spec/unit/predicates/min_size_spec.rb:34
     # ./spec/shared/predicates.rb:46:in `block (3 levels) in <top (required)>'
     # ./spec/shared/predicates.rb:45:in `each'
     # ./spec/shared/predicates.rb:45:in `block (2 levels) in <top (required)>'
  6) Dry::Logic::Predicates#max_size? with value size is greater than n behaves like a failing predicate is expected to equal false
     Failure/Error: expect(predicate.call(*args)).to be(false)
       expected false
            got true
     Shared Example Group: "a failing predicate" called from ./spec/unit/predicates/max_size_spec.rb:48
     # ./spec/shared/predicates.rb:56:in `block (3 levels) in <top (required)>'
     # ./spec/shared/predicates.rb:55:in `each'
     # ./spec/shared/predicates.rb:55:in `block (2 levels) in <top (required)>'
Finished in 0.32758 seconds (files took 0.42136 seconds to load)
399 examples, 6 failures
flash-gordon commented 2 years ago

Not sure what to do about it, the issue doesn't bring much clarity on why this happens

dleidert commented 2 years ago

Do you have a suggestion on how we could provide useful debugging information? I'll run it inside our i386 machines and see i fI can reproduce it.

dleidert commented 2 years ago

I've created an i386 environment on my machine, cloned the project, ran bundler and then rake spec and I see the same errors. I'd therefor expect that you should be able to reproduce those issues within an i386 environment as well. Ruby version is 2.7.

flash-gordon commented 2 years ago

Right, this is actually a but in tests, they use the size? predicate improperly (by passing an integer instead of a collection or a string). Integer#size returns different values depending on the architecture so here we are...

flash-gordon commented 2 years ago

@dleidert this should do it, thanks for the report

dleidert commented 2 years ago

Looks good. The build succeeds now.