mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
chore(tests): maybe fix flaky flock tests (#12122)
This commit is contained in:
parent
4c8ab33def
commit
7c0173df27
1 changed files with 5 additions and 8 deletions
|
@ -78,19 +78,17 @@ async function checkFirstBlocksSecond(opts: {
|
|||
await firstProcess.signal();
|
||||
await firstProcess.waitSignal(); // entering signal
|
||||
await firstProcess.waitSignal(); // entered signal
|
||||
await sleep(20);
|
||||
// signal the second to enter the lock
|
||||
await secondProcess.signal();
|
||||
await secondProcess.waitSignal(); // entering signal
|
||||
await sleep(20);
|
||||
await sleep(100);
|
||||
// signal to the first to exit the lock
|
||||
await firstProcess.signal();
|
||||
await sleep(20);
|
||||
// collect the final output so we know it's exited the lock
|
||||
const firstPsTimes = await firstProcess.getTimes();
|
||||
// signal to the second to exit the lock
|
||||
await secondProcess.waitSignal(); // entered signal
|
||||
await secondProcess.signal();
|
||||
// collect the remaining JSON output of both processes
|
||||
const firstPsTimes = await firstProcess.getTimes();
|
||||
const secondPsTimes = await secondProcess.getTimes();
|
||||
return firstPsTimes.exitTime < secondPsTimes.enterTime;
|
||||
} finally {
|
||||
|
@ -126,10 +124,9 @@ function runFlockTestProcess(opts: { exclusive: boolean; sync: boolean }) {
|
|||
|
||||
// record the exit time and wait a little bit before releasing
|
||||
// the lock so that the enter time of the next process doesn't
|
||||
// occur at the same time as this exit time (do double the
|
||||
// windows clock resolution)
|
||||
// occur at the same time as this exit time
|
||||
const exitTime = new Date().getTime();
|
||||
await new Promise((resolve) => setTimeout(resolve, 30));
|
||||
Deno.sleepSync(100);
|
||||
|
||||
// release the lock
|
||||
${opts.sync ? "Deno.funlockSync(rid);" : "await Deno.funlock(rid);"}
|
||||
|
|
Loading…
Reference in a new issue