Skip to content

Commit

Permalink
test: fix occasional directory not empty error in e2e (#4428)
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy authored Jan 24, 2025
1 parent acbb42a commit beeb2a8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions e2e/cases/cli/watch-files/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { awaitFileExists, getRandomPort, rspackOnlyTest } from '@e2e/helper';
import { expect, test } from '@playwright/test';

const dist = path.join(__dirname, 'dist');
const distIndexFile = path.join(__dirname, 'dist/static/js/index.js');
const tempConfigPath = './test-temp-config.ts';
const tempOutputFile = path.join(__dirname, 'test-temp-file.txt');
const extraConfigFile = path.join(__dirname, tempConfigPath);
Expand All @@ -29,7 +30,7 @@ rspackOnlyTest(
});

// the first build
await awaitFileExists(dist);
await awaitFileExists(distIndexFile);

fs.rmSync(tempOutputFile, { force: true });
// temp config changed and trigger rebuild
Expand All @@ -55,9 +56,9 @@ rspackOnlyTest(
},
});

await awaitFileExists(dist);
await awaitFileExists(distIndexFile);

fs.rmSync(dist, { recursive: true });
fs.rmSync(distIndexFile);
// temp config changed
fs.writeFileSync(extraConfigFile, 'export default 2;');

Expand All @@ -79,9 +80,11 @@ rspackOnlyTest(
},
});

await awaitFileExists(dist);
// Fix occasional 'directory not empty' error when wait and rm dist.
// Sometimes the dist directory exists, but the files in the dist directory have not been completely written.
await awaitFileExists(distIndexFile);

fs.rmSync(dist, { recursive: true });
fs.rmSync(distIndexFile);
// temp config changed
fs.writeFileSync(extraConfigFile, 'export default 2;');

Expand Down

1 comment on commit beeb2a8

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
plugins ✅ success
rspress ✅ success
rslib ✅ success
examples ✅ success

Please sign in to comment.