aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--scripts/theme-studio/Makefile61
-rwxr-xr-xscripts/theme-studio/run-tests.sh8
3 files changed, 74 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index a1f403e8..85da255d 100644
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ EMACS_TEST = $(EMACS_BATCH) -L $(TEST_DIR) -L $(MODULE_DIR)
# No colors - using plain text symbols instead
.PHONY: help targets test test-all test-unit test-integration test-file test-name \
- test-bash theme-studio-test benchmark coverage coverage-summary coverage-clean \
+ test-bash theme-studio-test theme-studio-coverage benchmark coverage coverage-summary coverage-clean \
validate-parens validate-modules compile compile-file lint profile \
clean clean-compiled clean-tests reset
@@ -67,6 +67,7 @@ help:
@echo " make test-name TEST=<pattern> - Run tests matching pattern"
@echo " make test-bash - Run the bats shell-script tests ($(words $(BASH_TESTS)) files)"
@echo " make theme-studio-test - Run the theme-studio tool tests (Python + Node + browser)"
+ @echo " make theme-studio-coverage - Coverage for the theme-studio JS + generate.py"
@echo " make benchmark - Run performance benchmarks (:perf-tagged)"
@echo ""
@echo " Coverage:"
@@ -123,7 +124,10 @@ test-bash:
@bats $(BASH_TESTS)
theme-studio-test:
- @scripts/theme-studio/run-tests.sh
+ @$(MAKE) -C scripts/theme-studio test
+
+theme-studio-coverage:
+ @$(MAKE) -C scripts/theme-studio coverage
BANNER = ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
diff --git a/scripts/theme-studio/Makefile b/scripts/theme-studio/Makefile
new file mode 100644
index 00000000..a7455b3d
--- /dev/null
+++ b/scripts/theme-studio/Makefile
@@ -0,0 +1,61 @@
+# Makefile for the theme-studio tool — a self-contained Python + JS subproject.
+# Its toolchain (python3, node, uvx, headless Chrome) is independent of the repo
+# root's Elisp/ERT world, so the build logic lives here with the code. The root
+# Makefile delegates: `make theme-studio-test` and `make theme-studio-coverage`
+# call `make -C scripts/theme-studio ...`.
+#
+# Recipes run in this directory, so the relative paths below resolve whether you
+# `cd` here or invoke via the root's `-C` delegation.
+
+# Absolute path to this directory (for `open`, which hands Chrome a file path).
+HERE := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
+
+# Optional palette seed for `gen` / `open`: make gen SEED=dupre.json
+SEED ?=
+
+.PHONY: help test check coverage gen open
+
+.DEFAULT_GOAL := help
+
+help:
+ @echo "theme-studio targets:"
+ @echo " make test - Full suite: Python + Node + browser hash gates"
+ @echo " make check - Fast gate: regenerate + Python + Node (no browser)"
+ @echo " make coverage - JS (node) + generate.py (uvx coverage) numbers"
+ @echo " make gen [SEED=x.json] - Regenerate theme-studio.html (optionally from a seed)"
+ @echo " make open [SEED=x.json] - Regenerate and open the page in Chrome"
+
+test:
+ @./run-tests.sh
+
+check:
+ @./run-tests.sh --no-browser
+
+coverage:
+ @echo "== JS coverage (node --experimental-test-coverage) =="
+ @node --test --experimental-test-coverage ./*.mjs 2>/dev/null \
+ | sed -n '/start of coverage report/,/end of coverage report/p'
+ @echo ""
+ @echo "== generate.py coverage =="
+ @if command -v uvx >/dev/null 2>&1; then \
+ uvx coverage run --include='generate.py' -m unittest test_generate >/dev/null 2>&1; \
+ uvx coverage report -m; \
+ uvx coverage erase >/dev/null 2>&1; \
+ else \
+ echo "uvx not found — skipping generate.py line coverage"; \
+ echo "($$(grep -c 'def test_' test_generate.py) test_generate.py tests exist)"; \
+ fi
+
+gen:
+ @THEME_STUDIO_SEED="$(SEED)" python3 generate.py
+
+open: gen
+ @c=""; for b in google-chrome-stable google-chrome chromium chromium-browser; do \
+ command -v $$b >/dev/null 2>&1 && { c=$$b; break; }; \
+ done; \
+ if [ -n "$$c" ]; then \
+ "$$c" "$(HERE)theme-studio.html" >/dev/null 2>&1 & \
+ echo "opened theme-studio.html in $$c"; \
+ else \
+ echo "no Chromium-family browser found"; exit 1; \
+ fi
diff --git a/scripts/theme-studio/run-tests.sh b/scripts/theme-studio/run-tests.sh
index d57f0044..42d24960 100755
--- a/scripts/theme-studio/run-tests.sh
+++ b/scripts/theme-studio/run-tests.sh
@@ -16,6 +16,10 @@ set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$HERE"
+# --no-browser skips the headless-Chrome hash gates for a fast inner loop.
+NO_BROWSER=0
+[ "${1:-}" = "--no-browser" ] && NO_BROWSER=1
+
fail=0
pass_msg() { printf ' PASS %s\n' "$1"; }
fail_msg() { printf ' FAIL %s\n' "$1"; fail=1; }
@@ -50,7 +54,9 @@ for c in google-chrome-stable google-chrome chromium chromium-browser; do
if command -v "$c" >/dev/null 2>&1; then CHROME="$c"; break; fi
done
HASHES="selftest cursortest readouttest deltatest oklchtest planetest locktest sorttest"
-if [ -z "$CHROME" ]; then
+if [ "$NO_BROWSER" = 1 ]; then
+ skip_msg "browser hash gates (--no-browser)"
+elif [ -z "$CHROME" ]; then
for t in $HASHES; do skip_msg "#$t (no Chromium-family browser found)"; done
else
PROF="$(mktemp -d)"