Skip to content

Commit 4444460

Browse files
committed
finish
1 parent 006c5f6 commit 4444460

File tree

6 files changed

+28
-5
lines changed

6 files changed

+28
-5
lines changed

src/core/execute.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async function nodeExecutor(
7070
executionRecorder.startTestFunction(`${instrumentResult.baseName} - init`);
7171
wasi.start(ins);
7272
} catch (error) {
73-
exceptionHandler(error);
73+
await exceptionHandler(error);
7474
}
7575
executionRecorder.finishTestFunction();
7676

@@ -87,7 +87,7 @@ async function nodeExecutor(
8787
try {
8888
(execTestFunction as (a: number) => void)(functionIndex);
8989
} catch (error) {
90-
exceptionHandler(error);
90+
await exceptionHandler(error);
9191
}
9292
executionRecorder.finishTestFunction();
9393
mockInstrumentFunc["mockFunctionStatus.clear"]();

src/core/executionRecorder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import chalk from "chalk";
12
import {
23
UnitTestFramework,
34
ImportsArgument,
@@ -80,7 +81,7 @@ export class ExecutionRecorder implements UnitTestFramework {
8081
}
8182

8283
notifyTestCrash(error: ExecutionError): void {
83-
this.logRecorder.addLog(`Reason: ${error.message}`);
84+
this.logRecorder.addLog(`Reason: ${chalk.red(error.message)}`);
8485
this.logRecorder.addLog(
8586
error.stacks
8687
.map((stack) => ` at ${stack.functionName} (${stack.fileName}:${stack.lineNumber}:${stack.columnNumber})`)

src/executionResult.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@ export class ExecutionResultSummary {
9999
log(" " + chalk.yellow(assertMessage));
100100
}
101101
if (hasCrash) {
102-
log(" " + chalk.red("Test case crashed!"));
102+
log(" " + chalk.red("Test Crashed!"));
103103
}
104104
for (const logMessage of logMessages ?? []) {
105105
log(chalk.gray(logMessage));
106106
}
107+
if (logMessages.length > 0) {
108+
// empty line to separate test
109+
log("");
110+
}
107111
}
108112
}
109113
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, expect } from "../../../assembly";
22
import { log } from "./env";
33

4-
test("assertOnTest", () => {
4+
test("assert on test", () => {
55
log("This test will fail due to an assertion error");
66
assert(false, "This assertion is expected to fail");
77
});

tests/e2e/assertFailed/stdout.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
code analysis: OK
22
compile testcases: OK
33
instrument: OK
4+
execute testcases: OK
5+
6+
test case: 0/2 (success/total)
7+
8+
Error Message:
9+
tests/e2e/assertFailed/tmp/assertOnInit.test - init:
10+
Test Crashed!
11+
Reason: unreachable
12+
at start:tests/e2e/assertFailed/assertOnInit.test (tests/e2e/assertFailed/assertOnInit.test.ts:1:0)
13+
at ~start (tests/e2e/assertFailed/tmp/assertOnInit.test.instrumented.wasm:1:244)
14+
15+
assert on test:
16+
Test Crashed!
17+
This test will fail due to an assertion error
18+
Reason: unreachable
19+
at start:tests/e2e/assertFailed/assertOnTest.test~anonymous|0 (tests/e2e/assertFailed/assertOnTest.test.ts:6:2)
20+
at executeTestFunction (tests/e2e/assertFailed/tmp/assertOnTest.test.instrumented.wasm:1:675)
421

tests/e2e/printLogInFailedInfo/stdout.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Error Message:
99
failed test:
1010
tests/e2e/printLogInFailedInfo/source.test.ts:6:2 value: 2 expect: = 3
1111
This is a log message for the failed test.
12+

0 commit comments

Comments
 (0)