From 89340b179867f9fb2a26325bd8be828ddfbeed17 Mon Sep 17 00:00:00 2001 From: rictic Date: Mon, 4 Sep 2023 21:49:57 -0700 Subject: [PATCH] Clean up service test. --- src/logging/default-logger.ts | 4 ++-- src/test/service.test.ts | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/logging/default-logger.ts b/src/logging/default-logger.ts index c9a74587f..d9af3f12b 100644 --- a/src/logging/default-logger.ts +++ b/src/logging/default-logger.ts @@ -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( diff --git a/src/test/service.test.ts b/src/test/service.test.ts index 16994e015..b7a48fdae 100644 --- a/src/test/service.test.ts +++ b/src/test/service.test.ts @@ -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({ @@ -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); @@ -1372,7 +1371,6 @@ test( standard: { command: standard.command, files: ['input'], - output: [], }, }, }, @@ -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/); @@ -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); }), );