diff options
| author | Craig Jennings <c@cjennings.net> | 2026-02-06 13:00:01 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-02-06 13:12:44 -0600 |
| commit | c603124f6487604baee5aab590e1432e99570ca8 (patch) | |
| tree | 85c8b3ac4dc0573b1aee4448c1ae7d2c21ce3225 /tests/test-video-audio-recording--wait-for-exit.el | |
| parent | 25a2acb634212455abeb0a0c8fb1a97c3ece3a2c (diff) | |
feat(recording): rewrite device setup, fix video stop, update modeline icons
Video stop fix: kill wf-recorder (producer) first on Wayland so ffmpeg
gets clean EOF, then signal process group. Replaces sit-for with
poll-based wait-for-exit. Fixes zero-byte output files.
Device selection: rewrite quick setup to show all available mics with
PulseAudio descriptions, auto-detect default sink monitor for system
audio. Skip confirmation dialog, add Cancel option to mic list.
Modeline: replace red dot emoji with nerd font icons (mic/camcorder).
Rename quick-setup-for-calls to quick-setup, rebind C-; r s / C-; r S.
173 recording tests pass (was 165).
Diffstat (limited to 'tests/test-video-audio-recording--wait-for-exit.el')
| -rw-r--r-- | tests/test-video-audio-recording--wait-for-exit.el | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/test-video-audio-recording--wait-for-exit.el b/tests/test-video-audio-recording--wait-for-exit.el new file mode 100644 index 00000000..adacd828 --- /dev/null +++ b/tests/test-video-audio-recording--wait-for-exit.el @@ -0,0 +1,80 @@ +;;; test-video-audio-recording--wait-for-exit.el --- Tests for recording wait-for-exit -*- lexical-binding: t; -*- + +;;; Commentary: +;; Unit tests for `cj/recording--wait-for-exit', the function that polls +;; for process exit instead of using a blind `sit-for' delay. +;; +;; This function is critical to the recording fix: without proper waiting, +;; ffmpeg cannot finalize container metadata, resulting in zero-byte files. +;; +;; Tests use real short-lived processes (`true', `sleep') to exercise the +;; actual polling logic rather than mocking `process-live-p'. + +;;; Code: + +(require 'ert) + +;; Stub dependencies before loading the module +(defvar cj/custom-keymap (make-sparse-keymap) + "Stub keymap for testing.") + +;; Now load the actual production module +(require 'video-audio-recording) + +;;; Normal Cases + +(ert-deftest test-video-audio-recording--wait-for-exit-normal-process-exits-returns-t () + "Test that wait-for-exit returns t when process exits within timeout. +Uses `true' which exits immediately." + (let ((proc (make-process :name "test-exit" :command '("true")))) + (sit-for 0.2) ; Let it exit + (should (eq t (cj/recording--wait-for-exit proc 2))))) + +(ert-deftest test-video-audio-recording--wait-for-exit-normal-polls-until-exit () + "Test that wait-for-exit polls and returns t after process exits. +Uses a short sleep to verify polling works across multiple iterations." + (let ((proc (make-process :name "test-short" :command '("sleep" "0.2")))) + (should (eq t (cj/recording--wait-for-exit proc 3))))) + +;;; Boundary Cases + +(ert-deftest test-video-audio-recording--wait-for-exit-boundary-already-dead-returns-t () + "Test that wait-for-exit returns t immediately for already-dead process." + (let ((proc (make-process :name "test-dead" :command '("true")))) + (sit-for 0.2) ; Ensure it's dead + (should-not (process-live-p proc)) + (should (eq t (cj/recording--wait-for-exit proc 1))))) + +(ert-deftest test-video-audio-recording--wait-for-exit-boundary-zero-timeout-dead-process () + "Test that zero timeout with dead process returns t." + (let ((proc (make-process :name "test-zero-dead" :command '("true")))) + (sit-for 0.2) + (should (eq t (cj/recording--wait-for-exit proc 0))))) + +(ert-deftest test-video-audio-recording--wait-for-exit-boundary-zero-timeout-live-process () + "Test that zero timeout with live process returns nil (timed out)." + (let ((proc (make-process :name "test-zero-live" :command '("sleep" "1000")))) + (unwind-protect + (should (eq nil (cj/recording--wait-for-exit proc 0))) + (delete-process proc)))) + +(ert-deftest test-video-audio-recording--wait-for-exit-boundary-timeout-exceeded-returns-nil () + "Test that wait-for-exit returns nil when timeout is exceeded. +Uses a long-running process with a very short timeout." + (let ((proc (make-process :name "test-timeout" :command '("sleep" "1000")))) + (unwind-protect + (should (eq nil (cj/recording--wait-for-exit proc 0.2))) + (delete-process proc)))) + +;;; Error Cases + +(ert-deftest test-video-audio-recording--wait-for-exit-error-deleted-process-returns-t () + "Test that wait-for-exit handles a deleted (not just exited) process. +A process killed via `delete-process' should be detected as not live." + (let ((proc (make-process :name "test-deleted" :command '("sleep" "1000")))) + (delete-process proc) + (sit-for 0.1) + (should (eq t (cj/recording--wait-for-exit proc 1))))) + +(provide 'test-video-audio-recording--wait-for-exit) +;;; test-video-audio-recording--wait-for-exit.el ends here |
