Skip to content

Commit 369ad0d

Browse files
committed
Various fixes to work on Windows
1 parent 8ed34e4 commit 369ad0d

File tree

6 files changed

+37
-29
lines changed

6 files changed

+37
-29
lines changed

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ BUILD_DATE ?=
1010
# Location of home dir for tests
1111
export ALS_HOME=$(ROOTDIR)/testsuite
1212

13+
# Exectuable extension
14+
ifeq ($(OS),)
15+
# Not Windows
16+
EXE=""
17+
else
18+
# Windows
19+
EXE=.exe
20+
endif
21+
1322
# Command to run for tests
14-
export ALS=$(ROOTDIR)/.obj/server/ada_language_server
23+
export ALS=$(ROOTDIR)/.obj/server/ada_language_server$(EXE)
1524

1625
# Tester files
17-
TESTER=$(ROOTDIR)/.obj/tester/tester-run
18-
CODEC_TEST=.obj/codec_test/codec_test
26+
TESTER=$(ROOTDIR)/.obj/tester/tester-run$(EXE)
27+
CODEC_TEST=.obj/codec_test/codec_test$(EXE)
1928

2029
# Env variable to set for update VS Code test references
2130
MOCHA_ALS_UPDATE=
@@ -156,7 +165,6 @@ endif
156165

157166
vscode-test:
158167
# Run the VS Code integration testsuite.
159-
echo $(GPR_PROJECT_PATH)
160168
MOCHA_ALS_UPDATE=$(MOCHA_ALS_UPDATE) cd integration/vscode/ada; LD_LIBRARY_PATH= npm run test
161169

162170
vscode-package:

