Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/actions/build-warduino/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Check out and build a WARDuino CLI version

inputs:
version:
description: WARDuino version tag without the optional v prefix, latest, or dirty
description: WARDuino version tag (with or without the v prefix), branch, or latest
required: false
default: latest

Expand All @@ -22,8 +22,8 @@ runs:
| sort --version-sort \
| tail --lines=1)
test -n "$VERSION"
elif [ "$WARDUINO_VERSION" = "dirty" ]; then
VERSION=main
elif git ls-remote --exit-code --heads https://github.com/TOPLLab/WARDuino.git "$WARDUINO_VERSION" > /dev/null; then
VERSION="$WARDUINO_VERSION"
else
VERSION="${WARDUINO_VERSION#v}"
VERSION="v$VERSION"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Build WARDuino CLI
uses: ./.github/actions/build-warduino
with:
version: 0.8.1
version: nanopb

- name: Upload built tools
uses: actions/upload-artifact@v4
Expand All @@ -62,6 +62,7 @@ jobs:
steps:
- uses: actions/checkout@v4


- run: npm i

- name: Prebuild files
Expand Down
8 changes: 8 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lint:
npx eslint src/**/* --config .eslint.config.mjs

format:
npx eslint src/**/* --config .eslint.config.mjs --fix

protocol:
temp_dir=$(mktemp -d) && trap 'rm -rf "$temp_dir"' EXIT && curl --fail --silent --show-error --location https://raw.githubusercontent.com/TOPLLab/WARDuino/7805f0bc87e79c55c151788a279f2ecb13e0fa7a/src/Debug/debug.proto --output "$temp_dir/debug.proto" && protoc --proto_path="$temp_dir" --plugin=protoc-gen-ts_proto=node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=src/protocol/vendor --ts_proto_opt=env=node,forceLong=bigint,useOptionals=messages,outputEncodeMethods=true,outputJsonMethods=false "$temp_dir/debug.proto"
80 changes: 80 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"test:prebuild": "npm run build && npm run build:tests",
"test": "npm run test:all",
"test:all": "npm run test:prebuild && npm run test:ava && npm run test:integration && npm run test:end-to-end",
"protocol:generate": "just protocol",
"test:ava": "ava",
"test:integration": "npx ts-node ./tests/integration/precision.ts",
"test:end-to-end": "npx ts-node ./tests/end-to-end/end2end.test.ts",
Expand Down Expand Up @@ -76,6 +77,7 @@
"ink-testing-library": "^2.1.0",
"mqtt": "^5.15.1",
"serialport": "^13.0.0",
"ts-proto": "^2.12.1",
"typescript-eslint": "^8.60.1"
},
"ava": {
Expand Down
16 changes: 10 additions & 6 deletions src/framework/Testee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,19 @@ export class Testee { // TODO unified with testbed interface
recover: (t: Testee) => Promise<any>,
retries: number = 0): Promise<object | void> {
let result: object | void = undefined;
let error;
while (0 <= retries && result === undefined) {
result = await attempt(testee, step, map).catch(async (err) => {
let error: unknown;
let succeeded = false;
while (0 <= retries && !succeeded) {
try {
result = await attempt(testee, step, map);
succeeded = true;
} catch (err) {
error = err;
await recover(testee);
});
retries--;
retries--;
}
}
return (result === undefined) ? Promise.reject(error) : result;
return succeeded ? result! : Promise.reject(error);
}

public skipall(): Testee {
Expand Down
19 changes: 8 additions & 11 deletions src/framework/scenario/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {setTimeout} from 'timers/promises';
import {Testee} from '../Testee';
import {TestbedEvents} from '../../testbeds/Testbed';
import {Breakpoint} from '../../debug/Breakpoint';
import {breakpointHitParser} from '../../messaging/Parsers';
import {DebugFrame} from '../../protocol/frame';
import {HitBreakpoint, NotificationType} from '../../protocol/vendor/debug';

export interface Dictionary {
[index: string]: any;
Expand Down Expand Up @@ -32,16 +33,12 @@ export function awaitBreakpoint(): Action<Breakpoint> {
return {
act: (testee: Testee) => {
return new Promise<Assertable<Breakpoint>>((resolve) => {
function breakpointListener(message: string) {
// check breakpoint hit message
try {
const breakpoint = breakpointHitParser(message);
// on success: remove listener + resolve
testee.bed()?.removeListener(TestbedEvents.OnMessage, breakpointListener);
resolve(assertable(breakpoint));
} catch {
// breakpoint not hit yet
}
function breakpointListener(frame: DebugFrame) {
if (frame.type !== NotificationType.NOTIFICATION_HIT_BREAKPOINT) return;
const location = HitBreakpoint.decode(frame.payload).location;
if (location === undefined) return;
testee.bed()?.removeListener(TestbedEvents.OnMessage, breakpointListener);
resolve(assertable(new Breakpoint(location.programCounter, 0)));
}

// await breakpoint hit
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ export * from './testbeds/TestbedSpecification';
export * from './debug/Breakpoint';
export * from './reporter/index';
export * from './debug/WARDuino';
export * from './protocol/frame';
export * as DebugProtocol from './protocol/vendor/debug';

export const latch = Framework.getImplementation();
Loading
Loading