From e281d88b16fa9c0b8faf5243dfc21481ac3cba9d Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 1 Jul 2026 21:49:38 -0400 Subject: test(recording): record integration captures into a temp dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../test-video-audio-recording-process-cleanup.el | 90 ++++++++++++---------- 1 file changed, 48 insertions(+), 42 deletions(-) (limited to 'tests') 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 -- cgit v1.2.3