From e4379d2a45f267340618c6a64ec9f287dff93367 Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Tue, 29 Aug 2023 19:22:18 -0700 Subject: [PATCH 1/5] Some small changes to prepare for the quiet logger. Adds some more events, logs them more consistently, puts the logger in control of how it's wrapped when in watch mode. --- src/analyzer.ts | 28 ++++++++++++- src/event.ts | 36 +++++++++++++++-- src/execution/service.ts | 24 ++++++----- src/ide.ts | 6 +-- src/logging/default-logger.ts | 75 +++++++++++++++++++++-------------- src/logging/logger.ts | 5 +++ src/test/util/uvu-timeout.ts | 4 ++ src/watcher.ts | 14 +++++-- 8 files changed, 142 insertions(+), 50 deletions(-) diff --git a/src/analyzer.ts b/src/analyzer.ts index fd701c201..9c62d2365 100644 --- a/src/analyzer.ts +++ b/src/analyzer.ts @@ -29,6 +29,7 @@ import type { ScriptReferenceString, } from './config.js'; import type {Agent} from './cli-options.js'; +import {Logger} from './logging/logger.js'; export interface AnalyzeResult { config: Result; @@ -147,9 +148,11 @@ export class Analyzer { private readonly _ongoingWorkPromises: Array> = []; private readonly _relevantConfigFilePaths = new Set(); private readonly _agent: Agent; + private readonly _logger: Logger | undefined; - constructor(agent: Agent, filesystem?: FileSystem) { + constructor(agent: Agent, logger?: Logger, filesystem?: FileSystem) { this._agent = agent; + this._logger = logger; this._packageJsonReader = new CachingPackageJsonReader(filesystem); } @@ -200,6 +203,29 @@ export class Analyzer { async analyze( root: ScriptReference, extraArgs: string[] | undefined + ): Promise { + this._logger?.log({ + type: 'info', + detail: 'analysis-started', + script: root, + }); + const analyzeResult = await this._actuallyAnalyze(root, extraArgs); + let rootScriptConfig = undefined; + if (analyzeResult.config.ok) { + rootScriptConfig = analyzeResult.config.value; + } + this._logger?.log({ + type: 'info', + detail: 'analysis-completed', + script: root, + rootScriptConfig, + }); + return analyzeResult; + } + + private async _actuallyAnalyze( + root: ScriptReference, + extraArgs: string[] | undefined ): Promise { // We do 2 walks through the dependency graph: // diff --git a/src/event.ts b/src/event.ts index 1401244a7..b31ac0c75 100644 --- a/src/event.ts +++ b/src/event.ts @@ -31,7 +31,7 @@ interface EventBase { // Success events // ------------------------------- -type Success = ExitZero | NoCommand | Fresh | Cached; +export type Success = ExitZero | NoCommand | Fresh | Cached; interface SuccessBase extends EventBase { @@ -313,7 +313,7 @@ export interface UnknownErrorThrown extends ErrorBase { // Output events // ------------------------------- -type Output = Stdout | Stderr; +export type Output = Stdout | Stderr; interface OutputBase extends EventBase { type: 'output'; @@ -338,14 +338,17 @@ export interface Stderr extends OutputBase { // Informational events // ------------------------------- -type Info = +export type Info = | ScriptRunning | ScriptLocked | OutputModified | WatchRunStart | WatchRunEnd + | ServiceProcessStarted | ServiceStarted | ServiceStopped + | AnalysisStarted + | AnalysisCompleted | GenericInfo; interface InfoBase @@ -377,6 +380,23 @@ export interface OutputModified extends InfoBase { detail: 'output-modified'; } +/** + * The analysis phase for an execution has begun, where we load package.json + * files, analyze their wireit configs, and build the dependency graph. + */ +export interface AnalysisStarted extends InfoBase { + detail: 'analysis-started'; +} + +/** + * The analysis phase for an execution has begun, where we load package.json + * files, analyze their wireit configs, and build the dependency graph. + */ +export interface AnalysisCompleted extends InfoBase { + detail: 'analysis-completed'; + rootScriptConfig: undefined | ScriptConfig; +} + /** * A watch mode iteration started. */ @@ -392,7 +412,15 @@ export interface WatchRunEnd extends InfoBase { } /** - * A service started running. + * A service process started running. + */ +export interface ServiceProcessStarted extends InfoBase { + detail: 'service-process-started'; +} + +/** + * A service started running and if it has a readyWhen condition, + * that condition is met. */ export interface ServiceStarted extends InfoBase { detail: 'service-started'; diff --git a/src/execution/service.ts b/src/execution/service.ts index f6c571d0b..f65455e93 100644 --- a/src/execution/service.ts +++ b/src/execution/service.ts @@ -262,6 +262,15 @@ export class ServiceScriptExecution extends BaseExecutionWithCommand { + this._logger.log({ + script: this._config, + type: 'info', + detail: 'service-stopped', + }); + }); } /** @@ -818,6 +827,11 @@ export class ServiceScriptExecution extends BaseExecutionWithCommand { diff --git a/src/logging/default-logger.ts b/src/logging/default-logger.ts index 6dda935c0..3bfc734b2 100644 --- a/src/logging/default-logger.ts +++ b/src/logging/default-logger.ts @@ -12,6 +12,7 @@ import type {Logger} from './logger.js'; import type {PackageReference, ScriptReference} from '../config.js'; import {DiagnosticPrinter} from '../error.js'; import {createRequire} from 'module'; +import {WatchLogger} from './watch-logger.js'; const getWireitVersion = (() => { let version: string | undefined; @@ -43,36 +44,9 @@ export class DefaultLogger implements Logger { this._diagnosticPrinter = new DiagnosticPrinter(this._rootPackageDir); } - /** - * Make a concise label for a script, or for just a package if we don't know - * the script name. If the package is different to the root package, it is - * disambiguated with a relative path. - */ - private _label(script: PackageReference | ScriptReference) { - const packageDir = script.packageDir; - const scriptName = 'name' in script ? script.name : undefined; - if (packageDir !== this._rootPackageDir) { - const relativePackageDir = pathlib - .relative(this._rootPackageDir, script.packageDir) - // Normalize to posix-style forward-slashes as the path separator, even - // on Windows which usually uses back-slashes. This way labels match the - // syntax used in the package.json dependency specifiers (which are - // already posix style). - .replace(pathlib.sep, pathlib.posix.sep); - if (scriptName !== undefined) { - return `${relativePackageDir}:${scriptName}`; - } else { - return relativePackageDir; - } - } else if (scriptName !== undefined) { - return scriptName; - } - return ''; - } - log(event: Event) { const type = event.type; - const label = this._label(event.script); + const label = labelForScript(this._rootPackageDir, event.script); const prefix = label !== '' ? ` [${label}]` : ''; switch (type) { default: { @@ -202,7 +176,8 @@ export class DefaultLogger implements Logger { } case 'dependency-invalid': { console.error( - `❌${prefix} Depended, perhaps indirectly, on ${this._label( + `❌${prefix} Depended, perhaps indirectly, on ${labelForScript( + this._rootPackageDir, event.dependency )} which could not be validated. Please file a bug at https://github.com/google/wireit/issues/new, mention this message, that you encountered it in wireit version ${getWireitVersion()}, and give information about your package.json files.` ); @@ -294,6 +269,10 @@ export class DefaultLogger implements Logger { console.log(`ℹ️${prefix} ${event.message}`); break; } + case 'service-process-started': { + console.log(`⬆️${prefix} Service starting...`); + break; + } case 'service-started': { console.log(`⬆️${prefix} Service started`); break; @@ -302,6 +281,10 @@ export class DefaultLogger implements Logger { console.log(`⬇️${prefix} Service stopped`); break; } + case 'analysis-started': + case 'analysis-completed': { + break; + } } } } @@ -310,4 +293,38 @@ export class DefaultLogger implements Logger { printMetrics(): void { // printMetrics() not used in default-logger. } + + getWatchLogger(): Logger { + return new WatchLogger(this); + } +} + +/** + * Make a concise label for a script, or for just a package if we don't know + * the script name. If the package is different to the root package, it is + * disambiguated with a relative path. + */ +export function labelForScript( + rootPackageDir: string, + script: ScriptReference | PackageReference +) { + const packageDir = script.packageDir; + const scriptName = 'name' in script ? script.name : undefined; + if (packageDir !== rootPackageDir) { + const relativePackageDir = pathlib + .relative(rootPackageDir, script.packageDir) + // Normalize to posix-style forward-slashes as the path separator, even + // on Windows which usually uses back-slashes. This way labels match the + // syntax used in the package.json dependency specifiers (which are + // already posix style). + .replace(pathlib.sep, pathlib.posix.sep); + if (scriptName !== undefined) { + return `${relativePackageDir}:${scriptName}`; + } else { + return relativePackageDir; + } + } else if (scriptName !== undefined) { + return scriptName; + } + return ''; } diff --git a/src/logging/logger.ts b/src/logging/logger.ts index 695247e0b..c61c459ca 100644 --- a/src/logging/logger.ts +++ b/src/logging/logger.ts @@ -12,4 +12,9 @@ import type {Event} from '../event.js'; export interface Logger { log(event: Event): void; printMetrics(): void; + + // Some loggers need additional logic when run in watch mode. + // If this method is present, we'll call it and use the result when in + // watch mode. + getWatchLogger?(): Logger; } diff --git a/src/test/util/uvu-timeout.ts b/src/test/util/uvu-timeout.ts index f5ab2364c..e46c4eccf 100644 --- a/src/test/util/uvu-timeout.ts +++ b/src/test/util/uvu-timeout.ts @@ -32,6 +32,10 @@ export const timeout = ( handler(...args), new Promise((_resolve, reject) => { timerId = setTimeout(() => { + // Log that we timed out, helpful to see when looking through logs + // when we started shutting down the rig because of a timeout, + // because all logs after this point aren't part of the normal test. + console.error('Test timed out.'); reject(new Error(`Test timed out after ${ms} milliseconds.`)); }, ms); }), diff --git a/src/watcher.ts b/src/watcher.ts index 788e8b630..da44cc123 100644 --- a/src/watcher.ts +++ b/src/watcher.ts @@ -11,7 +11,6 @@ import {Executor, FailureMode, ServiceMap} from './executor.js'; import {Logger} from './logging/logger.js'; import {Deferred} from './util/deferred.js'; import {WorkerPool} from './util/worker-pool.js'; -import {WatchLogger} from './logging/watch-logger.js'; import { ScriptConfig, ScriptReference, @@ -143,7 +142,7 @@ export class Watcher { ) { this._rootScript = rootScript; this._extraArgs = extraArgs; - this._logger = new WatchLogger(logger); + this._logger = logger.getWatchLogger?.() ?? logger; this._workerPool = workerPool; this._failureMode = failureMode; this._cache = cache; @@ -202,6 +201,15 @@ export class Watcher { if (this._latestRootScriptConfig === undefined) { void this._analyze(); } else { + // We already have a valid config, so we can skip the analysis step. + // but if the logger needs to know about the analysis, this lets + // it know. + this._logger.log({ + type: 'info', + detail: 'analysis-completed', + script: this._rootScript, + rootScriptConfig: this._latestRootScriptConfig, + }); void this._execute(this._latestRootScriptConfig); } return; @@ -223,7 +231,7 @@ export class Watcher { throw unexpectedState(this._state); } - const analyzer = new Analyzer(this._agent); + const analyzer = new Analyzer(this._agent, this._logger); const result = await analyzer.analyze(this._rootScript, this._extraArgs); if ((this._state as WatcherState) === 'aborted') { return; From f70cc2a76dfbc5c2c73e29fadc0b5adcf158e72f Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Tue, 29 Aug 2023 19:26:59 -0700 Subject: [PATCH 2/5] A few more minor changes --- .vscode/settings.json | 2 +- src/test/util/test-rig.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index bd4e2ab1f..f2746a833 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,6 @@ "javascript.preferences.importModuleSpecifierEnding": "js", "typescript.preferences.importModuleSpecifierEnding": "js", "editor.defaultFormatter": "esbenp.prettier-vscode", - "typescript.tsdk": "node_modules\\typescript\\lib", + "typescript.tsdk": "node_modules/typescript/lib", "typescript.enablePromptUseWorkspaceTsdk": true } diff --git a/src/test/util/test-rig.ts b/src/test/util/test-rig.ts index ce72da46a..a7ba1c131 100644 --- a/src/test/util/test-rig.ts +++ b/src/test/util/test-rig.ts @@ -113,7 +113,11 @@ export class WireitTestRig extends FilesystemTestRig { override async cleanup(): Promise { await Promise.all(this._commands.map((command) => command.close())); for (const child of this._activeChildProcesses) { - child.kill(); + // Force kill child processes, because we're cleaning up the test rig + // at the end of the test, and if any are still running then the test + // has probably failed from timeout. If the process is hung, we'll + // already see that from the timeout. + child.kill({force: true}); await child.exit; } await super.cleanup(); @@ -299,7 +303,7 @@ class ExecResult { /** * Kill the child process. */ - kill(): void { + kill({force} = {force: false}): void { if (!this.running) { throw new Error("Can't kill child process because it is not running"); } @@ -318,7 +322,11 @@ class ExecResult { // own process group. Passing the negative of the child's pid kills all // processes in the group (without the negative only the leader "sh" // process would be killed). - process.kill(-this._child.pid, 'SIGINT'); + if (force) { + process.kill(-this._child.pid, 9); + } else { + process.kill(-this._child.pid, 'SIGINT'); + } } } From 7990bcf61a236e5eb4281cac51b0ff5eb4517afd Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Tue, 29 Aug 2023 20:08:44 -0700 Subject: [PATCH 3/5] Add an additional uninteresting event --- src/logging/watch-logger.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/logging/watch-logger.ts b/src/logging/watch-logger.ts index 392d81770..974607c89 100644 --- a/src/logging/watch-logger.ts +++ b/src/logging/watch-logger.ts @@ -65,7 +65,8 @@ export class WatchLogger implements Logger { case 'failed-previous-watch-iteration': case 'watch-run-start': case 'start-cancelled': - case 'locked': { + case 'locked': + case 'analysis-completed': { return false; } } From 3dfc2c92e7ab2250126e1232f6bb70fd5bba9c34 Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Tue, 29 Aug 2023 21:16:30 -0700 Subject: [PATCH 4/5] Separate out tests that don't require network access. --- package.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a35b0dd5f..8fca023b4 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "format:check": "prettier . -c", "test": "wireit", "test:headless": "wireit", + "test:local": "wireit", "test:analysis": "wireit", "test:basic": "wireit", "test:cache-github": "wireit", @@ -75,10 +76,16 @@ ] }, "test:headless": { + "dependencies": [ + "test:cache-github", + "test:local" + ] + }, + "test:local": { + "#comment": "Run tests that don't require network access.", "dependencies": [ "test:analysis", "test:basic", - "test:cache-github", "test:cache-local", "test:clean", "test:cli-options", From 7517c9dbae7956cf25297848ffb43f6972ad37ee Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Tue, 29 Aug 2023 22:37:36 -0700 Subject: [PATCH 5/5] Address review comments --- src/analyzer.ts | 8 +++---- src/caching/github-actions-cache.ts | 8 +++---- src/event.ts | 33 ++++++++++++++++++++--------- src/execution/service.ts | 4 ++-- src/logging/default-logger.ts | 6 +++--- src/test/service.test.ts | 31 ++++++++++++++------------- src/test/util/test-rig.ts | 2 +- 7 files changed, 52 insertions(+), 40 deletions(-) diff --git a/src/analyzer.ts b/src/analyzer.ts index 9c62d2365..333cfd503 100644 --- a/src/analyzer.ts +++ b/src/analyzer.ts @@ -210,15 +210,13 @@ export class Analyzer { script: root, }); const analyzeResult = await this._actuallyAnalyze(root, extraArgs); - let rootScriptConfig = undefined; - if (analyzeResult.config.ok) { - rootScriptConfig = analyzeResult.config.value; - } this._logger?.log({ type: 'info', detail: 'analysis-completed', script: root, - rootScriptConfig, + rootScriptConfig: analyzeResult.config.ok + ? analyzeResult.config.value + : undefined, }); return analyzeResult; } diff --git a/src/caching/github-actions-cache.ts b/src/caching/github-actions-cache.ts index 64e5e4188..02a1a9032 100644 --- a/src/caching/github-actions-cache.ts +++ b/src/caching/github-actions-cache.ts @@ -189,7 +189,7 @@ export class GitHubActionsCache implements Cache { this._logger.log({ script, type: 'info', - detail: 'generic', + detail: 'cache-info', message: `Output was too big to be cached: ` + `${Math.round(tarballBytes / GB)}GB > ` + @@ -364,7 +364,7 @@ export class GitHubActionsCache implements Cache { this._logger.log({ script, type: 'info', - detail: 'generic', + detail: 'cache-info', message: `Connection error from GitHub Actions service, caching disabled. ` + 'Detail: ' + @@ -381,7 +381,7 @@ export class GitHubActionsCache implements Cache { this._logger.log({ script, type: 'info', - detail: 'generic', + detail: 'cache-info', message: `Hit GitHub Actions cache rate limit, caching disabled.`, }); } @@ -392,7 +392,7 @@ export class GitHubActionsCache implements Cache { this._logger.log({ script, type: 'info', - detail: 'generic', + detail: 'cache-info', message: `GitHub Actions service is unavailable, caching disabled.`, }); } diff --git a/src/event.ts b/src/event.ts index b31ac0c75..8755bc392 100644 --- a/src/event.ts +++ b/src/event.ts @@ -31,6 +31,9 @@ interface EventBase { // Success events // ------------------------------- +/** + * A script finished successfully. + */ export type Success = ExitZero | NoCommand | Fresh | Cached; interface SuccessBase @@ -70,6 +73,9 @@ export interface Cached extends SuccessBase { // Failure events // ------------------------------- +/** + * A problem was encountered. + */ export type Failure = | ExitNonZero | ExitSignal @@ -313,6 +319,9 @@ export interface UnknownErrorThrown extends ErrorBase { // Output events // ------------------------------- +/** + * A script emitted output. + */ export type Output = Stdout | Stderr; interface OutputBase extends EventBase { @@ -338,6 +347,9 @@ export interface Stderr extends OutputBase { // Informational events // ------------------------------- +/** + * Something happened, neither success nor failure, though often progress. + */ export type Info = | ScriptRunning | ScriptLocked @@ -345,11 +357,11 @@ export type Info = | WatchRunStart | WatchRunEnd | ServiceProcessStarted - | ServiceStarted + | ServiceReady | ServiceStopped | AnalysisStarted | AnalysisCompleted - | GenericInfo; + | CacheInfo; interface InfoBase extends EventBase { @@ -381,7 +393,7 @@ export interface OutputModified extends InfoBase { } /** - * The analysis phase for an execution has begun, where we load package.json + * The analysis phase for a run has begun, where we load package.json * files, analyze their wireit configs, and build the dependency graph. */ export interface AnalysisStarted extends InfoBase { @@ -389,8 +401,9 @@ export interface AnalysisStarted extends InfoBase { } /** - * The analysis phase for an execution has begun, where we load package.json - * files, analyze their wireit configs, and build the dependency graph. + * The analysis phase for a run has completed. If successful, we have a + * rootScriptConfig with a full dependency graph. If unsuccessful, it is + * undefined, and there will be a Failure event with more information. */ export interface AnalysisCompleted extends InfoBase { detail: 'analysis-completed'; @@ -422,8 +435,8 @@ export interface ServiceProcessStarted extends InfoBase { * A service started running and if it has a readyWhen condition, * that condition is met. */ -export interface ServiceStarted extends InfoBase { - detail: 'service-started'; +export interface ServiceReady extends InfoBase { + detail: 'service-ready'; } /** @@ -434,9 +447,9 @@ export interface ServiceStopped extends InfoBase { } /** - * A generic info event. + * An advisory event about caching. */ -export interface GenericInfo extends InfoBase { - detail: 'generic'; +export interface CacheInfo extends InfoBase { + detail: 'cache-info'; message: string; } diff --git a/src/execution/service.ts b/src/execution/service.ts index f65455e93..cbc84290d 100644 --- a/src/execution/service.ts +++ b/src/execution/service.ts @@ -852,7 +852,7 @@ export class ServiceScriptExecution extends BaseExecutionWithCommand(); test.before.each(async (ctx) => { try { ctx.rig = new WireitTestRig(); + process.env.SHOW_TEST_OUTPUT = 'true'; await ctx.rig.setup(); } catch (error) { // Uvu has a bug where it silently ignores failures in before and after, @@ -68,7 +69,7 @@ test( // The service starts because the consumer depends on it const serviceInv = await service.nextInvocation(); - await wireit.waitForLog(/Service started/); + await wireit.waitForLog(/Service ready/); // Confirm we show stdout/stderr from services serviceInv.stdout('service stdout'); @@ -150,11 +151,11 @@ test( // The service's own service dep must start first const serviceDepInv = await serviceDep.nextInvocation(); - await wireit.waitForLog(/\[serviceDep\] Service started/); + await wireit.waitForLog(/\[serviceDep\] Service ready/); // Now the main service can start const serviceInv = await service.nextInvocation(); - await wireit.waitForLog(/\[service\] Service started/); + await wireit.waitForLog(/\[service\] Service ready/); // The consumer starts and finishes const consumerInv = await consumer.nextInvocation(); @@ -410,9 +411,9 @@ test( // Services start in bottom-up order. const service2Inv = await service2.nextInvocation(); - await wireit.waitForLog(/\[service2\] Service started/); + await wireit.waitForLog(/\[service2\] Service ready/); const service1Inv = await service1.nextInvocation(); - await wireit.waitForLog(/\[service1\] Service started/); + await wireit.waitForLog(/\[service1\] Service ready/); // Wait a moment to ensure they keep running since the user hasn't killed // Wireit yet. @@ -503,9 +504,9 @@ for (const failureMode of ['continue', 'no-new', 'kill']) { // Services start in bottom-up order. const service2Inv = await service2.nextInvocation(); - await wireit.waitForLog(/\[service2\] Service started/); + await wireit.waitForLog(/\[service2\] Service ready/); const service1Inv = await service1.nextInvocation(); - await wireit.waitForLog(/\[service1\] Service started/); + await wireit.waitForLog(/\[service1\] Service ready/); // Wait a moment to ensure they keep running because the failure hasn't // happened yet. @@ -828,7 +829,7 @@ test( // Check that we only print "Service started" when we *actually* start a // service, and not when we adopt an existing one into a new iteration. - assert.equal([...stdout.matchAll(/Service started/g)].length, 2); + assert.equal([...stdout.matchAll(/Service ready/g)].length, 2); }) ); @@ -1115,7 +1116,7 @@ test( hardInv1.exit(0); softInv1.exit(0); const serviceInv1 = await service.nextInvocation(); - await wireit.waitForLog(/Service started/); + await wireit.waitForLog(/Service ready/); await wireit.waitForLog(/Watching for file changes/); // Changing input of soft dependency does not restart service @@ -1132,7 +1133,7 @@ test( await serviceInv1.closed; await service.nextInvocation(); await wireit.waitForLog(/Service stopped/); - await wireit.waitForLog(/Service started/); + await wireit.waitForLog(/Service ready/); await wireit.waitForLog(/Watching for file changes/); wireit.kill(); @@ -1185,9 +1186,9 @@ test( // Services start in bottom-up order. const childServiceInv1 = await childService.nextInvocation(); - await wireit.waitForLog(/\[childService\] Service started/); + await wireit.waitForLog(/\[childService\] Service ready/); const parentServiceInv1 = await parentService.nextInvocation(); - await wireit.waitForLog(/\[parentService\] Service started/); + await wireit.waitForLog(/\[parentService\] Service ready/); await wireit.waitForLog(/\[parentService\] Watching for file changes/); // childService restarts. @@ -1195,7 +1196,7 @@ test( await childServiceInv1.closed; await wireit.waitForLog(/\[childService\] Service stopped/); const childServiceInv2 = await childService.nextInvocation(); - await wireit.waitForLog(/\[childService\] Service started/); + await wireit.waitForLog(/\[childService\] Service ready/); // Wait a moment to increase confidence. await new Promise((resolve) => setTimeout(resolve, 100)); @@ -1312,7 +1313,7 @@ test( (await standard.nextInvocation()).exit(0); await wireit.waitForLog(/\[standard\] Executed successfully/); await service.nextInvocation(); - await wireit.waitForLog(/\[service\] Service started/); + await wireit.waitForLog(/\[service\] Service ready/); await wireit.waitForLog(/\[service\] Watching for file changes/); await new Promise((resolve) => setTimeout(resolve, 50)); assert.equal(service.numInvocations, 1); @@ -1337,7 +1338,7 @@ test( await wireit.waitForLog(/\[standard\] Executed successfully/); await service.nextInvocation(); await wireit.waitForLog(/\[service\] Service stopped/); - await wireit.waitForLog(/\[service\] Service started/); + await wireit.waitForLog(/\[service\] Service ready/); await wireit.waitForLog(/\[service\] Watching for file changes/); await new Promise((resolve) => setTimeout(resolve, 50)); assert.equal(service.numInvocations, 2); diff --git a/src/test/util/test-rig.ts b/src/test/util/test-rig.ts index a7ba1c131..cf62b7250 100644 --- a/src/test/util/test-rig.ts +++ b/src/test/util/test-rig.ts @@ -323,7 +323,7 @@ class ExecResult { // processes in the group (without the negative only the leader "sh" // process would be killed). if (force) { - process.kill(-this._child.pid, 9); + process.kill(-this._child.pid, 'SIGKILL'); } else { process.kill(-this._child.pid, 'SIGINT'); }