Skip to content

Commit 8eacea9

Browse files
committed
fix(test): ensure lock cleanup before manual mkdir in tests
Add explicit cleanup before manually creating lock directories in tests. This prevents EEXIST errors when tests don't fully clean up or run in quick succession.
1 parent 7bc0870 commit 8eacea9

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/process-lock.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ describe('process-lock', () => {
7171
})
7272

7373
it('should remove stale lock and acquire', async () => {
74+
// Ensure lock doesn't exist before we manually create it.
75+
if (existsSync(lockPath)) {
76+
await safeDelete(lockPath, { force: true })
77+
}
78+
7479
// Create a lock directory manually.
7580
mkdirSync(lockPath)
7681

@@ -88,6 +93,11 @@ describe('process-lock', () => {
8893
})
8994

9095
it('should retry with exponential backoff', async () => {
96+
// Ensure lock doesn't exist before we manually create it.
97+
if (existsSync(lockPath)) {
98+
await safeDelete(lockPath, { force: true })
99+
}
100+
91101
// Create lock manually to simulate another process holding it.
92102
mkdirSync(lockPath)
93103

@@ -112,6 +122,11 @@ describe('process-lock', () => {
112122
})
113123

114124
it('should respect custom stale timeout', async () => {
125+
// Ensure lock doesn't exist before we manually create it.
126+
if (existsSync(lockPath)) {
127+
await safeDelete(lockPath, { force: true })
128+
}
129+
115130
// Create a lock that's 6 seconds old.
116131
mkdirSync(lockPath)
117132
const sixSecondsAgo = Date.now() - 6_000

0 commit comments

Comments
 (0)