diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-01 21:49:38 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-01 21:49:38 -0400 |
| commit | e281d88b16fa9c0b8faf5243dfc21481ac3cba9d (patch) | |
| tree | 0838bb92b13b926920dc2b30d7eb15fec3493845 | |
| parent | 75198a74bfd9c50b29b13b2d9a3205504a13c4ef (diff) | |
| download | dotemacs-e281d88b16fa9c0b8faf5243dfc21481ac3cba9d.tar.gz dotemacs-e281d88b16fa9c0b8faf5243dfc21481ac3cba9d.zip | |
test(recording): record integration captures into a temp dir
The wf-recorder integration tests passed video-recordings-dir to the real capture pipeline, and the test file's defvar stub of that variable is clobbered by user-constants' defconst on load — so every suite run left ~0.5s screen captures in the real recordings directory. Pass an explicit make-temp-file dir and delete it in the unwind, matching what the capture probe already did.
| -rw-r--r-- | tests/test-video-audio-recording-process-cleanup.el | 90 |
1 files changed, 48 insertions, 42 deletions
diff --git a/tests/test-video-audio-recording-process-cleanup.el b/tests/test-video-audio-recording-process-cleanup.el index 7cb261c1..8fa0f106 100644 --- a/tests/test-video-audio-recording-process-cleanup.el +++ b/tests/test-video-audio-recording-process-cleanup.el @@ -334,18 +334,20 @@ This is an integration test that requires wf-recorder and Wayland." (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) - (lambda () nil))) - (let ((initial-count (test-cleanup--count-wf-recorder-processes))) - (cj/ffmpeg-record-video video-recordings-dir) - (sit-for 1.0) - (should (> (test-cleanup--count-wf-recorder-processes) initial-count)) - (cj/video-recording-stop) - (sit-for 1.0) - (should (= (test-cleanup--count-wf-recorder-processes) initial-count)))) - (test-cleanup-teardown) - (ignore-errors (call-process "pkill" nil nil nil "-INT" "wf-recorder")))) + (let ((rec-dir (make-temp-file "recording-cleanup-test-" t))) + (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 rec-dir) + (sit-for 1.0) + (should (> (test-cleanup--count-wf-recorder-processes) initial-count)) + (cj/video-recording-stop) + (sit-for 1.0) + (should (= (test-cleanup--count-wf-recorder-processes) initial-count)))) + (test-cleanup-teardown) + (ignore-errors (call-process "pkill" nil nil nil "-INT" "wf-recorder")) + (delete-directory rec-dir t)))) (ert-deftest test-integration-video-recording-start-cleans-orphans () "Test that starting a recording cleans up any orphan wf-recorder processes. @@ -355,24 +357,26 @@ This is an integration test that requires wf-recorder and Wayland." (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) - (lambda () nil))) - ;; Create an orphan wf-recorder (simulating a crash) - (start-process "orphan-wf" nil "wf-recorder" "-c" "libx264" "-m" "matroska" "-f" "/dev/null") - (sit-for 0.5) - (let ((orphan-pids (test-cleanup--get-wf-recorder-pids))) - (should orphan-pids) - (cj/ffmpeg-record-video video-recordings-dir) - (sit-for 1.0) - (let ((current-pids (test-cleanup--get-wf-recorder-pids))) - (dolist (orphan-pid orphan-pids) - (let ((still-running (member orphan-pid current-pids))) - (should-not still-running)))) - (cj/video-recording-stop) - (sit-for 0.5))) - (test-cleanup-teardown) - (ignore-errors (call-process "pkill" nil nil nil "-INT" "wf-recorder")))) + (let ((rec-dir (make-temp-file "recording-cleanup-test-" t))) + (unwind-protect + (cl-letf (((symbol-function 'cj/recording--validate-system-audio) + (lambda () nil))) + ;; Create an orphan wf-recorder (simulating a crash) + (start-process "orphan-wf" nil "wf-recorder" "-c" "libx264" "-m" "matroska" "-f" "/dev/null") + (sit-for 0.5) + (let ((orphan-pids (test-cleanup--get-wf-recorder-pids))) + (should orphan-pids) + (cj/ffmpeg-record-video rec-dir) + (sit-for 1.0) + (let ((current-pids (test-cleanup--get-wf-recorder-pids))) + (dolist (orphan-pid orphan-pids) + (let ((still-running (member orphan-pid current-pids))) + (should-not still-running)))) + (cj/video-recording-stop) + (sit-for 0.5))) + (test-cleanup-teardown) + (ignore-errors (call-process "pkill" nil nil nil "-INT" "wf-recorder")) + (delete-directory rec-dir t)))) (ert-deftest test-integration-video-recording-multiple-start-stop-cycles () "Test that multiple recording cycles don't accumulate orphan processes. @@ -382,18 +386,20 @@ This is an integration test that requires wf-recorder and Wayland." (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) - (lambda () nil))) - (let ((initial-count (test-cleanup--count-wf-recorder-processes))) - (dotimes (_ 3) - (cj/ffmpeg-record-video video-recordings-dir) - (sit-for 0.5) - (cj/video-recording-stop) - (sit-for 0.5)) - (should (= (test-cleanup--count-wf-recorder-processes) initial-count)))) - (test-cleanup-teardown) - (ignore-errors (call-process "pkill" nil nil nil "-INT" "wf-recorder")))) + (let ((rec-dir (make-temp-file "recording-cleanup-test-" t))) + (unwind-protect + (cl-letf (((symbol-function 'cj/recording--validate-system-audio) + (lambda () nil))) + (let ((initial-count (test-cleanup--count-wf-recorder-processes))) + (dotimes (_ 3) + (cj/ffmpeg-record-video rec-dir) + (sit-for 0.5) + (cj/video-recording-stop) + (sit-for 0.5)) + (should (= (test-cleanup--count-wf-recorder-processes) initial-count)))) + (test-cleanup-teardown) + (ignore-errors (call-process "pkill" nil nil nil "-INT" "wf-recorder")) + (delete-directory rec-dir t)))) (provide 'test-video-audio-recording-process-cleanup) ;;; test-video-audio-recording-process-cleanup.el ends here |
