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
108 changes: 103 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,80 @@ name: Tests
on: [ push ]

jobs:
build-wabt:
name: Build WAT tools
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Get WABT commit ID
working-directory: tests/artifacts/wabt
run: echo "WABT_VERSION=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Cache wabt
uses: actions/cache@v4
id: cache-wabt
with:
key: ${{ runner.os }}-wabt-${{ env.WABT_VERSION }}
path: tests/artifacts/wabt
restore-keys: |
${{ runner.os }}-wabt-

- name: Build WABT # Build latest version
if: steps.cache-wabt.outputs.cache-hit == false
working-directory: tests/artifacts/wabt
run: |
mkdir build; cd build
cmake ..
cmake --build .

- name: Upload built tools
uses: actions/upload-artifact@v4
with:
name: wabt-build-${{ github.run_id }}
path: tests/artifacts/wabt/build

build-wdcli:
name: Build WARDuino CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Get WDCLI commit ID
working-directory: tests/artifacts/warduino
run: echo "WDCLI_VERSION=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Cache WARDuino CLI
uses: actions/cache@v4
id: cache-warduino
with:
key: ${{ runner.os }}-warduino-${{ env.WDCLI_VERSION }}
path: tests/artifacts/warduino
restore-keys: |
${{ runner.os }}-warduino-

- name: Build WARDuino CLI # Build latest version
if: steps.cache-warduino.outputs.cache-hit == false
working-directory: tests/artifacts/warduino
run: |
mkdir build; cd build
cmake .. -D BUILD_EMULATOR=ON
cmake --build .

- name: Upload built tools
uses: actions/upload-artifact@v4
with:
name: warduino-build-${{ github.run_id }}
path: tests/artifacts/warduino/build

unit:
name: Unit tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
needs: build-wabt
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
Expand All @@ -16,14 +85,26 @@ jobs:
- name: Prebuild files
run: npm run test:prebuild

- name: Download WAT tools
uses: actions/download-artifact@v4
with:
name: wabt-build-${{ github.run_id }}
path: .tools

