Skip to content

Commit cdc8d13

Browse files
committed
Add tests for the debug adapter
1 parent 986eeb6 commit cdc8d13

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1431
-63
lines changed

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
out/
33
node_modules/
44
src/typings/
5-
5+
src/tests/config/custom.json
6+
src/tests/testdata/JSApp
7+
src/tests/testdata/TSApp
8+
src/tests/testdata/**/node_modules
9+
src/tests/testdata/**/platforms
610
npm-debug.log
7-
nativescript-*.vsix
8-
11+
nativescript-*.vsix

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
**/*.map
33
node_modules/.bin/**
44
src/**
5+
out/tests/**
56
images/screenshots/**
67
*.vsix
78
.gitignore

package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,27 @@
2626
"license": "SEE LICENSE IN LICENSE.txt",
2727
"dependencies": {
2828
"source-map": "^0.5.3",
29-
"vscode-debugprotocol": "^1.6.1",
30-
"vscode-debugadapter": "^1.6.1"
29+
"vscode-debugprotocol": "^1.7.0",
30+
"vscode-debugadapter": "^1.7.0"
3131
},
3232
"devDependencies": {
33+
"mocha": "^2.4.5",
3334
"tslint": "^3.5.0",
3435
"typescript": "^1.8.2",
3536
"typings": "^0.7.9",
3637
"vsce": "^1.0.0",
37-
"vscode": "^0.11.x"
38+
"vscode": "^0.11.x",
39+
"vscode-debugadapter-testsupport": "^1.7.0"
3840
},
3941
"scripts": {
4042
"postinstall": "node ./node_modules/vscode/bin/install && cd src && typings install",
4143
"clean": "git clean -fdx",
4244
"build": "tsc -p ./src",
43-
"package": "vsce package"
45+
"package": "vsce package",
46+
"launch-as-server": "node --nolazy ./out/webkit/webKitDebug.js --server=4712",
47+
"test-mac": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/mac.json ./out/tests",
48+
"test-win": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/win.json ./out/tests",
49+
"test-custom": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/custom.json ./out/tests"
4450
},
4551
"main": "./out/nativescript/nsMain",
4652
"activationEvents": [

src/.vscode/launch.json

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"request": "launch",
88
"program": "${workspaceRoot}/../out/webkit/webKitDebug.js",
99
"runtimeArgs": ["--nolazy"],
10-
"stopOnEntry": false,
1110
"args": [ "--server=4712" ],
11+
"stopOnEntry": false,
1212
"sourceMaps": true,
1313
"outDir": "${workspaceRoot}/../out",
1414
"cwd": "${workspaceRoot}"
@@ -17,14 +17,63 @@
1717
"name": "launch in extension host",
1818
"type": "extensionHost",
1919
"request": "launch",
20-
// Path to VSCode executable"
20+
// Path to VSCode executable
2121
"runtimeExecutable": "${execPath}",
2222
"args": [
2323
"--extensionDevelopmentPath=${workspaceRoot}"
2424
],
2525
"stopOnEntry": false,
2626
"sourceMaps": true,
27-
"outDir": "${workspaceRoot}/../out"
28-
}
27+
"outDir": "${workspaceRoot}/../out",
28+
"cwd": "${workspaceRoot}"
29+
},
30+
{
31+
"name": "run tests on mac",
32+
"type": "node",
33+
"request": "launch",
34+
"program": "${workspaceRoot}/../node_modules/mocha/bin/_mocha",
35+
"runtimeArgs": [ "--nolazy" ],
36+
"args": [
37+
"--opts", "${workspaceRoot}/tests/config/mocha.opts",
38+
"--config", "${workspaceRoot}/tests/config/mac.json",
39+
"${workspaceRoot}/../out/tests/"
40+
],
41+
"stopOnEntry": false,
42+
"sourceMaps": true,
43+
"outDir": "${workspaceRoot}/../out",
44+
"cwd": "${workspaceRoot}"
45+
},
46+
{
47+
"name": "run tests on win",
48+
"type": "node",
49+
"request": "launch",
50+
"program": "${workspaceRoot}/../node_modules/mocha/bin/_mocha",
51+
"runtimeArgs": [ "--nolazy" ],
52+
"args": [
53+
"--opts", "${workspaceRoot}/tests/config/mocha.opts",
54+
"--config", "${workspaceRoot}/tests/config/win.json",
55+
"${workspaceRoot}/../out/tests/"
56+
],
57+
"stopOnEntry": false,
58+
"sourceMaps": true,
59+
"outDir": "${workspaceRoot}/../out",
60+
"cwd": "${workspaceRoot}"
61+
},
62+
{
63+
"name": "run tests (custom)",
64+
"type": "node",
65+
"request": "launch",
66+
"program": "${workspaceRoot}/../node_modules/mocha/bin/_mocha",
67+
"runtimeArgs": [ "--nolazy" ],
68+
"args": [
69+
"--opts", "${workspaceRoot}/tests/config/mocha.opts",
70+
"--config", "${workspaceRoot}/tests/config/custom.json",
71+
"${workspaceRoot}/../out/tests/"
72+
],
73+
"stopOnEntry": false,
74+
"sourceMaps": true,
75+
"outDir": "${workspaceRoot}/../out",
76+
"cwd": "${workspaceRoot}"
77+
}
2978
]
30-
}
79+
}

src/nativescript/android/androidDebugConnection.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ export class AndroidDebugConnection implements ns.INSDebugConnection {
378378
};
379379
};
380380

381-
private fetchCallFrames(): Promise<any> {
381+
private fetchCallFrames(): Promise<WebKitProtocol.Debugger.CallFrame[]> {
382382

383383
let that = this;
384384
return this.request("backtrace",
@@ -402,7 +402,6 @@ export class AndroidDebugConnection implements ns.INSDebugConnection {
402402
};
403403
});
404404

405-
406405
return {
407406
callFrameId: frame.index.toString(),
408407
functionName: frame.func.inferredName || frame.func.name,
@@ -764,18 +763,6 @@ export class AndroidDebugConnection implements ns.INSDebugConnection {
764763
throw new Error("Not implemented");
765764
}
766765

767-
public page_setOverlayMessage(message: string): Promise<WebKitProtocol.Response> {
768-
//return this.sendMessage('Page.setOverlayMessage', { message });
769-
//throw new Error("Not implemented");
770-
return Promise.resolve();
771-
}
772-
773-
public page_clearOverlayMessage(): Promise<WebKitProtocol.Response> {
774-
//return this.sendMessage('Page.setOverlayMessage');
775-
//throw new Error("Not implemented");
776-
return Promise.resolve();
777-
}
778-
779766
// private sendMessage(method: any, params?: any): Promise<WebKitProtocol.Response> {
780767
// return this._socket.sendMessage({
781768
// id: this._nextId++,

src/nativescript/nativescript.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ export interface INSDebugConnection {
3535
runtime_getProperties(objectId: string, ownProperties: boolean, accessorPropertiesOnly: boolean): Promise<WebKitProtocol.Runtime.GetPropertiesResponse>;
3636

3737
runtime_evaluate(expression: string, objectGroup?: any, contextId?: number, returnByValue?: boolean): Promise<WebKitProtocol.Runtime.EvaluateResponse>;
38-
39-
page_setOverlayMessage(message: string): Promise<WebKitProtocol.Response>;
40-
41-
page_clearOverlayMessage(): Promise<WebKitProtocol.Response>;
42-
4338
}
4439

4540
export abstract class NSProject extends EventEmitter {

src/tests/.vscode/launch.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"version": "0.1.0",
3+
"configurations": [
4+
{
5+
"name": "run tests on mac",
6+
"type": "node",
7+
"request": "launch",
8+
"program": "${workspaceRoot}/../../node_modules/mocha/bin/_mocha",
9+
"runtimeArgs": [ "--nolazy" ],
10+
"args": [
11+
"--opts", "${workspaceRoot}/config/mocha.opts",
12+
"--config", "${workspaceRoot}/config/mac.json",
13+
"${workspaceRoot}/../../out/tests/"
14+
],
15+
"stopOnEntry": false,
16+
"sourceMaps": true,
17+
"outDir": "${workspaceRoot}/../../out",
18+
"cwd": "${workspaceRoot}/../"
19+
},
20+
{
21+
"name": "run tests on win",
22+
"type": "node",
23+
"request": "launch",
24+
"program": "${workspaceRoot}/../../node_modules/mocha/bin/_mocha",
25+
"runtimeArgs": [ "--nolazy" ],
26+
"args": [
27+
"--opts", "${workspaceRoot}/config/mocha.opts",
28+
"--config", "${workspaceRoot}/config/win.json",
29+
"${workspaceRoot}/../../out/tests/"
30+
],
31+
"stopOnEntry": false,
32+
"sourceMaps": true,
33+
"outDir": "${workspaceRoot}/../../out",
34+
"cwd": "${workspaceRoot}/../"
35+
},
36+
{
37+
"name": "run tests (custom)",
38+
"type": "node",
39+
"request": "launch",
40+
"program": "${workspaceRoot}/../../node_modules/mocha/bin/_mocha",
41+
"runtimeArgs": [ "--nolazy" ],
42+
"args": [
43+
"--opts", "${workspaceRoot}/config/mocha.opts",
44+
"--config", "${workspaceRoot}/config/custom.json",
45+
"${workspaceRoot}/../../out/tests/"
46+
],
47+
"stopOnEntry": false,
48+
"sourceMaps": true,
49+
"outDir": "${workspaceRoot}/../../out",
50+
"cwd": "${workspaceRoot}/../"
51+
}
52+
]
53+
}

src/tests/.vscode/tasks.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": "0.1.0",
3+
"windows": {
4+
"command": "..\\..\\node_modules\\.bin\\tsc"
5+
},
6+
"command": "../../node_modules/.bin/tsc",
7+
"isShellCommand": true,
8+
"args": ["-p", "../"],
9+
"problemMatcher": "$tsc"
10+
}

0 commit comments

Comments
 (0)