Skip to content

Commit 285a5cc

Browse files
committed
Increase timeout and set flakiness
1 parent a343980 commit 285a5cc

File tree

1 file changed

+138
-126
lines changed

1 file changed

+138
-126
lines changed

src/test/failures.test.ts

Lines changed: 138 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import {suite} from 'uvu';
88
import * as assert from 'uvu/assert';
9-
import {rigTest} from './util/rig-test.js';
9+
import {DEFAULT_UVU_TIMEOUT, rigTest} from './util/rig-test.js';
1010
import type {ExitResult} from './util/test-rig.js';
1111

1212
const test = suite<object>();
@@ -483,152 +483,164 @@ test(
483483

484484
test(
485485
'unexpected input file deletion during fingerprinting',
486-
rigTest(async ({rig}) => {
487-
// Spam our input file with writes and deletes out-of-band with wireit.
488-
let spamming = true;
489-
void (async () => {
490-
while (spamming) {
491-
try {
492-
await rig.write('input', Math.random());
493-
await rig.delete('input');
494-
} catch {
495-
// Sometimes we get an EPERM error here on Windows CI. Probably
496-
// writing too fast, just sleep a bit.
497-
await new Promise((resolve) => setTimeout(resolve, 1000));
486+
rigTest(
487+
async ({rig}) => {
488+
// Spam our input file with writes and deletes out-of-band with wireit.
489+
let spamming = true;
490+
void (async () => {
491+
while (spamming) {
492+
try {
493+
await rig.write('input', Math.random());
494+
await rig.delete('input');
495+
} catch {
496+
// Sometimes we get an EPERM error here on Windows CI. Probably
497+
// writing too fast, just sleep a bit.
498+
await new Promise((resolve) => setTimeout(resolve, 1000));
499+
}
498500
}
499-
}
500-
})();
501-
502-
let finalExit: ExitResult;
503-
try {
504-
// It could take multiple attempts to hit the race condition.
505-
for (let i = 0; i < 100; i++) {
506-
const failer = await rig.newCommand();
507-
await rig.write({
508-
'package.json': {
509-
scripts: {
510-
main: 'wireit',
511-
failer: 'wireit',
512-
},
513-
wireit: {
514-
main: {
515-
dependencies: ['failer'],
501+
})();
502+
503+
let finalExit: ExitResult;
504+
try {
505+
// It could take multiple attempts to hit the race condition.
506+
for (let i = 0; i < 100; i++) {
507+
const failer = await rig.newCommand();
508+
await rig.write({
509+
'package.json': {
510+
scripts: {
511+
main: 'wireit',
512+
failer: 'wireit',
516513
},
517-
failer: {
518-
command: failer.command,
519-
files: ['input'],
520-
output: ['output'],
514+
wireit: {
515+
main: {
516+
dependencies: ['failer'],
517+
},
518+
failer: {
519+
command: failer.command,
520+
files: ['input'],
521+
output: ['output'],
522+
},
521523
},
522524
},
523-
},
524-
});
525-
const wireit = rig.exec('npm run main');
526-
// If the error occurs, it will happen before invocation.
527-
const exitOrInvocation = await Promise.race([
528-
wireit.exit,
529-
failer.nextInvocation(),
530-
]);
531-
if ('code' in exitOrInvocation) {
532-
if (exitOrInvocation.stderr.includes('EPERM')) {
533-
// See note about EPERM above, it can also happen within wireit.
534-
await new Promise((resolve) => setTimeout(resolve, 1000));
535-
continue;
536-
} else {
537-
finalExit = exitOrInvocation;
538-
break;
525+
});
526+
const wireit = rig.exec('npm run main');
527+
// If the error occurs, it will happen before invocation.
528+
const exitOrInvocation = await Promise.race([
529+
wireit.exit,
530+
failer.nextInvocation(),
531+
]);
532+
if ('code' in exitOrInvocation) {
533+
if (exitOrInvocation.stderr.includes('EPERM')) {
534+
// See note about EPERM above, it can also happen within wireit.
535+
await new Promise((resolve) => setTimeout(resolve, 1000));
536+
continue;
537+
} else {
538+
finalExit = exitOrInvocation;
539+
break;
540+
}
539541
}
540-
}
541-
await rig.write('output', '1');
542-
exitOrInvocation.exit(0);
543-
finalExit = await wireit.exit;
544-
if (finalExit.code !== 0) {
545-
if (finalExit.stderr.includes('EPERM')) {
546-
// See note about EPERM above, it can also happen within wireit.
547-
await new Promise((resolve) => setTimeout(resolve, 1000));
548-
} else {
549-
break;
542+
await rig.write('output', '1');
543+
exitOrInvocation.exit(0);
544+
finalExit = await wireit.exit;
545+
if (finalExit.code !== 0) {
546+
if (finalExit.stderr.includes('EPERM')) {
547+
// See note about EPERM above, it can also happen within wireit.
548+
await new Promise((resolve) => setTimeout(resolve, 1000));
549+
} else {
550+
break;
551+
}
550552
}
551553
}
554+
} finally {
555+
spamming = false;
552556
}
553-
} finally {
554-
spamming = false;
555-
}
556557

557-
assert.equal(finalExit!.code, 1);
558-
assert.match(
559-
finalExit!.stderr,
560-
`[failer] Input file "${rig.resolve('input')}" was deleted unexpectedly.` +
561-
` Is another process writing to the same location?`,
562-
);
563-
}),
558+
assert.equal(finalExit!.code, 1);
559+
assert.match(
560+
finalExit!.stderr,
561+
`[failer] Input file "${rig.resolve('input')}" was deleted unexpectedly.` +
562+
` Is another process writing to the same location?`,
563+
);
564+
},
565+
{
566+
flaky: true,
567+
ms: DEFAULT_UVU_TIMEOUT * 2,
568+
},
569+
),
564570
);
565571

566572
test(
567573
'unexpected output file deletion during manifest generation',
568-
rigTest(async ({rig}) => {
569-
// Spam our output file with writes and deletes out-of-band with wireit.
570-
let spamming = true;
571-
void (async () => {
572-
while (spamming) {
573-
try {
574-
await rig.write('output', Math.random());
575-
await rig.delete('output');
576-
} catch {
577-
// Sometimes we get an EPERM error here on Windows CI. Probably
578-
// writing too fast, just sleep a bit.
579-
await new Promise((resolve) => setTimeout(resolve, 1000));
574+
rigTest(
575+
async ({rig}) => {
576+
// Spam our output file with writes and deletes out-of-band with wireit.
577+
let spamming = true;
578+
void (async () => {
579+
while (spamming) {
580+
try {
581+
await rig.write('output', Math.random());
582+
await rig.delete('output');
583+
} catch {
584+
// Sometimes we get an EPERM error here on Windows CI. Probably
585+
// writing too fast, just sleep a bit.
586+
await new Promise((resolve) => setTimeout(resolve, 1000));
587+
}
580588
}
581-
}
582-
})();
583-
584-
let finalExit: ExitResult;
585-
try {
586-
// It could take multiple attempts to hit the race condition.
587-
for (let i = 0; i < 100; i++) {
588-
const failer = await rig.newCommand();
589-
await rig.write({
590-
'package.json': {
591-
scripts: {
592-
main: 'wireit',
593-
failer: 'wireit',
594-
},
595-
wireit: {
596-
main: {
597-
dependencies: ['failer'],
589+
})();
590+
591+
let finalExit: ExitResult;
592+
try {
593+
// It could take multiple attempts to hit the race condition.
594+
for (let i = 0; i < 100; i++) {
595+
const failer = await rig.newCommand();
596+
await rig.write({
597+
'package.json': {
598+
scripts: {
599+
main: 'wireit',
600+
failer: 'wireit',
598601
},
599-
failer: {
600-
command: failer.command,
601-
files: ['input'],
602-
output: ['output'],
602+
wireit: {
603+
main: {
604+
dependencies: ['failer'],
605+
},
606+
failer: {
607+
command: failer.command,
608+
files: ['input'],
609+
output: ['output'],
610+
},
603611
},
604612
},
605-
},
606-
});
607-
const wireit = rig.exec('npm run main');
608-
const failerInv = await failer.nextInvocation();
609-
await rig.write('output', '1');
610-
failerInv.exit(0);
611-
finalExit = await wireit.exit;
612-
if (finalExit.code !== 0) {
613-
if (finalExit.stderr.includes('EPERM')) {
614-
// See note about EPERM above, it can also happen within wireit.
615-
await new Promise((resolve) => setTimeout(resolve, 1000));
616-
} else {
617-
break;
613+
});
614+
const wireit = rig.exec('npm run main');
615+
const failerInv = await failer.nextInvocation();
616+
await rig.write('output', '1');
617+
failerInv.exit(0);
618+
finalExit = await wireit.exit;
619+
if (finalExit.code !== 0) {
620+
if (finalExit.stderr.includes('EPERM')) {
621+
// See note about EPERM above, it can also happen within wireit.
622+
await new Promise((resolve) => setTimeout(resolve, 1000));
623+
} else {
624+
break;
625+
}
618626
}
619627
}
628+
} finally {
629+
spamming = false;
620630
}
621-
} finally {
622-
spamming = false;
623-
}
624631

625-
assert.equal(finalExit!.code, 1);
626-
assert.match(
627-
finalExit!.stderr,
628-
`[failer] Output file "${rig.resolve('output')}" was deleted unexpectedly.` +
629-
` Is another process writing to the same location?`,
630-
);
631-
}),
632+
assert.equal(finalExit!.code, 1);
633+
assert.match(
634+
finalExit!.stderr,
635+
`[failer] Output file "${rig.resolve('output')}" was deleted unexpectedly.` +
636+
` Is another process writing to the same location?`,
637+
);
638+
},
639+
{
640+
flaky: true,
641+
ms: DEFAULT_UVU_TIMEOUT * 2,
642+
},
643+
),
632644
);
633645

634646
test.run();

0 commit comments

Comments
 (0)