summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-04-26 20:55:23 +0200
committercashmere <cashmere@autistici.org>2026-04-26 20:55:23 +0200
commit8766e973e36117c375ee3ac4ecddbd97a2a12ea9 (patch)
tree4a23947b76a86ab2d9d52d7d24ad7ecea861568c
parent9bf686f48e4dfcc64c4c9434a63989316f520dba (diff)
downloadkitty-graphics-8766e973e36117c375ee3ac4ecddbd97a2a12ea9.tar.gz
chore(justfile): add sixel test recipes
After rebasing onto master (which now carries the justfile from #8), add recipes for the new configurable encoder + timeout work: - `sixel-encoder' prints what `kitty-gfx--sixel-resolve-encoder' picks. - `sixel-encode [ENCODER]' encodes tests/test-image.png headlessly and reports payload size; pass an encoder name to force a specific binary (e.g. `just sixel-encode img2sixel'). - `sixel-timeout-test' verifies the watchdog kills a `sleep 60' fake encoder within `kitty-gfx-sixel-encoder-timeout' seconds. - `test-sixel-image [ENCODER]' opens tests/test-image.png in Emacs with the Sixel backend forced, for manual rendering checks in foot/Konsole/ mintty/mlterm/WezTerm.
-rw-r--r--justfile49
1 files changed, 49 insertions, 0 deletions
diff --git a/justfile b/justfile
index 1202ca5..22fe756 100644
--- a/justfile
+++ b/justfile
@@ -98,6 +98,55 @@ typst-show fragment="$integral_(-oo)^(+oo) e^(-x^2) dif x = sqrt(pi)$":
echo "png=$png"; \
[ -n "$png" ] && xdg-open "$png"
+# --- Headless sixel checks --------------------------------------------------
+
+# Show resolved sixel encoder (auto-detect: img2sixel > magick > convert)
+sixel-encoder:
+ {{EMACS}} -Q -batch -L . -l {{SRC}} --eval '(princ (format "%S\n" (kitty-gfx--sixel-resolve-encoder)))'
+
+# Encode tests/test-image.png to sixel headlessly, report payload size.
+# Override encoder with: just sixel-encode "img2sixel"
+sixel-encode encoder="":
+ {{EMACS}} -Q -batch -L . -l {{SRC}} --eval '(progn \
+ (setq kitty-gfx-debug t) \
+ (when (> (length "{{encoder}}") 0) \
+ (setq kitty-gfx-sixel-encoder-program "{{encoder}}")) \
+ (princ (format "encoder=%S\n" (kitty-gfx--sixel-resolve-encoder))) \
+ (let ((d (kitty-gfx--sixel-encode "tests/test-image.png" 20 10))) \
+ (princ (format "bytes=%s\n" (and d (length d))))))'
+ @echo "--- log tail ---"
+ @tail -3 /tmp/kitty-gfx.log 2>/dev/null || true
+
+# Verify timeout watchdog kills a hung encoder within `kitty-gfx-sixel-encoder-timeout'
+sixel-timeout-test:
+ @printf '#!/usr/bin/env bash\nsleep 60\n' > /tmp/kgfx-fake-encoder.sh
+ @chmod +x /tmp/kgfx-fake-encoder.sh
+ time {{EMACS}} -Q -batch -L . -l {{SRC}} --eval '(progn \
+ (setq kitty-gfx-debug t \
+ kitty-gfx-sixel-encoder-program "/tmp/kgfx-fake-encoder.sh" \
+ kitty-gfx-sixel-encoder-timeout 1.0) \
+ (with-temp-buffer \
+ (set-buffer-multibyte nil) \
+ (princ (format "ok=%S\n" (kitty-gfx--sixel-run-encoder \
+ "/tmp/kgfx-fake-encoder.sh" 1.0 \
+ (current-buffer) nil)))))'
+ @echo "--- log tail ---"
+ @tail -3 /tmp/kitty-gfx.log 2>/dev/null || true
+ @rm -f /tmp/kgfx-fake-encoder.sh
+
+# --- Interactive sixel tests (run inside a sixel-capable terminal) ----------
+
+# Open test-image.png with sixel backend forced (foot/Konsole/mintty/WezTerm)
+test-sixel-image encoder="":
+ @echo ">> Run inside foot, Konsole, mintty, mlterm, or WezTerm."
+ TERM={{TERM_}} {{EMACS}} -nw -Q -l {{SRC}} \
+ --eval "(setq kitty-gfx-debug t kitty-gfx-preferred-protocol 'sixel)" \
+ $(if [ -n "{{encoder}}" ]; then echo "--eval (setq\\ kitty-gfx-sixel-encoder-program\\ \"{{encoder}}\")"; fi) \
+ --eval "(kitty-graphics-mode 1)" \
+ tests/test-image.png
+
+# --- Logs -------------------------------------------------------------------
+
# Tail the kitty-gfx debug log (set kitty-gfx-debug to t to populate)
log:
tail -f /tmp/kitty-gfx.log