Skip to content

Conversation

@srawlins
Copy link
Member

This one is a bit of a story; I could break it up if that would help the review, but here goes:

  1. I saw that LibraryContainer, an abstract mixin class, was (a) mixed into Category, and (b) extended by Package. Weird. So I tried to make it a base class, a proper superclass of those two. Well that showed me the two test classes: TestLibraryContainer and TestLibraryContainerSdk.
  2. What do those two test classes do? They existed for a mere 2 test cases in model_test.dart. These test cases just test the compareTo logic in LibraryContainer, but it is not terribly obvious how they test them. The TestLibraryContainer seemed very generic, and odd, with its own ContainerOrder list. In practice, Categories are always ordered by the --category-order option, and Packages are always ordered by the --package-order option. There's no need to test some generic ordering system.
  3. So, I was able to tear down those test classes and their two test cases, and rewrite them in a more real-world test group in packages_test.dart.
  4. This also allows isSdk and enclosingName to be simple, final fields on LibraryContainer, and enclosingName can be private. And then containerOrder only needs to stay public in order to override.
  5. This refactoring did require some fixes in the writePackage test function: (a) it was writing a .packages file, and (b) it was writing hard-coded package names into a package config file. We fix this by passing in a list of dependency names.

Copy link
Contributor

@szakarias szakarias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Nice! And thanks for the detailed PR description. Makes review much easier.

@srawlins srawlins merged commit 6d5e133 into dart-lang:main Oct 27, 2025
13 checks passed
@srawlins srawlins deleted the library-container branch October 27, 2025 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants