diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-03 21:32:09 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-03 21:32:09 -0500 |
| commit | 250db085bd2a2860636bb96c215dcbaa5efe91e9 (patch) | |
| tree | 2d93e27ccd66b6048a1c21c88b87c3e114c20305 /tests/test-dev-fkeys--projectile-capture-cmd.el | |
| parent | 2f8d8989856073cbed5f9159d02089903bc5343e (diff) | |
| download | dotemacs-250db085bd2a2860636bb96c215dcbaa5efe91e9.tar.gz dotemacs-250db085bd2a2860636bb96c215dcbaa5efe91e9.zip | |
test: re-point projectile revert tests at the decision helper
The legacy `cj/--projectile-revert-on-fail` wrapper and `cj/--projectile-revert-state` global were removed when the closure-based revert refactor landed (commit 2f8d898). The corresponding tests in `test-dev-fkeys--projectile-revert-on-fail.el` and the around-revert / capture-cmd files still referenced the legacy symbols, so 7 tests had been failing on `main` since that commit.
I re-pointed each test at `cj/--projectile-revert-state-on-fail`, the pure decision helper that the closure-based hook delegates to. Each test now passes the captured `state` plist as an explicit argument instead of binding the old global. Test names updated to match the new target.
I dropped two tests that no longer have a target. `revert-on-fail-clears-state` was specific to the wrapper clearing the global on completion, and there is no global to clear now. `revert-on-fail-removes-itself` was specific to the wrapper removing itself from `compilation-finish-functions`. The closure-based hook removes itself differently and is covered by the buffer-local hook tests in `test-dev-fkeys--projectile-around-revert.el`.
The around-revert and capture-cmd tests also lost their `cj/--projectile-revert-state nil` let-bindings since that variable no longer exists.
21 projectile-related tests pass together.
Diffstat (limited to 'tests/test-dev-fkeys--projectile-capture-cmd.el')
| -rw-r--r-- | tests/test-dev-fkeys--projectile-capture-cmd.el | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/tests/test-dev-fkeys--projectile-capture-cmd.el b/tests/test-dev-fkeys--projectile-capture-cmd.el index bc4c7684..85d4603f 100644 --- a/tests/test-dev-fkeys--projectile-capture-cmd.el +++ b/tests/test-dev-fkeys--projectile-capture-cmd.el @@ -23,8 +23,7 @@ (ert-deftest test-dev-fkeys-projectile-capture-cmd-stores-prior-value () "Normal: captures the cached cmd at the project root into the state plist." - (let* ((cj/--projectile-revert-state nil) - (projectile-compile-cmd-map (make-hash-table :test 'equal)) + (let* ((projectile-compile-cmd-map (make-hash-table :test 'equal)) state) (puthash "/p/" "make build" projectile-compile-cmd-map) (cl-letf (((symbol-function 'cj/--f4-project-root) (lambda () "/p/"))) @@ -32,43 +31,37 @@ (should (equal (plist-get state :map) 'projectile-compile-cmd-map)) (should (equal (plist-get state :root) "/p/")) - (should (equal (plist-get state :prior) "make build")) - (should (null cj/--projectile-revert-state)))) + (should (equal (plist-get state :prior) "make build")))) (ert-deftest test-dev-fkeys-projectile-capture-cmd-no-prior-stores-nil () "Normal: when no cmd is cached, captures :prior nil — distinct from \"didn't capture at all\" because :map and :root are still set." - (let* ((cj/--projectile-revert-state nil) - (projectile-test-cmd-map (make-hash-table :test 'equal)) + (let* ((projectile-test-cmd-map (make-hash-table :test 'equal)) state) (cl-letf (((symbol-function 'cj/--f4-project-root) (lambda () "/p/"))) (setq state (cj/--projectile-capture-cmd 'projectile-test-cmd-map))) (should (eq (plist-get state :map) 'projectile-test-cmd-map)) - (should (null (plist-get state :prior))) - (should (null cj/--projectile-revert-state)))) + (should (null (plist-get state :prior))))) ;;; Boundary Cases (ert-deftest test-dev-fkeys-projectile-capture-cmd-nil-root-leaves-state-nil () "Boundary: when no project root resolves, state stays nil so the finish hook treats it as a no-op." - (let ((cj/--projectile-revert-state nil) - (projectile-compile-cmd-map (make-hash-table :test 'equal))) + (let ((projectile-compile-cmd-map (make-hash-table :test 'equal))) (cl-letf (((symbol-function 'cj/--f4-project-root) (lambda () nil))) - (cj/--projectile-capture-cmd 'projectile-compile-cmd-map)) - (should (null cj/--projectile-revert-state)))) + (should-not (cj/--projectile-capture-cmd 'projectile-compile-cmd-map))))) ;;; Error Cases (ert-deftest test-dev-fkeys-projectile-capture-cmd-unbound-map-leaves-state-nil () "Error: when the cmd-map symbol is unbound (projectile not loaded), state stays nil and no error is raised." - (let ((cj/--projectile-revert-state nil)) - (cl-letf (((symbol-function 'cj/--f4-project-root) (lambda () "/p/"))) - ;; Use a clearly-unbound symbol to simulate projectile-not-loaded. - (cj/--projectile-capture-cmd 'cj-test--definitely-not-bound-xyzzy)) - (should (null cj/--projectile-revert-state)))) + (cl-letf (((symbol-function 'cj/--f4-project-root) (lambda () "/p/"))) + ;; Use a clearly-unbound symbol to simulate projectile-not-loaded. + (should-not + (cj/--projectile-capture-cmd 'cj-test--definitely-not-bound-xyzzy)))) (provide 'test-dev-fkeys--projectile-capture-cmd) ;;; test-dev-fkeys--projectile-capture-cmd.el ends here |
