From 3379c0d8abd1b8d0eb833e1cc580993659c87080 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 12 Apr 2018 09:55:19 +0200 Subject: [PATCH] create named pipe in windows --- test/smoke/src/vscode/code.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/smoke/src/vscode/code.ts b/test/smoke/src/vscode/code.ts index 281c05eba80..362f446cfbb 100644 --- a/test/smoke/src/vscode/code.ts +++ b/test/smoke/src/vscode/code.ts @@ -5,6 +5,7 @@ import * as path from 'path'; import * as cp from 'child_process'; +import * as os from 'os'; import { tmpName } from 'tmp'; import { IDriver, connect as connectDriver, IDisposable, IElement } from './driver'; @@ -88,11 +89,20 @@ export interface SpawnOptions { extraArgs?: string[]; } +async function createDriverHandle(): Promise { + if ('win32' === os.platform()) { + const name = [...Array(15)].map(() => Math.random().toString(36)[3]).join(''); + return `\\\\.\\pipe\\${name}`; + } else { + return await new Promise((c, e) => tmpName((err, handlePath) => err ? e(err) : c(handlePath))); + } +} + export async function spawn(options: SpawnOptions): Promise { const codePath = options.codePath; const electronPath = codePath ? getBuildElectronPath(codePath) : getDevElectronPath(); const outPath = codePath ? getBuildOutPath(codePath) : getDevOutPath(); - const handlePath = await new Promise((c, e) => tmpName((err, handlePath) => err ? e(err) : c(handlePath))); + const handle = await createDriverHandle(); const args = [ options.workspacePath, @@ -104,7 +114,7 @@ export async function spawn(options: SpawnOptions): Promise { '--disable-crash-reporter', `--extensions-dir=${options.extensionsPath}`, `--user-data-dir=${options.userDataDir}`, - '--driver', handlePath + '--driver', handle ]; if (!codePath) { @@ -126,7 +136,7 @@ export async function spawn(options: SpawnOptions): Promise { instances.add(child); child.once('exit', () => instances.delete(child)); - return connect(child, outPath, handlePath, options.verbose); + return connect(child, outPath, handle, options.verbose); } export class Code {