Skip to content

Commit fd75b25

Browse files
committed
Restore ability to debug and run extension tests
1 parent 009f607 commit fd75b25

File tree

9 files changed

+1273
-545
lines changed

9 files changed

+1273
-545
lines changed

.vscode-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { defineConfig } = require('@vscode/test-cli');
2+
3+
module.exports = defineConfig([
4+
{
5+
files: 'out/test/**/*.test.js',
6+
mocha: {
7+
ui: 'tdd',
8+
timeout: 20000
9+
}
10+
}
11+
]);

.vscode/launch.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
"request": "launch",
88
"runtimeExecutable": "${execPath}",
99
"args": [
10-
"--extensionDevelopmentPath=${workspaceRoot}",
10+
"--extensionDevelopmentPath=${workspaceFolder}",
1111
"--trace-deprecation"
1212
],
13-
"stopOnEntry": false,
1413
"sourceMaps": true,
1514
"outFiles": [
16-
"${workspaceRoot}/out/**/*.js"
15+
"${workspaceFolder}/out/test/**/*.js"
1716
],
1817
"preLaunchTask": "npm",
1918
"internalConsoleOptions": "openOnSessionStart"
@@ -28,11 +27,12 @@
2827
"--extensionDevelopmentPath=${workspaceFolder}",
2928
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
3029
],
30+
"sourceMaps": true,
3131
"outFiles": [
32-
"${workspaceRoot}/out/**/*.js"
32+
"${workspaceFolder}/out/test/**/*.js"
3333
],
3434
"preLaunchTask": "npm",
3535
"internalConsoleOptions": "openOnSessionStart"
3636
}
3737
]
38-
}
38+
}

package.json

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
"version": "3.32.0",
1313
"publisher": "OCamlPro SAS",
1414
"contributors": [
15-
{
16-
"name": "Emilien Lemaire",
17-
"email": "[email protected]"
18-
},
19-
{
20-
"name": "Olegs Kunicins",
21-
"email": "[email protected]"
22-
}
15+
{
16+
"name": "Emilien Lemaire",
17+
"email": "[email protected]"
18+
},
19+
{
20+
"name": "Olegs Kunicins",
21+
"email": "[email protected]"
22+
}
2323
],
2424
"license": "GPL-3.0",
2525
"icon": "icon.png",
@@ -52,7 +52,10 @@
5252
"debuggers": [
5353
{
5454
"type": "superbol-gdb",
55-
"languages": ["cobol", "COBOL"],
55+
"languages": [
56+
"cobol",
57+
"COBOL"
58+
],
5659
"program": "./out/src/gdb.js",
5760
"runtime": "node",
5861
"label": "SuperBOL Debugger for GnuCOBOL",
@@ -257,26 +260,30 @@
257260
"prepare": "tsc -p ./",
258261
"compile": "tsc -p ./",
259262
"watch": "tsc -w -p ./",
260-
"test": "mocha -u tdd ./out/test/",
263+
"test": "npm run compile && npm exec vscode-test",
261264
"lint": "eslint -c .eslintrc.js --ext .ts ./"
262265
},
263266
"devDependencies": {
264-
"@types/mocha": "^10.0.1",
267+
"@types/expect": "^1.20.4",
268+
"@types/mocha": "^10.0.10",
265269
"@types/node": "^20.6.3",
266-
"@types/vscode": "^1.44.0",
270+
"@types/vscode": "^1.64.0",
267271
"@typescript-eslint/eslint-plugin": "^6.7.2",
268272
"@typescript-eslint/parser": "^6.7.2",
269-
"@vscode/test-electron": "^2.3.4",
273+
"@vscode/debugadapter-testsupport": "^1.51.0",
274+
"@vscode/test-cli": "^0.0.12",
275+
"@vscode/test-electron": "^2.5.2",
270276
"eslint": "^8.50.0",
271277
"eslint_d": "^12.2.1",
272-
"mocha": "^10.2.0",
273-
"typescript": "^5.2.2",
274-
"@vscode/debugadapter-testsupport": "^1.51.0"
278+
"mocha": "^10.8.2",
279+
"ts-mocha": "^11.1.0",
280+
"ts-node": "^10.9.2",
281+
"tsconfig-paths": "^4.2.0",
282+
"typescript": "^5.2.2"
275283
},
276284
"dependencies": {
277-
"n-readlines": "^1.0.1",
278-
"package_name": "^1.0.0",
285+
"@vscode/debugadapter": "^1.51.0",
279286
"@vscode/debugprotocol": "^1.51.0",
280-
"@vscode/debugadapter": "^1.51.0"
287+
"n-readlines": "^1.0.1"
281288
}
282289
}

