From b7cdfce7e53f7471d9bfa03bbfaec4a43bdb0108 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Sat, 22 Jan 2022 08:43:21 +0100 Subject: [PATCH] Smoke test runner fails or hangs without error (fix #141148) --- test/automation/src/playwrightDriver.ts | 26 +++++++++++++++++++++---- test/smoke/src/main.ts | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/test/automation/src/playwrightDriver.ts b/test/automation/src/playwrightDriver.ts index fe7fd72050f..6b75ad93fbc 100644 --- a/test/automation/src/playwrightDriver.ts +++ b/test/automation/src/playwrightDriver.ts @@ -253,7 +253,7 @@ async function launchServer(options: LaunchOptions) { return { serverProcess, - endpoint: await measureAndLog(waitForEndpoint(serverProcess), 'waitForEndpoint(serverProcess)', logger) + endpoint: await measureAndLog(waitForEndpoint(serverProcess, logger), 'waitForEndpoint(serverProcess)', logger) }; } @@ -314,13 +314,31 @@ async function teardown(server: ChildProcess, logger: Logger): Promise { logger.log(`Gave up tearing down server after ${retries} attempts...`); } -function waitForEndpoint(server: ChildProcess): Promise { +function waitForEndpoint(server: ChildProcess, logger: Logger): Promise { return new Promise((resolve, reject) => { - server.stdout?.on('data', (d: Buffer) => { - const matches = d.toString('ascii').match(/Web UI available at (.+)/); + let endpointFound = false; + + server.stdout?.on('data', data => { + if (!endpointFound) { + logger.log(`[server] stdout: ${data}`); // log until endpoint found to diagnose issues + } + + const matches = data.toString('ascii').match(/Web UI available at (.+)/); if (matches !== null) { + endpointFound = true; + resolve(matches[1]); } }); + + server.stderr?.on('data', error => { + if (!endpointFound) { + logger.log(`[server] stderr: ${error}`); // log until endpoint found to diagnose issues + } + + if (error.toString().indexOf('EADDRINUSE') !== -1) { + reject(new Error(error)); + } + }); }); } diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index 65494e92561..263658a7283 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -180,7 +180,7 @@ if (!opts.web) { } if (!fs.existsSync(electronPath || '')) { - fail(`Can't find VSCode at ${electronPath}.`); + fail(`Can't find VSCode at ${electronPath}. Please run VSCode once first (scripts/code.sh, scripts\\code.bat) and try again.`); } if (process.env.VSCODE_DEV === '1') {