Skip to content

Commit 1b7ebd8

Browse files
committed
🧪 add retries
1 parent de4cd6a commit 1b7ebd8

File tree

3 files changed

+12
-88
lines changed

3 files changed

+12
-88
lines changed

src/test/suite/ASM.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,18 @@ const emulator: DosEmulatorType[] = [
5757
DosEmulatorType.jsdos,
5858
];
5959

60+
if (!process.platform) {
61+
emulator.shift();
62+
emulator.shift();
63+
}
64+
6065
const filelist: [string, number][] = [
6166
['1.asm', 0],
6267
['3中文路径hasError.asm', 1],
6368
['multi/2.asm', 0],
6469
];
6570

66-
suite("single file mode test", function () {
71+
export const singleFileTestSuite = suite("single file mode test", function () {
6772
this.timeout('60s');
6873
this.slow('20s');
6974
for (const emu of emulator) {
@@ -81,7 +86,7 @@ suite("single file mode test", function () {
8186
}
8287
});
8388

84-
suite("workspace mode test", function () {
89+
export const workspaceTestSuite = suite("workspace mode test", function () {
8590
this.timeout('60s');
8691
this.slow('20s');
8792
for (const emu of emulator) {

src/test/suite/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export function run(): Promise<void> {
88
const mocha = new Mocha({
99
ui: 'tdd',
1010
color: true,
11-
timeout: 2000
11+
timeout: 2000,
12+
retries: 3,
1213
});
1314

1415
if (process.platform === 'linux') {

src/web/test/suite/ASM.test.ts

Lines changed: 3 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,4 @@
1+
import { singleFileTestSuite, workspaceTestSuite } from "../../../test/suite/ASM.test";
12

2-
import * as assert from 'assert';
3-
4-
// You can import and use all API from the 'vscode' module
5-
// as well as import your extension to test it
6-
import * as vscode from 'vscode';
7-
import { AsmResult } from '../../../ASM/manager';
8-
import { DosEmulatorType, Assembler } from '../../../utils/configuration';
9-
10-
// import * as myExtension from '../../extension';
11-
const folders = vscode.workspace.workspaceFolders;
12-
if (folders === undefined) {
13-
throw new Error();
14-
}
15-
const samplesUri = folders[0].uri;
16-
17-
suite('Extension Test Suite', function () {
18-
vscode.window.showInformationMessage('Start all tests.');
19-
const MASMorTASM = [
20-
'MASM-v5.00',
21-
'MASM-v6.11',
22-
'TASM',
23-
];
24-
const emulator: DosEmulatorType[] = [
25-
DosEmulatorType.jsdos,
26-
];
27-
28-
const filelist: [string, number][] = [
29-
['1.asm', 0],
30-
['3中文路径hasError.asm', 1],
31-
// ['2.asm', DIAGCODE.ok],
32-
];
33-
34-
const args: [string, number, DosEmulatorType, Assembler][] = [];
35-
for (const file of filelist) {
36-
for (const emu of emulator) {
37-
for (const asm of MASMorTASM) {
38-
args.push([file[0], file[1], emu, asm]);
39-
}
40-
}
41-
}
42-
43-
this.beforeEach(async function () {
44-
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
45-
});
46-
47-
shuffle(args).forEach((val) => { testAsmCode(...val); });
48-
});
49-
50-
function testAsmCode(file: string, shouldErr: number, emu: DosEmulatorType, asm: Assembler): void {
51-
test(`test file ${file} in ${emu} use ${asm} want should ${shouldErr} error`,
52-
async function () {
53-
this.timeout('60s');
54-
this.slow('20s');
55-
56-
//open test file. NOTE: the extension will be activated when open .asm file
57-
const samplefile = vscode.Uri.joinPath(samplesUri, file);
58-
59-
//update settings
60-
await vscode.workspace.getConfiguration('masmtasm').update("dosbox.run", "exit");
61-
await vscode.workspace.getConfiguration('masmtasm').update("ASM.emulator", emu);
62-
await vscode.workspace.getConfiguration('masmtasm').update("ASM.assembler", asm);
63-
64-
//assert the extension activated and command contributed
65-
const vscodecmds = await vscode.commands.getCommands(true);
66-
const cmd = 'masm-tasm.runASM';
67-
if (!vscodecmds.includes(cmd)) {
68-
await vscode.extensions.getExtension('xsro.masm-tasm')?.activate();
69-
}
70-
const vscodecmds2 = await vscode.commands.getCommands(true);
71-
assert.ok(vscodecmds2.includes(cmd));
72-
73-
//assert message processed
74-
const _result = await vscode.commands.executeCommand(cmd, samplefile);
75-
const { message, error } = _result as AsmResult;
76-
assert.strictEqual(error, shouldErr, message);
77-
});
78-
}
79-
80-
function shuffle<T>(arr: T[]): T[] {
81-
for (let i = 1; i < arr.length; i++) {
82-
const random = Math.floor(Math.random() * (i + 1));
83-
[arr[i], arr[random]] = [arr[random], arr[i]];
84-
}
85-
return arr;
86-
}
3+
singleFileTestSuite;
4+
workspaceTestSuite;

0 commit comments

Comments
 (0)