-
Notifications
You must be signed in to change notification settings - Fork 174
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
Avoid memoizing dependencies #1926
Conversation
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.
I think it's fine to not storing the dependencies, but do we also need to change the timing test library and typechecker are detected? To me it's quite odd that we now need to rely on apply_options
to detect those attributes even though they actually don't care about the options.
IMO we can just also call gather_dependencies
in initialize
too and keep the same behaviour.
Why do you find it odd? To me it's a bit more organized to have default values in the initialize and then all automatic detection happens once we apply user options. |
I'd expect state = GlobalState.new
state.apply_options({})
assert_equal("rails", state.test_library) |
This ends up being a consequence of Sorbet. It's not possible to have non-nilable instance variables without putting them in the initializer, but we are not able to fully initialize the Ideally, we would do something like this def run_initialize(message)
@global_state = GlobalState.new(message)
end But there's no way to get proper typing that way. Even if we duplicate the dependencies array and move the test framework and type checker detection inside It just wouldn't impact those specific tests, but conceptually, the global state is never fully initialized until the user options are applied. |
1326854
to
019c876
Compare
e050ed1
to
f2e23de
Compare
As stated in this comment: #1926 (comment) A global state is not fully initialized without `apply_options` being called, which the current `with_server` test helper does not do. This means that when tests are being run, detections around things like test library are not performed, which can yield unexpected results to developers, especially addon authors. This commit changes the `with_server` test helper to call `apply_options`.
As stated in this comment: #1926 (comment) A global state is not fully initialized without `apply_options` being called, which the current `with_server` test helper does not do. This means that when tests are being run, detections around things like test library are not performed, which can yield unexpected results to developers, especially addon authors. This commit changes the `with_server` test helper to call `apply_options`.
Motivation
I noticed that we were keeping the project's dependencies in memory forever, but we only need that during boot. Let's save some memory and allow the array to be garbage collected.
Implementation
I turned the array into a local variable that gets used during
apply_options
.Automated Tests
Adapted our tests.