aboutsummaryrefslogtreecommitdiff
path: root/docker/scripts/run-unit-tests.sh
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-10-18 21:10:37 +0200
committercirakg <cirakg@cirakg.xyz>2026-10-18 21:10:37 +0200
commit85f1ecabd7f58f306b2a042376209ac8cf49ab9b (patch)
tree00a0f3e2717e5c20ce0c427a979ef609a400d326 /docker/scripts/run-unit-tests.sh
parent2071e2beda763137416ac386d4bb953711ec995d (diff)
build: complete the Docker pipeline for build, test, screenshots and packaging
- Container scripts now run from the mounted project (no image rebuild per script change): build-app.sh (strict -l 3, warnings fail), run-unit-tests.sh, screenshots.sh, app-diag.sh (perf/memory), lint.sh, package.sh and sim-vnc.sh (noVNC on 127.0.0.1:6080). - Headless simulator helpers: wait for port 1234, remove the stale single-instance lock (~/Sim-dev) that made later starts hang, show the simulator log on failure. - New targets: screenshots-approve, icons; `make lock` re-adds the requirements header; pytest treats warnings as errors. - Author/Summary headers on every build file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docker/scripts/run-unit-tests.sh')
-rwxr-xr-xdocker/scripts/run-unit-tests.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/docker/scripts/run-unit-tests.sh b/docker/scripts/run-unit-tests.sh
new file mode 100755
index 0000000..60a8955
--- /dev/null
+++ b/docker/scripts/run-unit-tests.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+# Author: cirakg & claude ai
+# Summary: Build and run the Monkey C unit tests on each test device in the headless simulator.
+#
+# Usage: run-unit-tests.sh DEVICE [DEVICE ...]
+# Output: build/test/results/<DEVICE>.log (console) and <DEVICE>.xml (JUnit).
+#
+# Every test build is compiled first, so a compile error stops the run before
+# the simulator starts. One simulator then runs every device in turn.
+# monkeydo exits with 1 even when all tests pass, so the verdict comes from
+# tools/ciq_test_report.py; the script fails if any device fails.
+set -euo pipefail
+# shellcheck source=ciq-env.sh
+source "$(dirname "${BASH_SOURCE[0]}")/ciq-env.sh"
+
+# Longest a single device's test run may take before it counts as hung.
+readonly TEST_TIMEOUT_S=600
+
+(($# > 0)) || die "usage: run-unit-tests.sh DEVICE [DEVICE ...]"
+ciq_require_sdk
+ciq_require_key
+
+for device in "$@"; do
+ build-app.sh test "${device}"
+done
+
+ciq_start_display
+ciq_start_simulator
+
+results="${BUILD_DIR}/test/results"
+mkdir -p "${results}"
+failed=0
+for device in "$@"; do
+ log "running unit tests on ${device}"
+ # monkeydo's exit status is ignored on purpose (see above); a timeout leaves
+ # an incomplete log, which the report then rejects.
+ timeout "${TEST_TIMEOUT_S}" monkeydo "${BUILD_DIR}/test/${device}.prg" "${device}" -t \
+ >"${results}/${device}.log" 2>&1 || true
+ python3 /work/tools/ciq_test_report.py "${results}/${device}.log" \
+ --device "${device}" --junit "${results}/${device}.xml" || failed=1
+done
+
+if ((failed)); then
+ die "unit tests failed; console logs are in build/test/results/"
+fi
+log "unit tests passed on: $*"