|
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'; |
10 | 3 |
|
11 | 4 | suite('GNATtest Integration Tests', function () { |
12 | 5 | this.beforeAll(async () => { |
13 | 6 | await activate(); |
14 | 7 | }); |
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 | | - }); |
70 | 8 | }); |
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