Clean up temporary directories in tests (#151)

Summary:
The `loadRepository` test tries to clean up temporary directories, but
failed to do so because the directories were not empty. The cleanup hook
threw an error, but this error was silenced by Jest due to [a known
bug][1] that was fixed a few days ago. We can fix this by asking `tmp`
to clean up directories even if they are not empty, using the
`unsafeCleanup` option.

[1]: https://github.com/facebook/jest/issues/3266

Test Plan:
While running `watch -n 0.1 'ls /tmp | grep "tmp-.*" | wc -l'`, run
tests. Note that the number increases by five and then drops down again;
before this patch, it would increase by 5 and then stay there.

wchargin-branch: clean-up-tmpdirs
This commit is contained in:
William Chargin 2018-04-26 19:34:23 -07:00 committed by GitHub
parent 3679529bef
commit 6f9941b526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -13,7 +13,7 @@ afterAll(() => {
});
function mkdtemp() {
const result = tmp.dirSync();
const result = tmp.dirSync({unsafeCleanup: true});
cleanups.push(() => result.removeCallback());
return result.name;
}