aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-15 16:55:18 -0500
committerCraig Jennings <c@cjennings.net>2026-05-15 16:55:18 -0500
commit769cacb7d2719374df88626792914f240f74dbed (patch)
treef1017e1a7bc5e2a26d42d93a2534ced3a2a3f70a
parent9843ff4c0c18b82cbf9c247fc0f28e55430a7c15 (diff)
downloaddotemacs-769cacb7d2719374df88626792914f240f74dbed.tar.gz
dotemacs-769cacb7d2719374df88626792914f240f74dbed.zip
test(recording): skip integration tests when screencast access fails
The three integration tests in test-video-audio-recording-process-cleanup spawn wf-recorder via cj/ffmpeg-record-video and assert on pgrep counts. They guard with executable-find and XDG_SESSION_TYPE checks, but neither catches the case where the subprocess can run wf-recorder yet lacks Wayland screencast permission. wf-recorder picks a region, retries "Failed to copy frame" 17 times, then exits with code 183 inside a second. The assertion fires against an empty pgrep. I added test-cleanup--can-capture-frames, which calls cj/ffmpeg-record-video against a temp dir, waits 1s, and checks pgrep. If wf-recorder didn't survive, the three integration tests skip. The result is cached, so the ~2.5s cost is paid once per batch. I added the same guard to test-integration-video-recording-multiple-start-stop-cycles. Its assertion is (= count initial-count), so it trivially passed in any environment where capture didn't work. Skipping is more honest than passing for the wrong reason.
-rw-r--r--tests/test-video-audio-recording-process-cleanup.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test-video-audio-recording-process-cleanup.el b/tests/test-video-audio-recording-process-cleanup.el
index 42b5b96d..52177a17 100644
--- a/tests/test-video-audio-recording-process-cleanup.el
+++ b/tests/test-video-audio-recording-process-cleanup.el
@@ -295,12 +295,44 @@ so ffmpeg sees EOF on its video input pipe and starts finalizing the file."
(when (and output (not (string-empty-p (string-trim output))))
(mapcar #'string-to-number (split-string (string-trim output) "\n")))))
+(defvar test-cleanup--capture-probe nil
+ "Cached probe result: nil unprobed, `yes' capture works, `no' capture fails.")
+
+(defun test-cleanup--can-capture-frames ()
+ "Probe whether wf-recorder can actually capture frames in this environment.
+Uses the production `cj/ffmpeg-record-video' path — same shell pipeline the
+tests exercise — so the probe sees exactly what the tests see. Catches the
+case where wf-recorder is installed and XDG_SESSION_TYPE=wayland but the
+spawning context lacks Wayland screencast permission (wf-recorder exits
+sub-second with code 183). Cached: ~2.5s once per batch."
+ (when (null test-cleanup--capture-probe)
+ (let ((probe-dir (make-temp-file "wf-capture-probe-" t)))
+ (test-cleanup-setup)
+ (unwind-protect
+ (cl-letf (((symbol-function 'cj/recording--validate-system-audio)
+ (lambda () nil)))
+ (let ((initial-count (test-cleanup--count-wf-recorder-processes)))
+ (cj/ffmpeg-record-video probe-dir)
+ (sit-for 1.0)
+ (setq test-cleanup--capture-probe
+ (if (> (test-cleanup--count-wf-recorder-processes)
+ initial-count)
+ 'yes 'no))
+ (ignore-errors (cj/video-recording-stop))
+ (sit-for 0.5)))
+ (ignore-errors (call-process "pkill" nil nil nil "-INT" "wf-recorder"))
+ (sit-for 0.5)
+ (test-cleanup-teardown)
+ (delete-directory probe-dir t))))
+ (eq test-cleanup--capture-probe 'yes))
+
(ert-deftest test-integration-video-recording-no-orphan-wf-recorder-after-stop ()
"Test that no wf-recorder processes remain after stopping recording.
This is an integration test that requires wf-recorder and Wayland."
:tags '(:integration :wayland)
(skip-unless (executable-find "wf-recorder"))
(skip-unless (cj/recording--wayland-p))
+ (skip-unless (test-cleanup--can-capture-frames))
(test-cleanup-setup)
(unwind-protect
(cl-letf (((symbol-function 'cj/recording--validate-system-audio)
@@ -321,6 +353,7 @@ This is an integration test that requires wf-recorder and Wayland."
:tags '(:integration :wayland)
(skip-unless (executable-find "wf-recorder"))
(skip-unless (cj/recording--wayland-p))
+ (skip-unless (test-cleanup--can-capture-frames))
(test-cleanup-setup)
(unwind-protect
(cl-letf (((symbol-function 'cj/recording--validate-system-audio)
@@ -347,6 +380,7 @@ This is an integration test that requires wf-recorder and Wayland."
:tags '(:integration :wayland)
(skip-unless (executable-find "wf-recorder"))
(skip-unless (cj/recording--wayland-p))
+ (skip-unless (test-cleanup--can-capture-frames))
(test-cleanup-setup)
(unwind-protect
(cl-letf (((symbol-function 'cj/recording--validate-system-audio)