-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Freeze formula definition once first instance is created #13753
Conversation
Review period will end on 2022-08-26 at 02:12:21 UTC. |
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.
Great work here! Would like to see a bunch more comments (particularly explaining why the code is doing what it is doing rather than what it is doing) and there's a brew typecheck
failure but otherwise this looks great!
Review period ended. |
Had to do 88a8def to get |
Thanks @Bo98! |
This seems to be causing issues for |
I guess we have no test coverage of that? Which is surprising. Will take a look. |
Defining methods inside `test` blocks is no longer supported as of Homebrew/brew#13753. Fixes a CI failure spotted in Homebrew#106925: Error: scry: failed An exception occurred within a child process: FrozenError: can't modify frozen class
Defining methods inside `test` blocks is no longer supported as of Homebrew/brew#13753. Fixes a CI failure spotted in #106925: Error: scry: failed An exception occurred within a child process: FrozenError: can't modify frozen class
This is no longer supported as of Homebrew/brew#13753. See Homebrew#109599.
This is no longer supported as of Homebrew/brew#13753. See Homebrew#109599.
This is no longer supported as of Homebrew/brew#13753. See Homebrew#109599.
This is no longer supported as of Homebrew/brew#13753. See Homebrew#109599.
This is no longer supported as of Homebrew/brew#13753. See Homebrew#109599.
This is no longer supported as of Homebrew/brew#13753. See #109599.
This is no longer supported as of Homebrew/brew#13753. See #109599.
This is no longer supported as of Homebrew/brew#13753. See #109599.
This PR implements safety mechanisms to avoid hitting the unsupported behaviour of modifying a formula's definition (e.g. adding a dependency) after the first instance has been created. Note that you will still have the ability to do so if such changes are applied to only that particular instance of the formula (typically involving private API). Only changes to the global definition on the class-level is prevented, as those would have an undefined effect on existing instances.
Each commit can be separated into a separate PR, but the order matters as each commit depends on the previous one.
Details on each one, in reverse order:
self.class.freeze
at the begininning ofinitialize
.SoftwareSpec
etc too, I've made it propagate the freeze request down.dup
theSoftwareSpec
s when create the instance, which means the spec stored at instance level will be unfrozen. I've added code to also propagate thedup
down too so everything on instance level is unfrozen and cannot propagate back up to the global definition.self.inherited
method, which act's effectively like a class-level constructor.Formula["foo"].class.depends_on "bar"
, which this PR was aiming to prevent being possibleself.inherited
, some variables are no longer initialised on the Formula base class. CallingFormula.new
on this base class never really worked anyway since it doesn't make sense so I made it an explicit error when this action is performed.BuildEnvironment::DSL
better.satisfy
conidition so it was a no-op requirement.CaskDependent
was incorrect in a few ways (e.g. it displayed "x86_64" for a formula requiring arm64).class.to_s
which is typically not human-readable.brew deps --include-requirements