aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 04:10:13 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 04:10:13 -0500
commitb361e8d158d4403052e7b6996fdbe4f9127c1b0e (patch)
treea8e2fbe684abb0caa994903533bf565fa3ee8d86 /tests
parent91bb2857a90edfcca0fc0907ce813d4bd76f1b7a (diff)
downloaddotemacs-b361e8d158d4403052e7b6996fdbe4f9127c1b0e.tar.gz
dotemacs-b361e8d158d4403052e7b6996fdbe4f9127c1b0e.zip
fix(recording): create the selected recording directory, not its parent
The recording toggles took a directory from the prefix-arg prompt (or the default), then ran (file-name-directory location) before make-directory. For a path without a trailing slash that returns the parent, so make-directory created the parent and left the selected directory uncreated — ffmpeg then failed to write into it. Both toggles now route the destination through cj/recording--normalize-recording-dir, which expands and applies file-name-as-directory, then call make-directory on that normalized path. The selected directory itself is created (parents=t is a no-op when it already exists), including names with spaces. Tests cover trailing-slash normalization, idempotence, spaces, and relative-to-absolute expansion.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-video-audio-recording--normalize-recording-dir.el46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test-video-audio-recording--normalize-recording-dir.el b/tests/test-video-audio-recording--normalize-recording-dir.el
new file mode 100644
index 00000000..b2997302
--- /dev/null
+++ b/tests/test-video-audio-recording--normalize-recording-dir.el
@@ -0,0 +1,46 @@
+;;; test-video-audio-recording--normalize-recording-dir.el --- Tests for recording-dir normalization -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Unit tests for cj/recording--normalize-recording-dir.
+;; The recording target is always a directory that ffmpeg writes a
+;; timestamped file into. Normalization must yield an absolute directory
+;; path with a trailing slash so the *selected* directory (not its parent)
+;; is the one created and recorded into.
+
+;;; Code:
+
+(require 'ert)
+
+;; Stub dependencies before loading the module
+(defvar cj/custom-keymap (make-sparse-keymap)
+ "Stub keymap for testing.")
+
+(require 'video-audio-recording)
+
+;;; Normal Cases
+
+(ert-deftest test-video-audio-recording--normalize-recording-dir-normal-adds-trailing-slash ()
+ "Normal: a path without a trailing slash becomes a directory path."
+ (should (equal "/tmp/foo/"
+ (cj/recording--normalize-recording-dir "/tmp/foo"))))
+
+(ert-deftest test-video-audio-recording--normalize-recording-dir-normal-idempotent ()
+ "Normal: a path that is already a directory is returned unchanged."
+ (should (equal "/tmp/foo/"
+ (cj/recording--normalize-recording-dir "/tmp/foo/"))))
+
+;;; Boundary Cases
+
+(ert-deftest test-video-audio-recording--normalize-recording-dir-boundary-spaces-preserved ()
+ "Boundary: spaces in the path are preserved (quoting happens at the shell)."
+ (should (equal "/tmp/my recordings/"
+ (cj/recording--normalize-recording-dir "/tmp/my recordings"))))
+
+(ert-deftest test-video-audio-recording--normalize-recording-dir-boundary-relative-expands-absolute ()
+ "Boundary: a relative path expands to an absolute directory path."
+ (let ((result (cj/recording--normalize-recording-dir "foo")))
+ (should (file-name-absolute-p result))
+ (should (string-suffix-p "/foo/" result))))
+
+(provide 'test-video-audio-recording--normalize-recording-dir)
+;;; test-video-audio-recording--normalize-recording-dir.el ends here