src/parser.c.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class SourceMap {
7878
private performLine: number = -1; // 002 - stepOver in routines with "perform"
7979
private isVersion2_2_or_3_1_1: boolean = false;
8080

81-
constructor(cwd: string, filesCobol: string[], sourceDirs: string[], private log: Function) {
81+
constructor(cwd: string, filesCobol: string[], sourceDirs: string[], private log: Function = (_ => {})) {
8282
this.cwd = fs.realpathSync(nativePathFromPath.resolve(cwd));
8383
this.log(`Source dirs: ${sourceDirs}`);
8484
for (const cSourceDir of sourceDirs) {

test/suite/functions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { parseExpression, cleanRawValue } from '../../src/functions';
66
suite("Useful functions", () => {
77
const cwd = nativePath.resolve(__dirname, '../../../test/resources');
88
const c = nativePath.resolve(cwd, 'petstore.c');
9-
const parsed = new SourceMap(cwd, [c]);
10-
console.log(parsed.toString());
9+
const parsed = new SourceMap(cwd, [c], [cwd]);
10+
//console.log(parsed.toString());
1111
const functionName = "petstore_";
1212

1313
test("it can parse expressions", () => {

test/suite/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from 'path';
2-
import * as Mocha from 'mocha';
3-
import * as glob from 'glob';
2+
import Mocha from 'mocha';
3+
import glob from 'glob';
44

55
export function run(): Promise<void> {
66
// Create the mocha test

test/suite/parser.c.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ suite("C code parse", () => {
66
const cwd = nativePath.resolve(__dirname, '../../../test/resources');
77
test("Minimal", () => {
88
const c = nativePath.resolve(cwd, 'hello.c');
9-
const cobol = '/home/olegs/projects/gnucobol-debug/test/resources/hello.cbl';
10-
const parsed = new SourceMap(cwd, [c]);
9+
const cobol = nativePath.resolve(cwd, 'hello.cbl');
10+
const parsed = new SourceMap(cwd, [c], [cwd]);
1111

1212
assert.equal(3, parsed.getLinesCount());
1313
assert.equal(3, parsed.getVariablesCount());
@@ -24,8 +24,8 @@ suite("C code parse", () => {
2424
});
2525
test("GnuCOBOL 3.1.1", () => {
2626
const c = nativePath.resolve(cwd, 'hello3.c');
27-
const cobol = '/home/olegs/projects/gnucobol-debug/test/resources/hello3.cbl';
28-
const parsed = new SourceMap(cwd, [c]);
27+
const cobol = nativePath.resolve(cwd, 'hello3.cbl');
28+
const parsed = new SourceMap(cwd, [c], [cwd]);
2929

3030
assert.equal(3, parsed.getLinesCount());
3131
assert.equal(3, parsed.getVariablesCount());
@@ -47,7 +47,7 @@ suite("C code parse", () => {
4747
const cSample = nativePath.resolve(cwd, 'sample.c');
4848
const cSubSample = nativePath.resolve(cwd, 'subsample.c');
4949
const cSubSubSample = nativePath.resolve(cwd, 'subsubsample.c');
50-
const parsed = new SourceMap(cwd, [cSample, cSubSample, cSubSubSample]);
50+
const parsed = new SourceMap(cwd, [cSample, cSubSample, cSubSubSample], [cwd]);
5151

5252
assert.equal(7, parsed.getLinesCount());
5353
assert.equal(14, parsed.getVariablesCount());
@@ -65,7 +65,7 @@ suite("C code parse", () => {
6565
});
6666
test("Variables Hierarchy", () => {
6767
const c = nativePath.resolve(cwd, 'petstore.c');
68-
const parsed = new SourceMap(cwd, [c]);
68+
const parsed = new SourceMap(cwd, [c], [cwd]);
6969

7070
assert.equal('b_14', parsed.getVariableByCobol('petstore_.WS-BILL').cName);
7171
assert.equal('f_15', parsed.getVariableByCobol('petstore_.WS-BILL.TOTAL-QUANTITY').cName);
@@ -74,7 +74,7 @@ suite("C code parse", () => {
7474
});
7575
test("Find variables by function and COBOL name", () => {
7676
const c = nativePath.resolve(cwd, 'petstore.c');
77-
const parsed = new SourceMap(cwd, [c]);
77+
const parsed = new SourceMap(cwd, [c], [cwd]);
7878

7979
assert.equal('f_15', parsed.findVariableByCobol('petstore_', 'TOTAL-QUANTITY').cName);
8080
assert.equal('f_15', parsed.findVariableByCobol('petstore_', 'WS-BILL.TOTAL-QUANTITY').cName);
@@ -85,7 +85,7 @@ suite("C code parse", () => {
8585
});
8686
test("Attributes", () => {
8787
const c = nativePath.resolve(cwd, 'datatypes.c');
88-
const parsed = new SourceMap(cwd, [c]);
88+
const parsed = new SourceMap(cwd, [c], [cwd]);
8989

9090
for (let variable of parsed.getVariablesByCobol()) {
9191
assert.notEqual(variable.attribute, null);
@@ -108,7 +108,7 @@ suite("C code parse", () => {
108108
});
109109
test("Multiple Functions", () => {
110110
const c = nativePath.resolve(cwd, 'func.c');
111-
const parsed = new SourceMap(cwd, [c]);
111+
const parsed = new SourceMap(cwd, [c], [cwd]);
112112

113113
const f_6 = parsed.getVariableByC('func_.f_6');
114114
assert.equal('argA', f_6.cobolName);

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"rootDir": ".",
88
"esModuleInterop": true,
99
},
10-
"include": ["src"],
10+
"include": ["src", "test"],
1111
"exclude": [
1212
"node_modules",
1313
".vscode-test"

0 commit comments

Comments
 (0)