- name: Verify tools
run: |
chmod u+x $GITHUB_WORKSPACE/.tools/*
$GITHUB_WORKSPACE/.tools/wasm-objdump --version

- name: Run ava unit tests
run: npm run test:ava
env:
WABT: ${GITHUB_WORKSPACE}/.tools

coverage:
name: Code coverage
runs-on: ubuntu-latest
strategy:
fail-fast: true
needs: build-wabt
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
Expand All @@ -33,9 +114,26 @@ jobs:
- name: Prebuild files
run: npm run test:prebuild

- name: Download WAT tools
uses: actions/download-artifact@v4
with:
name: wabt-build-${{ github.run_id }}
path: .tools

- name: Verify tools
run: |
chmod u+x $GITHUB_WORKSPACE/.tools/*
$GITHUB_WORKSPACE/.tools/wasm-objdump --version

- name: Add .tools to PATH
run: echo "$GITHUB_WORKSPACE/.tools" >> $GITHUB_PATH

- name: Run c8 coverage
run: |
echo "LINE_COVERAGE=$(npm run coverage:test:ava | grep -E '^\s*Lines\s*:\s*[0-9]+(\.[0-9]+)?%' | awk '{print $3}' | tr -d '%')" >> $GITHUB_ENV
echo "LINE_COVERAGE=$(npm run coverage:test:ava | grep -E 'Lines\s*:\s*[0-9]+(\.[0-9]+)?%' | awk '{print $3}' | tr -d '%')" >> $GITHUB_ENV

- name: Report coverage
run: npx c8 report --all

- name: Update coverage badge
uses: schneegans/[email protected]
Expand Down
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "WABT"]
path = WABT
url = [email protected]:TOPLLab/wabt.git
[submodule "tests/unit/artifacts/wabt"]
path = tests/artifacts/wabt
url = [email protected]:TOPLLab/wabt.git
[submodule "tests/unit/artifacts/warduino"]
path = tests/artifacts/warduino
url = [email protected]:TOPLLab/WARDuino.git
129 changes: 66 additions & 63 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,71 @@
{
"name": "latch",
"description": "A testing language for constraint environments",
"version": "0.3.1",
"type": "commonjs",
"exports": {
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.cjs"
},
"main": "dist/cjs/index.cjs",
"types": "dist/types/index.d.ts",
"name": "latch",
"description": "A testing language for constraint environments",
"version": "0.3.1",
"type": "commonjs",
"exports": {
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.cjs"
},
"main": "dist/cjs/index.cjs",
"types": "dist/types/index.d.ts",
"files": [
"dist",
"bin"
],
"scripts": {
"clean": "rm -rf dist",
"build": "npm run build:cjs",
"build:cjs": "tsc --project tsconfig.build.json",
"build:tests": "tsc --outDir out --project tsconfig.tests.json",
"watch": "tsc -watch -p ./",
"lint": "eslint src/**/* --config .eslint.config.mjs",
"test:prebuild": "npm run build && npm run build:tests",
"test:all": "npm run test:prebuild && npm run test:ava",
"test:ava": "ava",
"test:example": "npx ts-node ./tests/examples/example.ts",
"coverage:test:ava": "c8 --src src/ --all ava"
},
"dependencies": {
"ansi-colors": "^4.1.3",
"ieee754": "^1.2.1",
"ora": "^8.0.1",
"source-map": "^0.7.4",
"ts-node": "^10.5.0",
"tslib": "^2.8.1"
},
"devDependencies": {
"@ava/typescript": "^5.0.0",
"@eslint/js": "^9.16.0",
"@stylistic/eslint-plugin-js": "^2.11.0",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.1.0",
"@types/node": "^20.10.4",
"@types/uuid": "^9.0.0",
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"ava": "^6.2.0",
"c8": "^10.1.2",
"convert-extension": "^0.3.0",
"eslint": "^9.16.0",
"globals": "^15.13.0",
"mqtt": "^4.3.7",
"serialport": "^10.4.0",
"typescript": "^5.2.0",
"typescript-eslint": "^8.17.0"
},
"ava": {
"files": [
"dist",
"bin"
"out/tests/unit/describers.test.js",
"out/tests/unit/messaging.test.js",
"out/tests/unit/sourcemap.test.js",
"out/tests/unit/util.test.js"
],
"scripts": {
"clean": "rm -rf dist",
"build": "npm run build:cjs",
"build:cjs": "tsc --project tsconfig.build.json",
"build:tests": "tsc --outDir out --project tsconfig.tests.json",
"watch": "tsc -watch -p ./",
"lint": "eslint src/**/* --config .eslint.config.mjs",
"test:prebuild": "npm run build && npm run build:tests",
"test:all": "npm run test:prebuild && npm run test:ava",
"test:ava": "ava",
"test:example": "npx ts-node ./tests/examples/example.ts",
"coverage:test:ava": "c8 --src src/ --all ava"
},
"dependencies": {
"ansi-colors": "^4.1.3",
"ieee754": "^1.2.1",
"ora": "^8.0.1",
"source-map": "^0.7.4",
"ts-node": "^10.5.0",
"tslib": "^2.8.1"
},
"devDependencies": {
"@ava/typescript": "^5.0.0",
"@eslint/js": "^9.16.0",
"@stylistic/eslint-plugin-js": "^2.11.0",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.1.0",
"@types/node": "^20.10.4",
"@types/uuid": "^9.0.0",
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"ava": "^6.2.0",
"c8": "^10.1.2",
"convert-extension": "^0.3.0",
"eslint": "^9.16.0",
"globals": "^15.13.0",
"mqtt": "^4.3.7",
"serialport": "^10.4.0",
"typescript": "^5.2.0",
"typescript-eslint": "^8.17.0"
},
"ava": {
"files": [
"out/tests/unit/util.test.js"
],
"typescript": {
"compile": false,
"rewritePaths": {
"src/": "dist/"
}
}
"typescript": {
"compile": false,
"rewritePaths": {
"src/": "dist/"
}
}
}
}
3 changes: 3 additions & 0 deletions src/messaging/MessageQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ export class MessageQueue implements Iterable<string> {
private readonly delimiter: string;
private queue: string[];

/**
* @param delimiter the EOM (end-of-message) token
*/
constructor(delimiter: string) {
this.delimiter = delimiter;
this.queue = [];
Expand Down
12 changes: 0 additions & 12 deletions src/reporter/Reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,7 @@ export class Reporter {
this.archiver.write();
}

info(text: string) {
this.output += `info: ${text}\n`;
}

error(text: string) {
this.output += `error: ${text}\n`;
}

suite(title: string) {
this.output += `suite: ${title}\n`;
}

test(title: string) {
this.output += ` test: ${title}\n`;
}
}
3 changes: 1 addition & 2 deletions src/reporter/describers/SuiteDescribers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ export class NormalSuiteDescriber extends ShortSuiteDescriber {
});

if (this.item.outcome === Outcome.error) {
report.push(' '.repeat(2) + red(this.item.clarification.toString()));
report.push(' '.repeat(2) + red(this.item.clarification));
}

return report;
}

}
2 changes: 1 addition & 1 deletion src/util/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export function retry<T>(promise: () => Promise<T>, retries: number): Promise<T>
trying = ++attempt < retries;
}
}
reject(`exhausted number of retries (${retries})`);
reject(new Error(`exhausted number of retries (${retries})`));
});
}
4 changes: 2 additions & 2 deletions src/util/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function getFileExtension(file: string): string {
const result = /(?:\.([^.]+))?$/.exec(file)
if (result === null || result.length < 1) {
throw Error('Could not determine file type');
if (result === null || result.length < 1 || result[1] === undefined) {
throw new Error('Could not determine file type');
}
return result[1];
}
Expand Down
Loading
Loading