diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-25 22:10:18 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-25 22:10:18 -0500 |
| commit | c9ff295f02c355f889d1605853c148bbce404d52 (patch) | |
| tree | a1702eb32d958f6e53efe9dbe58c0e678c7e22f9 /tests/test-pearl-save.el | |
| parent | 33c5da1bc33b59f2969f176f434ca66050deab23 (diff) | |
| download | pearl-c9ff295f02c355f889d1605853c148bbce404d52.tar.gz pearl-c9ff295f02c355f889d1605853c148bbce404d52.zip | |
fix(save): extend the killed-buffer guard to the text-field savers
The atomic savers got this guard last commit, and the free-text savers share the same async exposure. pearl--save-field-push advances the provenance hash and runs the :after-push thunk through the marker after the push returns, and the description saver's outcome callback resyncs the Org hash the same way -- both signal if the buffer was killed in between. Both now check pearl--marker-live-p and skip the buffer touch while still reporting the remote outcome. I moved pearl--marker-live-p above the first caller so it's defined before all three use sites (no forward reference).
Diffstat (limited to 'tests/test-pearl-save.el')
| -rw-r--r-- | tests/test-pearl-save.el | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test-pearl-save.el b/tests/test-pearl-save.el index 8050e6d..1f4f273 100644 --- a/tests/test-pearl-save.el +++ b/tests/test-pearl-save.el @@ -288,6 +288,32 @@ the conflict choice (stubbed). Returns (:outcome :fetched :pushed :applied (should (equal '("remote changed") (plist-get r :applied))) (should (string= (secure-hash 'sha256 "remote changed") (plist-get r :hash))))) +(ert-deftest test-pearl-save-field-push-killed-buffer-no-signal () + "A text-field push whose buffer is killed before the success callback does not signal. +The hash-advance and :after-push touch the marker; on a dead buffer they must be +skipped, with the remote push still reported as pushed." + (let ((buf (generate-new-buffer "pearl-field-push-kill")) outcome after-ran) + (unwind-protect + (let (marker) + (with-current-buffer buf + (insert "* h\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\n") + (org-mode) + (goto-char (point-min)) + (setq marker (point-marker))) + (pearl--save-field-push + (list :issue-id "u" :identifier "ENG-1" :field 'title :marker marker + :prop "LINEAR-TITLE-SHA256" :label "ENG-1 title" + ;; the push kills the buffer, then reports success + :push (lambda (_text cb) (kill-buffer buf) (funcall cb '(:success t))) + ;; touching the dead marker would signal without the guard + :after-push (lambda (_r m) (setq after-ran t) (org-entry-put m "X" "y"))) + "new text" + (lambda (o) (setq outcome o))) + (should-not (buffer-live-p buf)) + (should (eq 'pushed (plist-get outcome :status))) + (should-not after-ran)) + (when (buffer-live-p buf) (kill-buffer buf))))) + ;;; --run-atomic-field-save (the per-field engine for enum/relation fields) (cl-defun test-pearl-save--atomic (&key live baseline remote (push-success t) resolution) |
