aboutsummaryrefslogtreecommitdiff
path: root/tests/test-dwim-shell-config-concat.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-23 20:01:25 -0500
committerCraig Jennings <c@cjennings.net>2026-05-23 20:01:25 -0500
commit5de470b1030c932b4e99ce685c0f27078a5db428 (patch)
tree3e9cb37a953a50fe9a81633067dc9c51ef9944c8 /tests/test-dwim-shell-config-concat.el
parentc0237adec5a92d6a2814f23b40be4d5415bcd9c8 (diff)
downloaddotemacs-5de470b1030c932b4e99ce685c0f27078a5db428.tar.gz
dotemacs-5de470b1030c932b4e99ce685c0f27078a5db428.zip
fix(dwim-shell): build video-concat filelist in elisp
cj/dwim-shell-commands-concatenate-videos built the ffmpeg concat list with echo '<<*>>' | tr ' ' '\n' | sed 's/^/file /'. That splits on spaces, so any video whose name contains a space produced a broken list, and a name with a quote broke the echo outright. I extracted cj/dwim-shell--build-concat-filelist, which renders each path as an escaped file '...' line. I write that list to a temp file and run ffmpeg against the quoted listfile, with a trailing rm to clean up after the process exits. The <<*>> token stays only as an inert shell comment, since dwim-shell needs it to run one command over all marked files instead of once per file.
Diffstat (limited to 'tests/test-dwim-shell-config-concat.el')
-rw-r--r--tests/test-dwim-shell-config-concat.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test-dwim-shell-config-concat.el b/tests/test-dwim-shell-config-concat.el
new file mode 100644
index 00000000..acbbbb2b
--- /dev/null
+++ b/tests/test-dwim-shell-config-concat.el
@@ -0,0 +1,29 @@
+;;; test-dwim-shell-config-concat.el --- Tests for concat filelist builder -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Covers cj/dwim-shell--build-concat-filelist, which renders an ffmpeg
+;; concat-demuxer filelist from a list of paths. Building it in Elisp (rather
+;; than echo/tr/sed over <<*>>) keeps paths with spaces and quotes intact.
+
+;;; Code:
+
+(require 'ert)
+(require 'dwim-shell-config)
+
+(ert-deftest test-dwim-concat-filelist-plain-paths ()
+ "Normal: plain paths become single-quoted file lines, newline-separated."
+ (should (equal (cj/dwim-shell--build-concat-filelist '("/v/a.mp4" "/v/b.mp4"))
+ "file '/v/a.mp4'\nfile '/v/b.mp4'")))
+
+(ert-deftest test-dwim-concat-filelist-space-in-path ()
+ "Boundary: a path with spaces stays inside the quotes, unsplit."
+ (should (equal (cj/dwim-shell--build-concat-filelist '("/v/my movie.mp4"))
+ "file '/v/my movie.mp4'")))
+
+(ert-deftest test-dwim-concat-filelist-quote-in-path ()
+ "Error/edge: a single quote in a path is escaped for the concat list."
+ (should (equal (cj/dwim-shell--build-concat-filelist '("/v/it's here.mp4"))
+ "file '/v/it'\\''s here.mp4'")))
+
+(provide 'test-dwim-shell-config-concat)
+;;; test-dwim-shell-config-concat.el ends here