mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-03 02:21:44 +00:00
test(hooks): stabilize concurrency burst reporting
This commit is contained in:
parent
fe9dcd009d
commit
003aa2b7b6
1 changed files with 15 additions and 18 deletions
|
|
@ -778,27 +778,24 @@ describe('PreToolUse concurrency guard (integration)', () => {
|
|||
`;
|
||||
|
||||
const N = 10;
|
||||
const claimers = Array.from({ length: N }, () =>
|
||||
spawn(process.execPath, ['-e', claimerScript], {
|
||||
const claimers = Array.from({ length: N }, () => {
|
||||
const child = spawn(process.execPath, ['-e', claimerScript], {
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
detached: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
const decision = new Promise<string>((resolve) => {
|
||||
let buf = '';
|
||||
child.stdout!.on('data', (d) => {
|
||||
buf += d.toString();
|
||||
if (buf.includes('\n')) resolve(buf.split('\n')[0]);
|
||||
});
|
||||
child.on('exit', () => resolve(buf.split('\n')[0] || 'EXIT'));
|
||||
});
|
||||
return { child, decision };
|
||||
});
|
||||
try {
|
||||
// Wait until every claimer has printed its decision.
|
||||
const decisions = await Promise.all(
|
||||
claimers.map(
|
||||
(c) =>
|
||||
new Promise<string>((resolve) => {
|
||||
let buf = '';
|
||||
c.stdout!.on('data', (d) => {
|
||||
buf += d.toString();
|
||||
if (buf.includes('\n')) resolve(buf.split('\n')[0]);
|
||||
});
|
||||
c.on('exit', () => resolve(buf.split('\n')[0] || 'EXIT'));
|
||||
}),
|
||||
),
|
||||
);
|
||||
const decisions = await Promise.all(claimers.map((c) => c.decision));
|
||||
const claimedCount = decisions.filter((d) => d.startsWith('CLAIMED:')).length;
|
||||
const skippedCount = decisions.filter((d) => d === 'SKIPPED').length;
|
||||
|
||||
|
|
@ -823,7 +820,7 @@ describe('PreToolUse concurrency guard (integration)', () => {
|
|||
} finally {
|
||||
for (const c of claimers) {
|
||||
try {
|
||||
c.kill();
|
||||
c.child.kill();
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue