Skip to content

Commit 8da07d6

Browse files
committed
Improve output structure
1 parent 18efdde commit 8da07d6

8 files changed

Lines changed: 168 additions & 132 deletions

File tree

assets/demo.gif

469 KB
Loading

package-lock.json

Lines changed: 9 additions & 121 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
{
22
"name": "latch",
3-
"description": "A testing language for constraint environments",
3+
"description": "A testing framework for constrained environments",
44
"version": "0.6.0",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/TOPLLab/latch.git"
8+
},
9+
"homepage": "https://topllab.github.io/WARDuino/guide/latch.html",
10+
"bugs": {
11+
"url": "https://github.com/TOPLLab/latch/issues"
12+
},
13+
"keywords": [
14+
"testing",
15+
"webassembly",
16+
"wasm",
17+
"embedded",
18+
"hardware"
19+
],
520
"exports": {
621
"types": "./dist/types/index.d.ts",
722
"require": "./dist/index.js"
@@ -18,7 +33,9 @@
1833
"build:tests": "tsc --outDir out --project tsconfig.tests.json",
1934
"watch": "tsc -watch -p ./",
2035
"lint": "eslint src/**/* --config .eslint.config.mjs",
36+
"format": "eslint src/**/* --config .eslint.config.mjs --fix",
2137
"test:prebuild": "npm run build && npm run build:tests",
38+
"test": "npm run test:all",
2239
"test:all": "npm run test:prebuild && npm run test:ava",
2340
"test:ava": "ava",
2441
"test:example": "npx ts-node ./tests/examples/example.ts",
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import {Box, Text} from 'ink';
2+
import {ReporterSnapshot} from '../ReporterState';
3+
import {Outcome} from '../Outcome';
4+
import {Result, ScenarioResult} from '../Results';
5+
import {StatusBadge} from './StatusBadge';
6+
7+
interface Props {
8+
snapshot: ReporterSnapshot;
9+
}
10+
11+
const failed = (outcome: Outcome): boolean => outcome === Outcome.failed || outcome === Outcome.error || outcome === Outcome.timedout;
12+
13+
interface FailureRow {
14+
scenario: ScenarioResult;
15+
step?: Result;
16+
}
17+
18+
const failureRows = (scenarios: ScenarioResult[]): FailureRow[] => scenarios.flatMap<FailureRow>((scenario): FailureRow[] => {
19+
const steps = scenario.outcomes().filter((step) => failed(step.outcome));
20+
return steps.length === 0 ? [{scenario}] : steps.map((step) => ({scenario, step}));
21+
});
22+
23+
export function ActiveFailures({snapshot}: Props) {
24+
const failures = snapshot.activeRuns.map((run) => ({
25+
run,
26+
scenarios: run.scenarios.filter((scenario) => failed(scenario.outcome))
27+
})).filter(({scenarios}) => scenarios.length > 0);
28+
29+
if (failures.length === 0) {
30+
return null;
31+
}
32+
33+
return (
34+
<Box flexDirection="column" marginTop={1}>
35+
{failures.map(({run, scenarios}) => (
36+
<Box key={`${run.id}-failures`} flexDirection="column">
37+
<Text>
38+
<StatusBadge outcome={Outcome.failed}/>
39+
<Text> {run.suiteTitle}</Text>
40+
<Text color="gray"> ({scenarios.length}/{run.plannedScenarios ?? run.scenarios.length})</Text>
41+
</Text>
42+
{failureRows(scenarios).map(({scenario, step}) => (
43+
<Box key={`${run.id}-failure-${scenario.name}-${step?.name ?? 'scenario'}`} marginLeft={5}>
44+
<Text>
45+
<Text color="gray">TEST</Text>
46+
<Text> {scenario.name}</Text>
47+
{step ? <Text color="gray"> · {step.name}</Text> : null}
48+
</Text>
49+
</Box>
50+
))}
51+
</Box>
52+
))}
53+
</Box>
54+
);
55+
}

src/reporter/ink/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {SuiteList} from './SuiteList';
77
import {LogPanel} from './LogPanel';
88
import {FinalSummary} from './FinalSummary';
99
import {showsDebugDetails} from './verbosity';
10+
import {ActiveFailures} from './ActiveFailures';
1011

1112
interface Props {
1213
snapshot: ReporterSnapshot;
@@ -29,6 +30,7 @@ export function App({snapshot, archive, verbosity}: Props) {
2930
<Box flexDirection="column">
3031
<RunHeader archive={archive}/>
3132
<SuiteList snapshot={snapshot} verbosity={verbosity}/>
33+
{verbosity === Verbosity.normal ? <ActiveFailures snapshot={snapshot}/> : null}
3234
<ProgressSummary snapshot={snapshot}/>
3335
<LogPanel logs={snapshot.logs} verbosity={verbosity}/>
3436
</Box>

src/reporter/ink/RunHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ interface Props {
77

88
export function RunHeader({archive}: Props) {
99
return (
10-
<Box flexDirection="column" marginBottom={1}>
10+
<Box flexDirection="row" marginBottom={1}>
1111
<Text bold>Latch</Text>
12-
<Text color="gray">v{version} · archive {archive}</Text>
12+
<Text color="gray"> v{version} · archive {archive}</Text>
1313
</Box>
1414
);
1515
}

0 commit comments

Comments
 (0)