aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 04:08:19 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 04:08:19 -0500
commit556f48a2a0518253015496a618eec9e7a7142dcc (patch)
treec24de779d0f780448f1921dcf566a60d32a3e56d /tests
parent39795e850f2027a88021307a37de0381996df8a5 (diff)
downloaddotemacs-556f48a2a0518253015496a618eec9e7a7142dcc.tar.gz
dotemacs-556f48a2a0518253015496a618eec9e7a7142dcc.zip
fix(recording): scope wf-recorder stop signal to our own process
Stopping a Wayland recording ran pkill -INT wf-recorder, which signals every wf-recorder on the system — including an unrelated screen capture the user started outside Emacs. The stop path now scopes the producer-first interrupt to the wf-recorder child of our own recording shell via pkill -P <shell-pid>, in the new cj/recording--interrupt-child-wf-recorder helper. The producer-first ordering is unchanged: wf-recorder still gets SIGINT before the process-group signal so ffmpeg sees a clean EOF on pipe:0 and finalizes the MKV. The orphan-cleanup at recording start stays a broad by-name kill on purpose — those leftover recorders come from crashed sessions whose shells are already dead, so there is no live PID to scope to. Tests cover the scoped call, the nil-PID no-op, and that the bare system-wide form is never used.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-video-audio-recording--interrupt-child-wf-recorder.el56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test-video-audio-recording--interrupt-child-wf-recorder.el b/tests/test-video-audio-recording--interrupt-child-wf-recorder.el
new file mode 100644
index 00000000..6e4cda1c
--- /dev/null
+++ b/tests/test-video-audio-recording--interrupt-child-wf-recorder.el
@@ -0,0 +1,56 @@
+;;; test-video-audio-recording--interrupt-child-wf-recorder.el --- Tests for scoped wf-recorder interrupt -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Unit tests for cj/recording--interrupt-child-wf-recorder.
+;; Verifies the producer-first stop signal targets only the wf-recorder
+;; child of this module's own shell process, not every wf-recorder on the
+;; system.
+
+;;; Code:
+
+(require 'ert)
+
+;; Stub dependencies before loading the module
+(defvar cj/custom-keymap (make-sparse-keymap)
+ "Stub keymap for testing.")
+
+(require 'video-audio-recording)
+
+;;; Normal Cases
+
+(ert-deftest test-video-audio-recording--interrupt-child-wf-recorder-normal-scopes-to-parent-pid ()
+ "Normal: interrupt is scoped to the wf-recorder child of the given PID."
+ (let ((captured nil))
+ (cl-letf (((symbol-function 'call-process)
+ (lambda (&rest args) (setq captured args) 0)))
+ (cj/recording--interrupt-child-wf-recorder 12345)
+ ;; Targets wf-recorder, by parent PID, with SIGINT — not a bare
+ ;; system-wide name match.
+ (should (member "-INT" captured))
+ (should (member "-P" captured))
+ (should (member "12345" captured))
+ (should (member "wf-recorder" captured)))))
+
+;;; Boundary Cases
+
+(ert-deftest test-video-audio-recording--interrupt-child-wf-recorder-boundary-nil-pid-no-call ()
+ "Boundary: a nil PID issues no kill at all (nothing to scope to)."
+ (let ((called nil))
+ (cl-letf (((symbol-function 'call-process)
+ (lambda (&rest _) (setq called t) 0)))
+ (cj/recording--interrupt-child-wf-recorder nil)
+ (should-not called))))
+
+;;; Error Cases
+
+(ert-deftest test-video-audio-recording--interrupt-child-wf-recorder-error-never-bare-name ()
+ "Error: must never call pkill with only the program name (system-wide kill)."
+ (let ((captured nil))
+ (cl-letf (((symbol-function 'call-process)
+ (lambda (&rest args) (setq captured args) 0)))
+ (cj/recording--interrupt-child-wf-recorder 999)
+ ;; The whole point of the fix: a parent-scoping flag is always present.
+ (should (member "-P" captured)))))
+
+(provide 'test-video-audio-recording--interrupt-child-wf-recorder)
+;;; test-video-audio-recording--interrupt-child-wf-recorder.el ends here