Skip to content

Commit

Permalink
fix integration browser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Jun 15, 2021
1 parent f488650 commit 3d2dea7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/integration/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as rimraf from 'rimraf';
import { URI } from 'vscode-uri';
import * as kill from 'tree-kill';
import * as optimistLib from 'optimist';
import { StdioOptions } from 'node:child_process';

const optimist = optimistLib
.describe('workspacePath', 'path to the workspace to open in the test').string('workspacePath')
Expand Down Expand Up @@ -113,23 +114,25 @@ async function launchServer(browserType: BrowserType): Promise<{ endpoint: url.U
console.log(`Storing log files into '${logsPath}'`);
}

const stdio: StdioOptions = optimist.argv.debug ? 'pipe' : ['ignore', 'pipe', 'ignore'];

let serverProcess = cp.spawn(
serverLocation,
serverArgs,
{ env }
{ env, stdio }
);

if (optimist.argv.debug) {
serverProcess?.stderr?.on('data', error => console.log(`Server stderr: ${error}`));
serverProcess?.stdout?.on('data', data => console.log(`Server stdout: ${data}`));
serverProcess.stderr!.on('data', error => console.log(`Server stderr: ${error}`));
serverProcess.stdout!.on('data', data => console.log(`Server stdout: ${data}`));
}

process.on('exit', () => serverProcess.kill());
process.on('SIGINT', () => serverProcess.kill());
process.on('SIGTERM', () => serverProcess.kill());

return new Promise(c => {
serverProcess?.stdout?.on('data', data => {
serverProcess.stdout!.on('data', data => {
const matches = data.toString('ascii').match(/Web UI available at (.+)/);
if (matches !== null) {
c({ endpoint: url.parse(matches[1]), server: serverProcess });
Expand Down

0 comments on commit 3d2dea7

Please sign in to comment.