diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-12 00:56:27 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-12 00:56:27 -0500 |
| commit | 839bbeb14a92a777a3857102dba08a212b21443d (patch) | |
| tree | 67cadf65b818b17d8421e4063a06d51895e4584b /Makefile | |
| parent | 18ba99fda928769adb235bd85b485c8be94c3ddd (diff) | |
| download | dotemacs-839bbeb14a92a777a3857102dba08a212b21443d.tar.gz dotemacs-839bbeb14a92a777a3857102dba08a212b21443d.zip | |
test(scripts): add bats coverage for setup-email.sh password helpers
`setup-email.sh' ran top to bottom, so the only way to exercise `install_encrypted_password' / `decrypt_password' was to run the whole new-machine setup (mbsync, mu init). Its procedural body now lives in a `main()' function guarded by the usual `[[ "${BASH_SOURCE[0]}" == "${0}" ]]' check, so sourcing the script just defines the helpers, and running it directly is unchanged.
New `tests/test-setup-email.bats' sources the script, points the password dirs at a per-test tmpdir, and covers both helpers across the normal / skip-existing / missing-source / (for decrypt) gpg-failure paths, stubbing `gpg' so no real key is needed. `make test-bash' runs the bats files, and `make test' picks them up after the Elisp suite when bats is installed.
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -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 test-bash - Run the bats shell-script tests # make benchmark - Run performance benchmarks (:perf-tagged tests) # make coverage - Generate simplecov coverage report # make coverage-clean - Remove coverage report file @@ -31,6 +32,7 @@ EMACS_HOME = $(HOME)/.emacs.d UNIT_TESTS = $(filter-out $(TEST_DIR)/test-integration-%.el, $(wildcard $(TEST_DIR)/test-*.el)) INTEGRATION_TESTS = $(wildcard $(TEST_DIR)/test-integration-%.el) ALL_TESTS = $(UNIT_TESTS) $(INTEGRATION_TESTS) +BASH_TESTS = $(wildcard $(TEST_DIR)/*.bats) # Module files MODULE_FILES = $(wildcard $(MODULE_DIR)/*.el) @@ -42,7 +44,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 \ - benchmark coverage coverage-clean \ + test-bash benchmark coverage coverage-clean \ validate-parens validate-modules compile lint profile \ clean clean-compiled clean-tests reset @@ -61,6 +63,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 test-bash - Run the bats shell-script tests ($(words $(BASH_TESTS)) files)" @echo " make benchmark - Run performance benchmarks (:perf-tagged)" @echo "" @echo " Coverage:" @@ -92,13 +95,28 @@ help: test: test-all test-all: - @echo "[i] Running all tests ($(words $(ALL_TESTS)) files)..." + @echo "[i] Running all tests ($(words $(ALL_TESTS)) Elisp files)..." @$(MAKE) test-unit @if [ $(words $(INTEGRATION_TESTS)) -gt 0 ]; then \ $(MAKE) test-integration; \ fi + @if [ $(words $(BASH_TESTS)) -gt 0 ] && command -v bats >/dev/null 2>&1; then \ + $(MAKE) test-bash; \ + fi @echo "✓ All tests complete" +test-bash: + @if [ $(words $(BASH_TESTS)) -eq 0 ]; then \ + echo "No bats tests found"; \ + exit 0; \ + fi + @if ! command -v bats >/dev/null 2>&1; then \ + echo "[!] bats not installed — skipping shell-script tests"; \ + exit 0; \ + fi + @echo "[i] Running bats shell-script tests ($(words $(BASH_TESTS)) files)..." + @bats $(BASH_TESTS) + test-unit: @echo "[i] Running unit tests ($(words $(UNIT_TESTS)) files)..." @echo "" |
