Cleanup test files on Windows after executing test binary #1910
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.
The test results on Windows include a lot of noise after most tests:
Could not remove temporary directory: The process cannot access the file because it is being used by another process
These temporary folders can build up after time (many GB in my case). In particular the files which are still held are the logging file and the store/wallet store database files. The logger is set up as a singleton for the duration of the program, so is not easily closed. It's also a nightmare trying to stop the store/wallet store in
node::stop
as other stuff can still execute in the background which can talk to the database, pendingalarm
operations in particular. So we need to wait until the node destructor has finished. I could probably add a "stopped" flag in a load of places, but I feel like it could introduce problems and this is only for tests do didn't want to add any regression risks.An option would be to change all test to use test fixtures and make use of the
TearDown ()
function to contain the cleaning logic. But it involves changing every test, e.g:TEST (wallet, update_work_action)
becomes:
TEST_F (TestFixtureWithTearDownImplemented, wallet.update_work_action)
Not very ideal, but it would mean all platforms would clean up correctly after each test is run. I will leave this option open for debate.
For now, I've implemented conditional compilation so that on Windows the cleaning up only happens at the end of the test executable. This does mean that early exiting in any test will not clean up any proceeding but it seems better than nothing (and also removes the noisey output). The other platforms remain unchanged.