-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Simplify mocking IO in PackageManager, add a test for add-path
#2881
Conversation
✅ PR OK, no changes in deprecations or warnings Total deprecations: 0 Total warnings: 0 Build statistics: statistics (-before, +after)
executable size=5356064 bin/dub
-rough build time=63s
+rough build time=62s Full build output
|
aefb2cb
to
ff06a7a
Compare
Moving it to PackageManager allows us to call PackageManager.existsFile, allowing us to mock a lot more things.
This allows us to test the behavior of the base class much better, by overriding the last IO function, readText.
This is one more step towards removing our mocking of refresh_.
We can finally test the full features of the base function, as we are now mocking the IO, not the logic.
Mocking IO is required for writeLocalPackageList, as we want to test the 'add-path' behavior. While it is not a big concern for overrides, as they are deprecated and we are unlikely to add new tests, it is easy to do, and already done for reading them.
This will prove handy when writting tests that require multiple invocation of Dub, such as idempotence tests, or things like add-path which currently don't propagate their change through Dub as they are one shot commands.
So that tests can use 'NativePath' and 'toNativeString'.
This was not currently tested explicitly, and is currently the reason why we still have the scanning behavior in the PackageManager. In order to remove the scanning behavior and have the PM lazily scan packages, we first must add test to ensure there will be no further regression.
ff06a7a
to
1082f7f
Compare
This has quite a lot of improvements I need to fix other bugs (write more tests), so I'm going to merge it in ~10 hours unless anyone objects. |
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 reviewed the commits one-by-one and everything looks moving in the right direction. Awesome work @Geod24 👍
@s-ludwig : I would like to remove the scanning behavior in
PackageManager
. This is a source of pain for us, as it slows down builds, including with @atilaneves Reggae.Last time that introduced a regression which you fixed in #2481 .
This simplifies mocking quite a bit and introduces a test for it (see last commit /
source/dub/test/other.d
in the diff).If you could have a quick look at the test and confirm that it covers your use case ?