integration/vscode/ada/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,14 @@
635635
"vscode-tmgrammar-test": "0.1.1"
636636
},
637637
"scripts": {
638-
"check-licenses": "npx license-checker-rseidelsohn --summary --onlyAllow '0BSD;Apache-2.0;BSD-2-Clause;BSD-3-Clause;BlueOak-1.0.0;CC0-1.0;GPL-3.0;GPL-3.0-or-later;ISC;MIT;Python-2.0;Zlib'",
638+
"check-licenses": "npx license-checker-rseidelsohn --summary --onlyAllow \"0BSD;Apache-2.0;BSD-2-Clause;BSD-3-Clause;BlueOak-1.0.0;CC0-1.0;GPL-3.0;GPL-3.0-or-later;ISC;MIT;Python-2.0;Zlib\"",
639639
"vscode:prepublish": "npm run esbuild-base -- --minify",
640640
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/src/extension.js --external:vscode --format=cjs --platform=node",
641641
"compile": "node ./node_modules/typescript/bin/tsc",
642642
"watch": "node ./node_modules/typescript/bin/tsc -watch",
643643
"pretest": "npm run compile",
644-
"lint": "eslint './src/**/*.{js,ts,tsx}' --quiet --fix",
645-
"cilint": "eslint './src/**/*.{js,ts,tsx}'",
644+
"lint": "eslint \"./src/**/*.{js,ts,tsx}\" --quiet --fix",
645+
"cilint": "eslint \"./src/**/*.{js,ts,tsx}\"",
646646
"test": "node ./out/test/runTest.js"
647647
},
648648
"dependencies": {

integration/vscode/ada/src/helpers.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,8 @@ type ExecutablesResponse = {
205205
* @returns a string contains the path of the project file
206206
*/
207207
export async function getProjectFile(client: LanguageClient): Promise<string> {
208-
const configValue: string | undefined = vscode.workspace
209-
.getConfiguration('ada')
210-
.get('projectFile');
211-
if (configValue != undefined && configValue != '') {
212-
return configValue;
213-
} else {
214-
const result: ProjectFileResponse = await client.sendRequest('$/glsProjectFile');
215-
return result.projectFile;
216-
}
208+
const result: ProjectFileResponse = await client.sendRequest('$/glsProjectFile');
209+
return result.projectFile;
217210
}
218211

219212
/**

integration/vscode/ada/test/suite/general/tasks.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as vscode from 'vscode';
22
import * as assert from 'assert';
3+
import * as path from 'path';
34
import { suite, test } from 'mocha';
45
import { contextClients } from '../../../src/extension';
56
import { activate } from '../utils';
@@ -43,15 +44,19 @@ suite('GPR Tasks Provider', function () {
4344
test('Tasks resolving', async () => {
4445
const prov = new GprTaskProvider(contextClients.adaClient);
4546
const task = new vscode.Task(
46-
{ type: 'gpr', main: 'src/program.adb' },
47+
{ type: 'gpr', main: path.join('src', 'program.adb') },
4748
'build main',
4849
'tasks'
4950
);
5051
const workspace = vscode.workspace.workspaceFolders?.at(0)?.uri.fsPath;
5152
if (workspace == undefined) {
5253
throw new Error('No workspace found');
5354
}
54-
const expectedCmd = `gprbuild -d -P ${workspace}/default.gpr src/program.adb `;
55+
const expectedCmd =
56+
'gprbuild -d -P ' +
57+
path.join(workspace, 'default.gpr') +
58+
' ' +
59+
path.join('src', 'program.adb ');
5560
const resolved = await prov.resolveTask(task);
5661
assert.notStrictEqual(resolved, undefined);
5762
if (resolved != undefined && resolved.execution) {

integration/vscode/ada/test/suite/gnattest/gnattest.test.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@ suite('GNATtest Integration Tests', function () {
1414
});
1515
test('Generate Tests', async () => {
1616
await contextClients.adaClient.onReady();
17-
const projectFile = vscode.workspace.asRelativePath(
18-
await getProjectFile(contextClients.adaClient)
19-
);
20-
if (vscode.workspace.workspaceFolders) {
21-
const fpath = path.join(vscode.workspace.workspaceFolders[0].uri.path, projectFile);
22-
cp.execSync('gnattest -P ' + fpath, { timeout: 60000 });
23-
} else {
24-
throw new Error('No workspace folder found for the specified URI');
25-
}
17+
const projectFile = await getProjectFile(contextClients.adaClient);
18+
// Generate tests and redirect the stderr to stdout if command failed
19+
cp.execSync('gnattest -P ' + projectFile + ' 2>&1', { timeout: 60000 });
2620
});
2721
test('Build & Run the tests', () => {
2822
if (vscode.workspace.workspaceFolders) {
2923
const ext: string = process.platform == 'win32' ? '.exe' : '';
30-
const cwd = vscode.workspace.workspaceFolders[0].uri.path;
24+
const cwd = vscode.workspace.workspaceFolders[0].uri.fsPath;
3125

3226
cp.execSync(
3327
'gprbuild -P ' + path.join(cwd, 'obj', 'gnattest', 'harness', 'test_driver.gpr'),
@@ -57,7 +51,7 @@ suite('GNATtest Integration Tests', function () {
5751
});
5852
test('Read & Parse & compare the results', async () => {
5953
if (vscode.workspace.workspaceFolders) {
60-
const cwd = vscode.workspace.workspaceFolders[0].uri.path;
54+
const cwd = vscode.workspace.workspaceFolders[0].uri.fsPath;
6155
const resultPath = path.join(cwd, 'obj', 'gnattest', 'result.txt');
6256
const result = await gnattest.readResultFile(resultPath);
6357
assert.notStrictEqual(

integration/vscode/ada/test/suite/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { existsSync, readFileSync, writeFileSync } from 'fs';
1717
* @param expectedUri - path to the file containing the expected output
1818
*/
1919
export function assertEqualToFileContent(actual: string, expectedUri: vscode.Uri) {
20+
// Normalize the actual string
21+
actual = normalizeLineEndings(actual);
22+
2023
if (update()) {
2124
writeFileSync(expectedUri.fsPath, actual);
2225
} else {
@@ -25,10 +28,15 @@ export function assertEqualToFileContent(actual: string, expectedUri: vscode.Uri
2528
}
2629

2730
const expected: string = readFileSync(expectedUri.fsPath, 'utf-8');
31+
2832
assert.strictEqual(actual, expected);
2933
}
3034
}
3135

36+
export function normalizeLineEndings(str: string, lineEnding = '\n'): string {
37+
return str.replace(/\r?\n/g, lineEnding);
38+
}
39+
3240
/**
3341
*
3442
* @returns true if the testsuite is running in update mode, i.e. the

0 commit comments

Comments
 (0)