diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-12 00:09:15 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-12 00:09:15 -0500 |
| commit | cd0b90dc74996f7bd7b897834bac7038ffb7f5b8 (patch) | |
| tree | 8c072614cd477676a98cef2730e62dae84aac586 | |
| parent | 94ee5e4fac213de915a27906e4e0861e86de8914 (diff) | |
| download | dotemacs-cd0b90dc74996f7bd7b897834bac7038ffb7f5b8.tar.gz dotemacs-cd0b90dc74996f7bd7b897834bac7038ffb7f5b8.zip | |
build: add make benchmark target and skip :perf tests by default
`make test', `make coverage', and the editor's PostToolUse test runner all selected `(not (tag :slow))', which let the now-`:perf'-tagged benchmark suite run alongside the unit tests. Each of those three filters now also excludes `:perf', and a new `make benchmark' target runs the benchmark file on its own. `make test-file' and `make test-name' keep their old filters so the suite stays reachable for ad-hoc runs.
`COVERAGE_EXCLUDE' loses `test-lorem-optimum-benchmark.el'. The tag filter handles it now, so the only entry left is `test-all-comp-errors.el', which byte-compiles modules and can't run under undercover's instrumentation.
| -rwxr-xr-x | .claude/hooks/validate-el.sh | 2 | ||||
| -rw-r--r-- | Makefile | 31 |
2 files changed, 22 insertions, 11 deletions
diff --git a/.claude/hooks/validate-el.sh b/.claude/hooks/validate-el.sh index dfb7ac7e..334578ae 100755 --- a/.claude/hooks/validate-el.sh +++ b/.claude/hooks/validate-el.sh @@ -98,7 +98,7 @@ if [ "$count" -ge 1 ] && [ "$count" -le "$MAX_AUTO_TEST_FILES" ]; then -L "$PROJECT_ROOT/tests" \ --eval '(package-initialize)' \ -l ert "${load_args[@]}" \ - --eval "(ert-run-tests-batch-and-exit '(not (tag :slow)))" 2>&1)"; then + --eval "(ert-run-tests-batch-and-exit '(not (or (tag :slow) (tag :perf))))" 2>&1)"; then fail_json "TESTS FAILED ($count test file(s))" "$f" "$output" fi fi @@ -6,6 +6,7 @@ # make test-unit - Run unit tests only # make test-file FILE=test-foo.el - Run specific test file # make test-name TEST=test-foo-* - Run tests matching pattern +# make benchmark - Run performance benchmarks (:perf-tagged tests) # make coverage - Generate simplecov coverage report # make coverage-clean - Remove coverage report file # make validate-parens - Check for unbalanced parentheses @@ -41,7 +42,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 \ - coverage coverage-clean \ + benchmark coverage coverage-clean \ validate-parens validate-modules compile lint profile \ clean clean-compiled clean-tests reset @@ -60,6 +61,7 @@ help: @echo " make test-integration - Run integration tests only ($(words $(INTEGRATION_TESTS)) files)" @echo " make test-file FILE=<filename> - Run specific test file" @echo " make test-name TEST=<pattern> - Run tests matching pattern" + @echo " make benchmark - Run performance benchmarks (:perf-tagged)" @echo "" @echo " Coverage:" @echo " make coverage - Generate simplecov JSON at $(COVERAGE_FILE)" @@ -105,7 +107,7 @@ test-unit: for test in $(UNIT_TESTS); do \ test_name=$$(basename $$test); \ printf " Testing %-60s " "$$test_name..."; \ - output=$$($(EMACS_TEST) -l ert -l $$test --eval "(ert-run-tests-batch-and-exit '(not (tag :slow)))" 2>&1); \ + output=$$($(EMACS_TEST) -l ert -l $$test --eval "(ert-run-tests-batch-and-exit '(not (or (tag :slow) (tag :perf))))" 2>&1); \ result=$$?; \ if [ $$result -eq 0 ]; then \ pass_count=$$(echo "$$output" | grep -oP "Ran \K\d+" | head -1); \ @@ -157,7 +159,7 @@ test-integration: for test in $(INTEGRATION_TESTS); do \ test_name=$$(basename $$test); \ printf " Testing %-60s " "$$test_name..."; \ - output=$$($(EMACS_TEST) -l ert -l $$test --eval "(ert-run-tests-batch-and-exit '(not (tag :slow)))" 2>&1); \ + output=$$($(EMACS_TEST) -l ert -l $$test --eval "(ert-run-tests-batch-and-exit '(not (or (tag :slow) (tag :perf))))" 2>&1); \ result=$$?; \ if [ $$result -eq 0 ]; then \ pass_count=$$(echo "$$output" | grep -oP "Ran \K\d+" | head -1); \ @@ -220,6 +222,17 @@ endif --eval '(ert-run-tests-batch-and-exit "$(TEST)")' @echo "✓ Tests matching '$(TEST)' complete" +# Performance benchmarks for lorem-optimum's Markov chain. These are tagged +# `:perf' so `make test', `make coverage', and the editor test hook skip them; +# this target is the way to run them on purpose. +BENCHMARK_TESTS = $(TEST_DIR)/test-lorem-optimum-benchmark.el + +benchmark: + @echo "[i] Running performance benchmarks..." + @$(EMACS_TEST) -l ert $(foreach test,$(BENCHMARK_TESTS),-l $(test)) \ + --eval "(ert-run-tests-batch-and-exit '(tag :perf))" + @echo "✓ Benchmarks complete" + # ============================================================================ # Coverage Targets # ============================================================================ @@ -227,13 +240,11 @@ endif COVERAGE_DIR = .coverage COVERAGE_FILE = $(COVERAGE_DIR)/simplecov.json -# Test files that can't coexist with undercover's instrumentation -# (test-all-comp-errors byte-compiles modules, which fails on instrumented -# sources; test-lorem-optimum-benchmark's wall-clock assertions fail when -# instrumentation slows execution). Excluded from `make coverage' only. +# test-all-comp-errors byte-compiles every module, which fails on sources +# undercover has instrumented, so it can't run under `make coverage'. (The +# :perf-tagged benchmarks are skipped by the tag filter above, not listed here.) COVERAGE_EXCLUDE = \ - $(TEST_DIR)/test-all-comp-errors.el \ - $(TEST_DIR)/test-lorem-optimum-benchmark.el + $(TEST_DIR)/test-all-comp-errors.el COVERAGE_TESTS = $(filter-out $(COVERAGE_EXCLUDE),$(UNIT_TESTS)) coverage: coverage-clean $(COVERAGE_DIR) @@ -248,7 +259,7 @@ coverage: coverage-clean $(COVERAGE_DIR) for test in $(COVERAGE_TESTS); do \ test_name=$$(basename $$test); \ printf " Coverage: %-58s " "$$test_name..."; \ - output=$$($(EMACS_TEST) -l $(TEST_DIR)/run-coverage-file.el -l $$test --eval "(ert-run-tests-batch-and-exit '(not (tag :slow)))" 2>&1); \ + output=$$($(EMACS_TEST) -l $(TEST_DIR)/run-coverage-file.el -l $$test --eval "(ert-run-tests-batch-and-exit '(not (or (tag :slow) (tag :perf))))" 2>&1); \ result=$$?; \ if [ $$result -eq 0 ]; then \ echo "✓"; \ |
