Skip to content

Commit 3768b57

Browse files
authored
Adapt exit code to success (#46)
1 parent d3ffece commit 3768b57

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/framework/Framework.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {StyleType} from '../reporter';
88
import {styling} from '../reporter/Style';
99
import {SuiteResult} from '../reporter/Results';
1010
import {Reporter} from '../reporter/Reporter';
11+
import {Outcome} from "../reporter/describers/Describer";
1112

1213
interface DependenceTree {
1314
test: TestScenario;
@@ -104,7 +105,9 @@ export class Framework {
104105
})))
105106
}
106107

107-
public async run(suites: Suite[]) {
108+
public async run(suites: Suite[]): Promise<boolean> {
109+
let success: boolean = true;
110+
108111
this.scheduled.concat(suites);
109112
this.reporter.general();
110113
const t0 = performance.now();
@@ -118,6 +121,7 @@ export class Framework {
118121

119122
await this.runSuite(result, testee, order);
120123
this.reporter.report(result);
124+
success = success && result.outcome === Outcome.succeeded;
121125
}))
122126
}))
123127
const t1 = performance.now();
@@ -126,6 +130,8 @@ export class Framework {
126130
await Promise.all(suites.map(suite => suite.testees.map(async (testee: Testee) => {
127131
await timeout<Object | void>('Shutdown testbed', testee.timeout, testee.shutdown());
128132
})))
133+
134+
return success;
129135
}
130136

131137
public async parallel(suites: Suite[]) {
@@ -162,10 +168,9 @@ export class Framework {
162168
}
163169
}
164170

165-
// Analyse flakiness
166-
public analyse(suite: Suite[], runs: number = 3) {
171+
public analyse(suite: Suite[], runs: number = 1) {
167172
this.runs = runs;
168-
this.run(suite);
173+
this.run(suite).then((success: boolean) => process.exit(success ? 0 : 1));
169174
}
170175

171176
public static getImplementation() {

src/manage/Compiler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class WatCompiler extends Compiler {
7272

7373
constructor(wabt: string) {
7474
super();
75-
this.wabt = wabt;
75+
this.wabt = wabt.length > 0 ? wabt + "/" : "";
7676
}
7777

7878
public async compile(program: string, dir?: string): Promise<CompileOutput> {
@@ -94,7 +94,7 @@ export class WatCompiler extends Compiler {
9494
// compile WAT to Wasm
9595
return new Promise<CompileOutput>((resolve, reject) => {
9696
const file = `${dir}/upload.wasm`;
97-
const command = `${this.wabt}/wat2wasm --no-canonicalize-leb128s --disable-bulk-memory --debug-names -v -o ${file} ${program}`;
97+
const command = `${this.wabt}wat2wasm --no-canonicalize-leb128s --disable-bulk-memory --debug-names -v -o ${file} ${program}`;
9898
let out: string = '';
9999
let err: string = '';
100100

@@ -122,7 +122,7 @@ export class WatCompiler extends Compiler {
122122
public dump(output: CompileOutput): Promise<CompileOutput> {
123123
// object dump
124124
return new Promise<CompileOutput>((resolve, reject) => {
125-
const command = `${this.wabt}/wasm-objdump -x -m ${output.file}`;
125+
const command = `${this.wabt}wasm-objdump -x -m ${output.file}`;
126126

127127
const compile = exec(command, (error: ExecException | null, stdout: string) => {
128128
output.map = this.parseWasmObjDump(output, stdout.toString());

src/util/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {homedir} from 'os';
22

3-
export const WABT: string = process.env.WABT ?? `${homedir()}/Documents/TOPL/plugin/WABT/build/`;
3+
export const WABT: string = process.env.WABT ?? `${homedir()}/Arduino/libraries/WARDuino/lib/wabt/build/`;
44

55
export const EMULATOR: string = process.env.EMULATOR ?? `${homedir()}/Arduino/libraries/WARDuino/build-emu/wdcli`;
66

tests/examples/example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ debug.test({
9494
steps: [DUMP]
9595
});
9696

97-
framework.run([spec, debug]).then(() => process.exit(0));
97+
framework.analyse([spec, debug]);

0 commit comments

Comments
 (0)