Skip to content

Commit 5ff82eb

Browse files
committed
fix: test
1 parent 33f7ac7 commit 5ff82eb

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

workspaces/libnpmexec/test/with-lock.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@ const getTempDir = () => fs.realpathSync(os.tmpdir())
1111
t.test('concurrent locking', async (t) => {
1212
const dir = fs.mkdtempSync(path.join(getTempDir(), 'test-'))
1313
const events = []
14-
const lockPromises = [
15-
withLock(dir, async () => {
16-
events.push('lock1 acquired')
17-
await setTimeout(100)
18-
events.push('lock1 released')
19-
}),
20-
withLock(dir, async () => {
21-
events.push('lock2 acquired')
22-
await setTimeout(100)
23-
events.push('lock2 released')
24-
return 'lock2'
25-
}),
26-
]
27-
await Promise.all(lockPromises)
14+
const lockPromise1 = withLock(dir, async () => {
15+
events.push('lock1 acquired')
16+
await setTimeout(100)
17+
events.push('lock1 released')
18+
})
19+
await setTimeout(50)
20+
const lockPromise2 = withLock(dir, async () => {
21+
events.push('lock2 acquired')
22+
await setTimeout(100)
23+
events.push('lock2 released')
24+
return 'lock2'
25+
})
26+
await Promise.all([lockPromise1, lockPromise2])
2827
t.same(events, [
2928
'lock1 acquired',
3029
'lock1 released',

0 commit comments

Comments
 (0)