Skip to content

Commit 7dbe4af

Browse files
committed
Create a testsuite for the e3-testsuite integration
1 parent 7a7e444 commit 7dbe4af

File tree

3 files changed

+209
-3
lines changed

3 files changed

+209
-3
lines changed

integration/vscode/ada/.vscode-test.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const testsuites = [
5151
'dot-als-json',
5252
'status_bar',
5353
'aggregate_projects',
54+
'e3-testsuite',
5455
];
5556

5657
export default defineConfig(

integration/vscode/ada/src/e3Testsuite.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ type TestResult = {
5757

5858
const showLoadTestListErrorCmdId = 'e3-testsuite.showLoadTestListError';
5959
let lastLoadError: string = '';
60+
export let controller: vscode.TestController;
61+
export let runProfile: vscode.TestRunProfile;
6062

6163
// This method is called when your extension is activated
6264
// Your extension is activated the very first time the command is executed
@@ -70,7 +72,7 @@ export function activateE3TestsuiteIntegration(context: vscode.ExtensionContext)
7072
}),
7173
);
7274

73-
const controller = vscode.tests.createTestController('e3-testsuite', 'e3-testsuite');
75+
controller = vscode.tests.createTestController('e3-testsuite', 'e3-testsuite');
7476
context.subscriptions.push(controller);
7577

7678
const testData: Map<vscode.TestItem, TestInfo> = new Map();
@@ -154,7 +156,7 @@ export function activateE3TestsuiteIntegration(context: vscode.ExtensionContext)
154156
});
155157
};
156158

