Skip to content

Commit

Permalink
Clean up service test.
Browse files Browse the repository at this point in the history
  • Loading branch information
rictic committed Sep 5, 2023
1 parent 14a255d commit 89340b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/logging/default-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,10 @@ export class DefaultLogger implements Logger {
);
}
case 'dependency not fully tracked': {
return `the service depends on ${labelForScript(
return `the service depends on [${labelForScript(
this.rootPackageDir,
stringToScriptReference(notFullyTrackedReason.dependency),
)}`;
)}] which must always be run`;
}
case 'no files field': {
throw new Error(
Expand Down
30 changes: 16 additions & 14 deletions src/test/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,6 @@ for (const failureMode of ['continue', 'no-new']) {
// v v
// service standard
timeout(async ({rig}) => {
rig.env.WIREIT_LOGGER = 'simple';
const service = await rig.newCommand();
const standard = await rig.newCommand();
await rig.writeAtomic({
Expand Down Expand Up @@ -665,21 +664,21 @@ for (const failureMode of ['continue', 'no-new']) {
const wireit = rig.exec('npm run entrypoint --watch', {
env: {WIREIT_FAILURES: failureMode},
});
// await wireit.waitForLog(
// /50% \[1 \/ 2\] \[2 running\] \[1 service\] standard/,
// );
await wireit.waitForLog(
/50% \[1 \/ 2\] \[2 running\] \[1 service\] standard/,
);
const serviceInv = await service.nextInvocation();
const standardInv1 = await standard.nextInvocation();
standardInv1.exit(1);
// await wireit.waitForLog(/❌ \[standard\] exited with exit code 1/);
// await wireit.waitForLog(/❌ 1 script failed/);
await wireit.waitForLog(/ \[standard\] exited with exit code 1/);
await wireit.waitForLog(/ 1 script failed/);
await new Promise((resolve) => setTimeout(resolve, 100));
assert.ok(serviceInv.isRunning);

await rig.write('input/standard', '2');
const standardInv2 = await standard.nextInvocation();
standardInv2.exit(0);
// await wireit.waitForLog(/✅ Ran 2 scripts and skipped 0/);
await wireit.waitForLog(/ Ran 1 script and skipped 0/);
await new Promise((resolve) => setTimeout(resolve, 100));
assert.ok(serviceInv.isRunning);

Expand Down Expand Up @@ -1372,7 +1371,6 @@ test(
standard: {
command: standard.command,
files: ['input'],
output: [],
},
},
},
Expand Down Expand Up @@ -1417,7 +1415,7 @@ test(
await wireit.waitForLog(/\[standard\] Executed successfully/);
await service.nextInvocation();
await wireit.waitForLog(
/\[service\] Service stopped because a dependency changed: \[standard\]/,
/\[service\] Service stopped because the service depends on \[standard\] which must always be run/,
);
await wireit.waitForLog(/\[service\] Service starting.../);
await wireit.waitForLog(/\[service\] Service ready/);
Expand All @@ -1444,16 +1442,20 @@ test(
// restart, because the fingerprint has been restored to what it was before
// the failure.
await rig.write('input', '3');
await wireit.waitForLog(/\[standard\] Restored from cache/);
await wireit.waitForLog(
/🔁 \[service\] File "input" was changed, triggering a new run/,
);
await wireit.waitForLog(/\[standard\] Running command/);
(await standard.nextInvocation()).exit(0);
await wireit.waitForLog(/\[service\] Watching for file changes/);
await new Promise((resolve) => setTimeout(resolve, 50));
assert.equal(service.numInvocations, 2);
assert.equal(standard.numInvocations, 4);
assert.equal(service.numInvocations, 3);
assert.equal(standard.numInvocations, 5);

wireit.kill();
await wireit.exit;
assert.equal(service.numInvocations, 2);
assert.equal(standard.numInvocations, 4);
assert.equal(service.numInvocations, 3);
assert.equal(standard.numInvocations, 5);
}),
);

Expand Down

0 comments on commit 89340b1

Please sign in to comment.