Skip to content

Commit 6ebce88

Browse files
committed
Remove obsolete gnattest integration code and tests
1 parent 235ca43 commit 6ebce88

File tree

2 files changed

+2
-171
lines changed

2 files changed

+2
-171
lines changed

integration/vscode/ada/src/gnattest.ts

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -133,90 +133,6 @@ async function refreshTestItemTree() {
133133
await addTestsRootLevel();
134134
}
135135

136-
/*
137-
Resolves Tests to run for a selected test item in the Explorer
138-
*/
139-
export function gatherChildTestItems(
140-
collection: vscode.TestItemCollection | readonly vscode.TestItem[]
141-
): vscode.TestItem[] {
142-
let items: vscode.TestItem[] = [];
143-
collection.forEach((item) => {
144-
if (item.children.size == 0) {
145-
items.push(item);
146-
} else {
147-
items = items.concat(gatherChildTestItems(item.children));
148-
}
149-
});
150-
return items;
151-
}
152-
153-
/*
154-
Gets the Source file name for a test item
155-
Needed for the --routines switch
156-
*/
157-
export function getParentTestSourceName(item: vscode.TestItem) {
158-
let parent: vscode.TestItem = item;
159-
if (item.parent != undefined) {
160-
parent = getParentTestSourceName(item.parent);
161-
}
162-
return parent;
163-
}
164-
165-
/*
166-
Return the test_runner output stored in the result.txt file
167-
*/
168-
export async function readResultFile(resultPath: string) {
169-
if (vscode.workspace.workspaceFolders !== undefined) {
170-
if (pathIsReadable(resultPath)) {
171-
const file = await vscode.workspace.fs.readFile(vscode.Uri.file(resultPath));
172-
return file.toString();
173-
}
174-
}
175-
return undefined;
176-
}
177-
178-
enum Test_State {
179-
PASSED = 'PASSED',
180-
FAILED = 'FAILED',
181-
}
182-
183-
/*
184-
Parses the result of the file 'result.txt'
185-
*/
186-
export function parseResults(
187-
tests: vscode.TestItem[],
188-
run: vscode.TestRun | undefined,
189-
file: string
190-
): boolean {
191-
const matchs = file.match(
192-
/(^|\n)((\w|-)+).ad[b|s]:\d+:\d+: (info|error): corresponding test (\w+)/g
193-
);
194-
if (matchs) {
195-
for (let i = 0; i < matchs.length; i++) {
196-
matchs[i] = matchs[i].replace(/\n/, '');
197-
for (const e of tests) {
198-
// Check if the result line is for the test 'e'
199-
const test_src = getParentTestSourceName(e);
200-
const p: number | undefined = e.parent?.range?.start.line;
201-
const test_line: number = p ? p + 1 : 0;
202-
const check_line = matchs[i].match(test_src.label + ':' + test_line.toString());
203-
// update the state of the test
204-
if (check_line != null && run != undefined) {
205-
run.appendOutput(`Completed ${e.id}\r\n`);
206-
const mm: string = matchs[i].substring(matchs[i].length - 6, matchs[i].length);
207-
if (mm == Test_State.PASSED) {
208-
run.passed(e);
209-
} else {
210-
run.failed(e, new vscode.TestMessage(matchs[i]));
211-
}
212-
}
213-
}
214-
}
215-
return true;
216-
}
217-
return false;
218-
}
219-
220136
async function getGnatTestXmlPath(): Promise<string> {
221137
const objDir = await getObjectDir();
222138
const gnatTestXmlPath = path.join(objDir, 'gnattest', 'harness', 'gnattest.xml');
Lines changed: 2 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,8 @@
1-
import * as assert from 'assert';
2-
import * as cp from 'child_process';
3-
import { suite, test } from 'mocha';
4-
import * as path from 'path';
5-
import * as vscode from 'vscode';
6-
import { adaExtState } from '../../../src/extension';
7-
import * as gnattest from '../../../src/gnattest';
8-
import { getProjectFile } from '../../../src/helpers';
9-
import { activate, assertEqualToFileContent } from '../utils';
1+
import { suite } from 'mocha';
2+
import { activate } from '../utils';
103

114
suite('GNATtest Integration Tests', function () {
125
this.beforeAll(async () => {
136
await activate();
147
});
15-
test('Generate Tests', async () => {
16-
const projectFile = await getProjectFile(adaExtState.adaClient);
17-
// Generate tests and redirect the stderr to stdout if command failed
18-
cp.execSync('gnattest -P ' + projectFile + ' 2>&1', { timeout: 60000 });
19-
});
20-
test('Build & Run the tests', () => {
21-
if (vscode.workspace.workspaceFolders) {
22-
const ext: string = process.platform == 'win32' ? '.exe' : '';
23-
const cwd = vscode.workspace.workspaceFolders[0].uri.fsPath;
24-
25-
cp.execSync(
26-
'gprbuild -P ' + path.join(cwd, 'obj', 'gnattest', 'harness', 'test_driver.gpr'),
27-
{ timeout: 60000 }
28-
);
29-
cp.execSync(
30-
path.join(cwd, 'obj', 'gnattest', 'harness', 'test_runner' + ext) +
31-
' > ' +
32-
path.join(cwd, 'obj', 'gnattest', 'result.txt'),
33-
{ timeout: 60000 }
34-
);
35-
} else {
36-
throw new Error('No workspace folder found for the specified URI');
37-
}
38-
});
39-
test('Expected Tests discovered', async () => {
40-
const root = await gnattest.addTestsRootLevel();
41-
assert.notStrictEqual(root, undefined);
42-
const tests = gnattest.gatherChildTestItems(gnattest.controller.items);
43-
for (let i = 0; i < tests.length; i++) {
44-
assert.strictEqual(tests[i].label, expectedTests[i].name);
45-
assert.strictEqual(tests[i].range?.start.line, expectedTests[i].line);
46-
}
47-
});
48-
test('Read & Parse & compare the results', async () => {
49-
if (vscode.workspace.workspaceFolders) {
50-
const cwd = vscode.workspace.workspaceFolders[0].uri.fsPath;
51-
const resultPath = path.join(cwd, 'obj', 'gnattest', 'result.txt');
52-
const result = await gnattest.readResultFile(resultPath);
53-
assert.notStrictEqual(
54-
result,
55-
undefined,
56-
'Could not read the result file ' + resultPath
57-
);
58-
if (result != undefined) {
59-
const expectedUri = vscode.Uri.joinPath(
60-
vscode.workspace.workspaceFolders[0].uri,
61-
'result.txt.expected'
62-
);
63-
assert.strictEqual(gnattest.parseResults([], undefined, result), true);
64-
assertEqualToFileContent(result, expectedUri);
65-
}
66-
} else {
67-
throw new Error('No workspace folder found for the specified URI');
68-
}
69-
});
708
});
71-
72-
const expectedTests = [
73-
{
74-
name: 'Test_Speed_bdc804',
75-
line: 39,
76-
},
77-
{
78-
name: 'Test_Adjust_Speed_6fd48f',
79-
line: 60,
80-
},
81-
{
82-
name: 'Test_Desired_Speed_3a9813',
83-
line: 39,
84-
},
85-
{
86-
name: 'Test_Set_Desired_Speed_42cd33',
87-
line: 60,
88-
},
89-
{
90-
name: 'Test_Adjust_Speed_6fd48f',
91-
line: 81,
92-
},
93-
];

0 commit comments

Comments
 (0)