Use temp user data dir

This commit is contained in:
Daniel Imms 2019-08-13 11:28:29 -07:00
parent f4deaa16c1
commit 68f94dd8b4

View file

@ -6,6 +6,9 @@
import * as puppeteer from 'puppeteer'; import * as puppeteer from 'puppeteer';
import { ChildProcess, spawn } from 'child_process'; import { ChildProcess, spawn } from 'child_process';
import { join } from 'path'; import { join } from 'path';
import { tmpdir } from 'os';
import { mkdir } from 'fs';
import { promisify } from 'util';
const width = 1200; const width = 1200;
const height = 800; const height = 800;
@ -184,11 +187,18 @@ let endpoint: string | undefined;
export async function launch(_args): Promise<void> { export async function launch(_args): Promise<void> {
args = _args; args = _args;
console.log('launch args', args);
// TODO: --web-user-data-dir (tmpdir) // TODO: Don't open up the system browser
server = spawn(join(args[0], '/resources/server/web.sh'), ['--driver', 'web']); const webUserDataDir = join(tmpdir(), `smoketest-${Math.random() * 10000000000}`);
endpoint = await new Promise<string>(r => { await promisify(mkdir)(webUserDataDir);
server = spawn(join(args[0], 'resources/server/web.sh'), ['--driver', 'web', '--web-user-data-dir', webUserDataDir]);
server.stderr.on('data', e => console.log('Server error: ' + e));
endpoint = await waitForEndpoint();
await timeout(2000);
}
function waitForEndpoint(): Promise<string> {
return new Promise<string>(r => {
server.stdout.on('data', d => { server.stdout.on('data', d => {
const matches = d.toString('ascii').match(/Web UI available at (.+)/); const matches = d.toString('ascii').match(/Web UI available at (.+)/);
if (matches !== null) { if (matches !== null) {