157-
const profile = controller.createRunProfile(
159+
runProfile = controller.createRunProfile(
158160
'e3-testsuite',
159161
vscode.TestRunProfileKind.Run,
160162
async function (request, token) {
@@ -480,7 +482,7 @@ export function activateE3TestsuiteIntegration(context: vscode.ExtensionContext)
480482
run.appendOutput(line + '\r\n');
481483
}
482484
}
483-
context.subscriptions.push(profile);
485+
context.subscriptions.push(runProfile);
484486

485487
vscode.window.withProgress(
486488
{
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
import assert from 'assert';
2+
import { commands, TestItem, TestItemCollection, Uri, workspace } from 'vscode';
3+
import { CancellationTokenSource } from 'vscode-languageclient';
4+
import * as e3 from '../../src/e3Testsuite';
5+
import { activate } from '../utils';
6+
7+
suite('e3-testsuite', function () {
8+
this.beforeAll(async function () {
9+
await activate();
10+
});
11+
12+
test('Test list', async function () {
13+
await e3.controller.refreshHandler!(new CancellationTokenSource().token);
14+
15+
assert.deepStrictEqual(toTestResult(e3.controller.items), [
16+
{
17+
id: Uri.joinPath(workspace.workspaceFolders![0].uri, 'testsuite.py').toString(),
18+
label: 'testsuite.py',
19+
children: [
20+
{
21+
id: '01-test-one-result',
22+
label: '01-test-one-result',
23+
children: [],
24+
},
25+
{
26+
id: '02-test-multiple-results',
27+
label: '02-test-multiple-results',
28+
children: [],
29+
},
30+
{
31+
id: '03-test-multiple-passing-results',
32+
label: '03-test-multiple-passing-results',
33+
children: [],
34+
},
35+
{
36+
id: '04-test-only-passing-sub-results',
37+
label: '04-test-only-passing-sub-results',
38+
children: [],
39+
},
40+
{
41+
id: '05-test-only-sub-results-one-failing',
42+
label: '05-test-only-sub-results-one-failing',
43+
children: [],
44+
},
45+
{
46+
id: '06-test-with-diff',
47+
label: '06-test-with-diff',
48+
children: [],
49+
},
50+
{
51+
id: '07-test-with-no-results',
52+
label: '07-test-with-no-results',
53+
children: [],
54+
},
55+
],
56+
},
57+
]);
58+
});
59+
60+
test('Test list after run', async function () {
61+
await e3.controller.refreshHandler!(new CancellationTokenSource().token);
62+
await commands.executeCommand('testing.runAll');
63+
64+
assert.deepStrictEqual(toTestResult(e3.controller.items), [
65+
{
66+
id: Uri.joinPath(workspace.workspaceFolders![0].uri, 'testsuite.py').toString(),
67+
label: 'testsuite.py',
68+
children: [
69+
{
70+
id: '01-test-one-result',
71+
label: '01-test-one-result',
72+
children: [],
73+
},
74+
{
75+
id: '02-test-multiple-results',
76+
label: '02-test-multiple-results',
77+
/**
78+
* We expect these sub-results to appear after the test run
79+
*/
80+
children: [
81+
{
82+
id: '02-test-multiple-results.sub3',
83+
label: '02-test-multiple-results.sub3',
84+
children: [],
85+
},
86+
{
87+
id: '02-test-multiple-results.sub2',
88+
label: '02-test-multiple-results.sub2',
89+
children: [],
90+
},
91+
{
92+
id: '02-test-multiple-results.sub1',
93+
label: '02-test-multiple-results.sub1',
94+
children: [],
95+
},
96+
],
97+
},
98+
{
99+
id: '03-test-multiple-passing-results',
100+
label: '03-test-multiple-passing-results',
101+
/**
102+
* We expect these sub-results to appear after the test run
103+
*/
104+
children: [
105+
{
106+
id: '03-test-multiple-passing-results.sub3',
107+
label: '03-test-multiple-passing-results.sub3',
108+
children: [],
109+
},
110+
{
111+
id: '03-test-multiple-passing-results.sub2',
112+
label: '03-test-multiple-passing-results.sub2',
113+
children: [],
114+
},
115+
{
116+
id: '03-test-multiple-passing-results.sub1',
117+
label: '03-test-multiple-passing-results.sub1',
118+
children: [],
119+
},
120+
],
121+
},
122+
{
123+
id: '04-test-only-passing-sub-results',
124+
label: '04-test-only-passing-sub-results',
125+
/**
126+
* We expect these sub-results to appear after the test run
127+
*/
128+
children: [
129+
{
130+
id: '04-test-only-passing-sub-results.sub3',
131+
label: '04-test-only-passing-sub-results.sub3',
132+
children: [],
133+
},
134+
{
135+
id: '04-test-only-passing-sub-results.sub2',
136+
label: '04-test-only-passing-sub-results.sub2',
137+
children: [],
138+
},
139+
{
140+
id: '04-test-only-passing-sub-results.sub1',
141+
label: '04-test-only-passing-sub-results.sub1',
142+
children: [],
143+
},
144+
],
145+
},
146+
{
147+
id: '05-test-only-sub-results-one-failing',
148+
label: '05-test-only-sub-results-one-failing',
149+
/**
150+
* We expect these sub-results to appear after the test run
151+
*/
152+
children: [
153+
{
154+
id: '05-test-only-sub-results-one-failing.sub3',
155+
label: '05-test-only-sub-results-one-failing.sub3',
156+
children: [],
157+
},
158+
{
159+
id: '05-test-only-sub-results-one-failing.sub2',
160+
label: '05-test-only-sub-results-one-failing.sub2',
161+
children: [],
162+
},
163+
{
164+
id: '05-test-only-sub-results-one-failing.sub1',
165+
label: '05-test-only-sub-results-one-failing.sub1',
166+
children: [],
167+
},
168+
],
169+
},
170+
{
171+
id: '06-test-with-diff',
172+
label: '06-test-with-diff',
173+
children: [],
174+
},
175+
{
176+
id: '07-test-with-no-results',
177+
label: '07-test-with-no-results',
178+
children: [],
179+
},
180+
],
181+
},
182+
]);
183+
});
184+
});
185+
186+
interface TestResultItem {
187+
id: string;
188+
label: string;
189+
children: TestResultItem[];
190+
}
191+
192+
function toTestResult(items: TestItemCollection): TestResultItem[] {
193+
const res: TestResultItem[] = [];
194+
function process(item: TestItem): void {
195+
res.push({
196+
id: item.id,
197+
label: item.label,
198+
children: toTestResult(item.children),
199+
});
200+
}
201+
items.forEach(process);
202+
return res;
203+
}

0 commit comments

Comments
 (0)