Skip to content

Commit

Permalink
allowing enough time and retries for copied directory to be unlocked …
Browse files Browse the repository at this point in the history
…and deleted
  • Loading branch information
catdad committed Jul 8, 2020
1 parent 2b3c2bc commit 268713e
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,27 @@ describe('integration', () => {
return path.resolve(dir, fixturename);
};

beforeEach(async () => {
before(async () => {
dir = await createCopy();
});
afterEach(async () => {
fs.remove(dir);
after(async function () {
// this can take a bit of time because the folder remains locked
// for a little while (usually round 15 seconds)
this.timeout(45000);
let remainingMilliseconds = 30 * 1000;
const end = Date.now() + remainingMilliseconds;

while (remainingMilliseconds > 0) {
try {
await fs.remove(dir);
remainingMilliseconds = 0;
} catch (e) {
remainingMilliseconds = end - Date.now();
if (e.code !== 'EBUSY' && remainingMilliseconds > 0) {
throw e;
}
}
}
});

it('ignores files defined by negative patterns', async () => {
Expand Down

0 comments on commit 268713e

Please sign in to comment.