Start sorting DSL generators by class name #478
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
DSL generation runs are currently not repeatable since we don't load DSL generators in any specific order, but the generators could add order dependent items to the constants they decorate, like
include
calls. Thus, depending on what order generators run, we end up getting a different order ofinclude
s which breaks all assumptions of determinism from the generator.This didn't used to be a problem since Parlour used to sort
include
calls in the output, so the output ended up being the same regardless of the order theinclude
s were added. However, sortinginclude
s is a bad idea in general, since the behaviour of the resulting constant could be drastically different so the RBI gem does not do that.Implementation
We started sorting DSL generators by class name for now. Since we don't have dependencies between generators yet, this simple sorting should be enough and safe. In the future, if we add dependencies between generators, we can replace this with some kind of topological sort, like how Bundler does.
Tests
Extended existing DSL CLI test to add 2 in repo fake generators that decorate the
Post
class with included modules. If runs start being indeterministic again, expected order ofinclude
s should fail these tests.