Skip to content

Commit 4ac3d78

Browse files
authored
Merge 441f8a4 into 9c00306
2 parents 9c00306 + 441f8a4 commit 4ac3d78

15 files changed

Lines changed: 137 additions & 139 deletions

File tree

src/framework/Scheduler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function trees(input: TestScenario[]): TestScenario[][][] {
8787
input.sort(comparator);
8888

8989
// output
90-
let forest: TestScenario[][][] = [];
90+
const forest: TestScenario[][][] = [];
9191

9292
// scenario that have already been seen
9393
const seen = new Set<TestScenario>();
@@ -100,7 +100,7 @@ function trees(input: TestScenario[]): TestScenario[][][] {
100100
continue;
101101
}
102102
// start a new tree
103-
let t: TestScenario[][] = tree(test);
103+
const t: TestScenario[][] = tree(test);
104104
forest.push(t);
105105
pointer = forest.length - 1;
106106

@@ -129,7 +129,7 @@ function trees(input: TestScenario[]): TestScenario[][][] {
129129
function tree(root: TestScenario): TestScenario[][] {
130130
let result: TestScenario[][] = [];
131131

132-
let lifo: TestScenario[] = [...root.dependencies ?? []];
132+
const lifo: TestScenario[] = [...root.dependencies ?? []];
133133
for (const test of lifo) {
134134
const c = tree(test);
135135
result = merge(c, result);
@@ -188,7 +188,7 @@ function levels(input: TestScenario[]): TestScenario[][] {
188188
const test: TestScenario = input.shift()!;
189189

190190
// skip any test with unresolved dependencies
191-
let skip: boolean = (test.dependencies ?? []).some((dependence: TestScenario) => input.includes(dependence));
191+
const skip: boolean = (test.dependencies ?? []).some((dependence: TestScenario) => input.includes(dependence));
192192

193193
if (skip) {
194194
input.push(test);

src/framework/TestResult.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import {v4 as randomUUID} from 'uuid';
22

3-
/* eslint-disable @typescript-eslint/naming-convention */
43
export enum Status {
54
FAILED = 'failed',
65
BROKEN = 'broken',
76
PASSED = 'passed',
87
SKIPPED = 'skipped',
98
}
109

11-
/* eslint-disable @typescript-eslint/naming-convention */
1210
export enum Stage {
1311
SCHEDULED = 'scheduled',
1412
RUNNING = 'running',

src/framework/Testee.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export class Testee { // TODO unified with testbed interface
167167
return;
168168
}
169169

170-
let compiled: CompileOutput = await new CompilerFactory(WABT).pickCompiler(description.program).compile(description.program);
170+
const compiled: CompileOutput = await new CompilerFactory(WABT).pickCompiler(description.program).compile(description.program);
171171
try {
172172
await timeout<Object | void>(`uploading module`, testee.timeout, testee.bed()!.sendRequest(new SourceMap.Mapping(), Message.updateModule(compiled.file))).catch((e) => Promise.reject(e));
173173
testee.current = description.program;

src/manage/Compiler.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ enum CompilationEvents {
1818

1919
export interface CompileOutput {
2020
file: string;
21-
out?: String;
22-
err?: String;
21+
out?: string;
22+
err?: string;
2323
map?: SourceMap.Mapping;
2424
}
2525

@@ -33,13 +33,13 @@ export class CompilerFactory {
3333
}
3434

3535
public pickCompiler(file: string): Compiler {
36-
let fileType = getFileExtension(file);
36+
const fileType = getFileExtension(file);
3737
switch (fileType) {
38-
case 'wast' :
39-
case 'wat' :
40-
return this.wat;
41-
case 'ts' :
42-
return this.asc;
38+
case 'wast' :
39+
case 'wat' :
40+
return this.wat;
41+
case 'ts' :
42+
return this.asc;
4343
}
4444
throw new Error('Unsupported file type');
4545
}
@@ -95,15 +95,15 @@ export class WatCompiler extends Compiler {
9595
return new Promise<CompileOutput>((resolve, reject) => {
9696
const file = `${dir}/upload.wasm`;
9797
const command = `${this.wabt}/wat2wasm --no-canonicalize-leb128s --disable-bulk-memory --debug-names -v -o ${file} ${program}`;
98-
let out: String = '';
99-
let err: String = '';
98+
let out: string = '';
99+
let err: string = '';
100100

101-
function handle(error: ExecException | null, stdout: String, stderr: any) {
101+
function handle(error: ExecException | null, stdout: string) {
102102
out = stdout;
103103
err = error?.message ?? '';
104104
}
105105

106-
let compile = exec(command, handle);
106+
const compile = exec(command, handle);
107107
this.emit(CompilationEvents.started, command);
108108

109109
compile.on('close', (code) => {
@@ -124,7 +124,7 @@ export class WatCompiler extends Compiler {
124124
return new Promise<CompileOutput>((resolve, reject) => {
125125
const command = `${this.wabt}/wasm-objdump -x -m ${output.file}`;
126126

127-
let compile = exec(command, (error: ExecException | null, stdout: String, stderr: any) => {
127+
const compile = exec(command, (error: ExecException | null, stdout: string) => {
128128
output.map = this.parseWasmObjDump(output, stdout.toString());
129129
this.emit(CompilationEvents.sourcemap);
130130
resolve(output);
@@ -212,17 +212,17 @@ export class AsScriptCompiler extends Compiler {
212212

213213
// compile AS to Wasm and WAT
214214
return new Promise<CompileOutput>(async (resolve, reject) => {
215-
let file = `${dir}/upload.wasm`;
215+
const file = `${dir}/upload.wasm`;
216216
const command = await this.getCompilationCommand(program, file);
217-
let out: String = '';
218-
let err: String = '';
217+
let out: string = '';
218+
let err: string = '';
219219

220-
function handle(error: ExecException | null, stdout: String, stderr: any) {
220+
function handle(error: ExecException | null, stdout: string) {
221221
out = stdout;
222222
err = error?.message ?? '';
223223
}
224224

225-
let compile = exec(command, handle);
225+
const compile = exec(command, handle);
226226

227227
compile.on('close', (code) => {
228228
if (code !== 0) {
@@ -239,23 +239,23 @@ export class AsScriptCompiler extends Compiler {
239239
private getCompilationCommand(program: string, output: string): Promise<string> {
240240
// builds asc command based on the version of asc
241241
return new Promise<string>(async (resolve) => {
242-
let version: Version = await AsScriptCompiler.retrieveVersion();
242+
const version: Version = await AsScriptCompiler.retrieveVersion();
243243
resolve(`npx asc ${program} --exportTable --disable bulk-memory --sourceMap --debug ` +
244244
`${(version.major > 0 || +version.minor >= 20) ? '--outFile' : '--binaryFile'} ${output}`);
245245
});
246246
}
247247

248248
private static retrieveVersion(): Promise<Version> {
249249
return new Promise<Version>((resolve, reject) => {
250-
let out: String = '';
251-
let err: String = '';
250+
let out: string = '';
251+
let err: string = '';
252252

253-
function handle(error: ExecException | null, stdout: String, stderr: any) {
253+
function handle(error: ExecException | null, stdout: string) {
254254
out = stdout;
255255
err = error?.message ?? '';
256256
}
257257

258-
let compilerVersion = exec('npx asc --version', handle);
258+
const compilerVersion = exec('npx asc --version', handle);
259259
compilerVersion.on('close', (code) => {
260260
if (code !== 0) {
261261
reject(`asc --version failed: ${err}`);
@@ -299,7 +299,7 @@ function parseLines(context: CompileOutput): SourceMap.SourceLine[] {
299299

300300
const lines: string[] = context.out.split('\n');
301301
const corrections = extractSectionAddressCorrections(lines);
302-
let result: SourceLine[] = [];
302+
const result: SourceLine[] = [];
303303
let lastLineInfo = undefined;
304304
for (let i = 0; i < lines.length; i++) {
305305
const line = lines[i];
@@ -331,8 +331,8 @@ function parseLines(context: CompileOutput): SourceMap.SourceLine[] {
331331
}
332332

333333
export function extractAddressInformation(addressLine: string): string {
334-
let regexpr = /^(?<address>([\da-f])+):/;
335-
let match = addressLine.match(regexpr);
334+
const regexpr = /^(?<address>([\da-f])+):/;
335+
const match = addressLine.match(regexpr);
336336
if (match?.groups) {
337337
return match.groups.address;
338338
}

src/manage/Uploader.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ export class UploaderFactory {
3535

3636
public pickUploader(specification: TestbedSpecification, args: string[] = []): Uploader {
3737
switch (specification.type) {
38-
case PlatformType.arduino:
39-
return new ArduinoUploader(this.arduino, args, specification.options as SerialOptions);
40-
case PlatformType.emulator:
41-
case PlatformType.emu2emu:
42-
case PlatformType.emuproxy:
43-
return new EmulatorUploader(this.emulator, args, specification.options as SubprocessOptions);
44-
case PlatformType.debug:
45-
return new EmulatorConnector(specification.options as SubprocessOptions)
38+
case PlatformType.arduino:
39+
return new ArduinoUploader(this.arduino, args, specification.options as SerialOptions);
40+
case PlatformType.emulator:
41+
case PlatformType.emu2emu:
42+
case PlatformType.emuproxy:
43+
return new EmulatorUploader(this.emulator, args, specification.options as SubprocessOptions);
44+
case PlatformType.debug:
45+
return new EmulatorConnector(specification.options as SubprocessOptions)
4646
}
4747
throw new Error('Unsupported platform type');
4848
}
@@ -206,7 +206,7 @@ export class ArduinoUploader extends Uploader {
206206
private stage(program: string): Promise<void> {
207207
const that = this;
208208
return new Promise<void>((resolve, reject) => {
209-
let compile = exec(`make compile PAUSED=true BINARY=${program}`, {cwd: this.sdkpath});
209+
const compile = exec(`make compile PAUSED=true BINARY=${program}`, {cwd: this.sdkpath});
210210

211211
compile.on('close', (code) => {
212212
if (code !== 0) {

src/messaging/Message.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export namespace Message {
128128
}
129129

130130
export async function uploadFile(program: string): Promise<Request<Ack>> {
131-
let compiled: CompileOutput = await new CompilerFactory(WABT).pickCompiler(program).compile(program);
131+
const compiled: CompileOutput = await new CompilerFactory(WABT).pickCompiler(program).compile(program);
132132
return updateModule(compiled.file);
133133
}
134134

src/messaging/Parsers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function ackParser(text: string, ack: string): Ack {
3939
export function breakpointParser(text: string): Breakpoint {
4040
const ack: Ack = ackParser(text, 'BP');
4141

42-
let breakpointInfo = ack.text.match(/BP (0x.*)!/);
42+
const breakpointInfo = ack.text.match(/BP (0x.*)!/);
4343
if (breakpointInfo!.length > 1) {
4444
return new Breakpoint(parseInt(breakpointInfo![1]), 0); // TODO address to line mapping
4545
}
@@ -50,7 +50,7 @@ export function breakpointParser(text: string): Breakpoint {
5050
export function breakpointHitParser(text: string): Breakpoint {
5151
const ack: Ack = ackParser(text, 'AT ');
5252

53-
let breakpointInfo = ack.text.match(/AT (0x.*)!/);
53+
const breakpointInfo = ack.text.match(/AT (0x.*)!/);
5454
if (breakpointInfo!.length > 1) {
5555
return new Breakpoint(parseInt(breakpointInfo![1]), 0); // TODO address to line mapping
5656
}

src/reporter/Reporter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ export class Reporter {
183183
results(time: number) {
184184
this.archiver.set('duration (ms)', Math.round(time));
185185

186-
let passing = this.suites.flatMap((suite) => suite.scenarios).filter((scenario) => scenario.passing()).length;
187-
let failing = this.suites.flatMap((suite) => suite.scenarios).filter((scenario) => scenario.failing()).length;
186+
const passing = this.suites.flatMap((suite) => suite.scenarios).filter((scenario) => scenario.passing()).length;
187+
const failing = this.suites.flatMap((suite) => suite.scenarios).filter((scenario) => scenario.failing()).length;
188188
const skipped = this.suites.flatMap((suite) => suite.scenarios).filter((scenario) => scenario.skipped()).length;
189189

190190
const scs = this.suites.flatMap((suite) => suite.scenarios);

src/reporter/Result.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ export class Result {
2020

2121
toString(): string {
2222
switch (this.completion) {
23-
case Completion.succeeded:
24-
return `${bold(inverse(green(' PASS ')))} ${this.name}`;
25-
case Completion.uncommenced:
26-
return `${bold(inverse(yellow(' SKIP ')))} ${this.name}`;
27-
case Completion.error:
28-
case Completion.failed:
29-
default:
30-
return `${bold(inverse(red(' FAIL ')))} ${this.name}\n ${red(this.completion)}${red(this.description)}`;
23+
case Completion.succeeded:
24+
return `${bold(inverse(green(' PASS ')))} ${this.name}`;
25+
case Completion.uncommenced:
26+
return `${bold(inverse(yellow(' SKIP ')))} ${this.name}`;
27+
case Completion.error:
28+
case Completion.failed:
29+
default:
30+
return `${bold(inverse(red(' FAIL ')))} ${this.name}\n ${red(this.completion)}${red(this.description)}`;
3131

3232
}
3333
}
@@ -74,38 +74,38 @@ export class Result {
7474

7575
public expectBehaviour(actual: any, previous: any, behaviour: Behaviour): void {
7676
switch (behaviour) {
77-
case Behaviour.unchanged:
78-
if (deepEqual(actual, previous)) {
79-
this.completion = Completion.succeeded;
80-
} else {
81-
this.completion = Completion.failed;
82-
this.description = `Expected ${actual} to equal ${previous}`
83-
}
84-
break;
85-
case Behaviour.changed:
86-
if (!deepEqual(actual, previous)) {
87-
this.completion = Completion.succeeded;
88-
} else {
89-
this.completion = Completion.failed;
90-
this.description = `Expected ${actual} to be different from ${previous}`
91-
}
92-
break;
93-
case Behaviour.increased:
94-
if (actual > previous) {
95-
this.completion = Completion.succeeded;
96-
} else {
97-
this.completion = Completion.failed;
98-
this.description = `Expected ${actual} to be greater than ${previous}`
99-
}
100-
break;
101-
case Behaviour.decreased:
102-
if (actual < previous) {
103-
this.completion = Completion.succeeded;
104-
} else {
105-
this.completion = Completion.failed;
106-
this.description = `Expected ${actual} to be less than ${previous}`
107-
}
108-
break;
77+
case Behaviour.unchanged:
78+
if (deepEqual(actual, previous)) {
79+
this.completion = Completion.succeeded;
80+
} else {
81+
this.completion = Completion.failed;
82+
this.description = `Expected ${actual} to equal ${previous}`
83+
}
84+
break;
85+
case Behaviour.changed:
86+
if (!deepEqual(actual, previous)) {
87+
this.completion = Completion.succeeded;
88+
} else {
89+
this.completion = Completion.failed;
90+
this.description = `Expected ${actual} to be different from ${previous}`
91+
}
92+
break;
93+
case Behaviour.increased:
94+
if (actual > previous) {
95+
this.completion = Completion.succeeded;
96+
} else {
97+
this.completion = Completion.failed;
98+
this.description = `Expected ${actual} to be greater than ${previous}`
99+
}
100+
break;
101+
case Behaviour.decreased:
102+
if (actual < previous) {
103+
this.completion = Completion.succeeded;
104+
} else {
105+
this.completion = Completion.failed;
106+
this.description = `Expected ${actual} to be less than ${previous}`
107+
}
108+
break;
109109
}
110110
}
111111
}

src/reporter/Style.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ interface Labels {
2525
// strategy factory
2626
export function styling(type: StyleType): Style {
2727
switch (type) {
28-
case StyleType.github:
29-
case StyleType.plain:
30-
default:
31-
return new Plain();
28+
case StyleType.github:
29+
case StyleType.plain:
30+
default:
31+
return new Plain();
3232
}
3333
}
3434

0 commit comments

Comments
 (0)