Launch() test
This commit is contained in:
Родитель
dd4fff0130
Коммит
9ba9a09c8c
|
@ -2,7 +2,6 @@
|
|||
* Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
*--------------------------------------------------------*/
|
||||
|
||||
import * as sinon from 'sinon';
|
||||
import * as mockery from 'mockery';
|
||||
import * as assert from 'assert';
|
||||
|
||||
|
@ -255,6 +254,6 @@ suite('Utilities', () => {
|
|||
test('http:// url - no change', () => {
|
||||
const url = 'http://site.com/My/Cool/Site/script.js?stuff';
|
||||
testCanUrl(url, url);
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -173,7 +173,34 @@ suite('WebKitDebugAdapter', () => {
|
|||
});
|
||||
});
|
||||
|
||||
suite('launch()', () => { });
|
||||
suite('launch()', () => {
|
||||
test('launches with minimal correct args', () => {
|
||||
let spawnCalled = false;
|
||||
function spawn(chromePath: string, args: string[]): any {
|
||||
// Just assert that the chrome path is some string with 'chrome' in the path, and there are >0 args
|
||||
assert(chromePath.toLowerCase().indexOf('chrome') >= 0);
|
||||
assert(args.indexOf('--remote-debugging-port=9222') >= 0);
|
||||
assert(args.indexOf('a.js') >= 0);
|
||||
assert(args.indexOf('abc') >= 0);
|
||||
assert(args.indexOf('def') >= 0);
|
||||
spawnCalled = true;
|
||||
|
||||
return { on: () => { } };
|
||||
}
|
||||
|
||||
mockery.registerMock('child_process', { spawn });
|
||||
mockery.registerMock('fs', { statSync: () => true });
|
||||
mockery.registerMock('os', {
|
||||
tmpdir: () => 'c:/tmp',
|
||||
platform: () => 'win32'
|
||||
});
|
||||
const wkda = instantiateWKDA();
|
||||
return wkda.launch({ program: 'a.js', runtimeArguments: ['abc', 'def'], workingDirectory: 'c:/' }).then(() => {
|
||||
assert(spawnCalled);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('setExceptionBreakpoints()', () => { });
|
||||
suite('stepping', () => { });
|
||||
suite('stackTrace()', () => { });
|
||||
|
|
|
@ -60,6 +60,9 @@ export class DebounceHelper {
|
|||
|
||||
constructor(private timeoutMs: number) { }
|
||||
|
||||
/**
|
||||
* If not waiting already, call fn after the timeout
|
||||
*/
|
||||
public wait(fn: () => any): void {
|
||||
if (!this.waitToken) {
|
||||
this.waitToken = setTimeout(() => {
|
||||
|
@ -70,6 +73,9 @@ export class DebounceHelper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If waiting for something, cancel it and call fn immediately
|
||||
*/
|
||||
public doAndCancel(fn: () => any): void {
|
||||
if (this.waitToken) {
|
||||
clearTimeout(this.waitToken);
|
||||
|
@ -161,7 +167,7 @@ export class Logger {
|
|||
|
||||
/**
|
||||
* Maps a url from webkit to an absolute local path.
|
||||
* If not given an absolute path (with file: prefix), searches the current working directory for a matching file.
|
||||
* If not given an absolute path (with file: prefix), searches the current working directory for a matching file.
|
||||
* http://localhost/scripts/code.js => d:/app/scripts/code.js
|
||||
* file:///d:/scripts/code.js => d:/scripts/code.js
|
||||
*/
|
||||
|
@ -206,8 +212,8 @@ export function webkitUrlToClientUrl(cwd: string, url: string): string {
|
|||
* The client can handle urls in this format too.
|
||||
* file:///D:\\scripts\\code.js => d:/scripts/code.js
|
||||
* file:///Users/me/project/code.js => /Users/me/project/code.js
|
||||
* c:\scripts\code.js => c:/scripts/code.js
|
||||
* http://site.com/scripts/code.js => (no change)
|
||||
* c:\scripts\code.js => c:/scripts/code.js
|
||||
* http://site.com/scripts/code.js => (no change)
|
||||
*/
|
||||
export function canonicalizeUrl(url: string): string {
|
||||
url = url
|
||||
|
|
|
@ -68,8 +68,9 @@ export class WebKitDebugAdapter implements IDebugAdapter {
|
|||
}
|
||||
|
||||
public launch(args: ILaunchRequestArgs): Promise<void> {
|
||||
const chromeExe = args.runtimeExecutable || Utilities.getBrowserPath();
|
||||
if (!chromeExe) {
|
||||
// Check exists?
|
||||
const chromePath = args.runtimeExecutable || Utilities.getBrowserPath();
|
||||
if (!chromePath) {
|
||||
return Promise.reject(`Can't find Chrome - install it or set the "runtimeExecutable" field in the launch config.`);
|
||||
}
|
||||
|
||||
|
@ -92,8 +93,8 @@ export class WebKitDebugAdapter implements IDebugAdapter {
|
|||
///return Promise.reject('The launch config must specify either the "program" or "url" field.');
|
||||
}
|
||||
|
||||
Logger.log(`spawn('${chromeExe}', ${JSON.stringify(chromeArgs) })`);
|
||||
this._chromeProc = spawn(chromeExe, chromeArgs);
|
||||
Logger.log(`spawn('${chromePath}', ${JSON.stringify(chromeArgs) })`);
|
||||
this._chromeProc = spawn(chromePath, chromeArgs);
|
||||
this._chromeProc.on('error', (err) => {
|
||||
Logger.log('chrome error: ' + err);
|
||||
this.terminateSession();
|
||||
|
|
Загрузка…
Ссылка в новой задаче