-
Notifications
You must be signed in to change notification settings - Fork 19
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
Ruby 3.2 yast2-storage-ng sometimes fails to build, diff in Marshal.dump #1321
Conversation
Today's findings: The My plan is to accept the reality of the nondeterministic ordering and instead remove the gorilla from the room: WIP: irb(main):001:0> class C; def initialize(attrs); attrs.each { |a| instance_variable_set(a.to_sym, a.to_s) } ; end ; end
=> :initialize
irb(main):004:0> a = C.new([])
=> #<C:0x0000563aa62d27b0>
irb(main):005:0> b = C.new([])
=> #<C:0x0000563aa618b848>
irb(main):006:0> a == b
=> false
irb(main):007:0> module EqualByIVs; def ==(other); return if other.class != self.class; instance_variables.all? { |iv| instance_variable_get(iv) == other.instance_variable_get(iv) }; end; end
=> :==
irb(main):008:0> class C; include EqualByIVs; end
=> C
irb(main):009:0> a == b
=> true |
A word-diff is useful: git diff --color-words /var/tmp/build-root-standard/tmp/dump[12]
… values" This reverts commit 21b4a13. The debug print revealed that there is sometimes a different ordering of instance variables in VolumeSpecification than the one used by initialize/apply_defaults Don't know why, just live with it now
ad50a9b
to
984e54b
Compare
984e54b
to
90387ef
Compare
It started to matter once we defined SubvolSpecification#==
90387ef
to
2ebbab7
Compare
2ebbab7
to
567058c
Compare
# specify the instance variables used for the comparison: | ||
# https://github.com/yast/yast-yast2/blob/master/library/general/src/lib/yast2/equatable.rb | ||
module EqualByInstanceVariables | ||
# TODO: move to base library? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
✔️ Public Jenkins job #452 successfully finished |
✔️ Internal Jenkins job #1138 successfully finished |
Problem
Ruby 3.2 yast2-storage-ng sometimes fails to build, diff in Marshal.dump
The failing test means to check that a new
ProposalSettings
is in fact equal to the original one, and does so by dumping and reloading the two objects withMarshal
. It fails in case the two objects differ in the order in which their instance variables were assigned.Solution
Instead of using
Marshal
, addProposalSettings#==
.Do it by introducing a simple module,
EqualByInstanceVariables
, including it in that class and a couple of others that are used by it.Gory details: everything I've learned about equality in Ruby along the way, very messy so far: https://gist.github.com/mvidner/eb10bf4d70f0df5c1073a2229fd4491e
Testing
Screenshots
N/A