You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplify LibraryContainer hierarchy and tests (#4121)
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.
0 commit comments