aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test-video-audio-recording-process-cleanup.el90
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