blob: c6b7ac2b7c71bc8ea7ddada976431a23ff5685d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
;;; test-ai-vterm--launch-command.el --- Tests for cj/--ai-vterm-launch-command -*- lexical-binding: t; -*-
;;; Commentary:
;; The launch command is what gets typed into a fresh vterm shell to bring
;; up Claude inside a per-project tmux session. The session is named after
;; the project basename so a second F9 on the same project reattaches to
;; the running Claude rather than spawning a new one. The trailing
;; `exec bash' keeps the tmux window alive if Claude exits, leaving the
;; session intact for recovery.
;;; Code:
(require 'ert)
(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
(require 'ai-vterm)
(ert-deftest test-ai-vterm--launch-command-uses-new-session-attach ()
"Normal: starts with `tmux new-session -A' so existing sessions reattach."
(let ((cj/ai-vterm-claude-command "claude"))
(should (string-prefix-p
"tmux new-session -A "
(cj/--ai-vterm-launch-command "/code/foo")))))
(ert-deftest test-ai-vterm--launch-command-includes-session-name ()
"Normal: the session name comes from the basename helper."
(let ((cj/ai-vterm-claude-command "claude"))
(should (string-match-p
" -s foo "
(cj/--ai-vterm-launch-command "/code/foo")))))
(ert-deftest test-ai-vterm--launch-command-includes-start-directory ()
"Normal: `-c <dir>' so the new session's first window starts in DIR."
(let ((cj/ai-vterm-claude-command "claude"))
(should (string-match-p
" -c /code/foo "
(cj/--ai-vterm-launch-command "/code/foo")))))
(ert-deftest test-ai-vterm--launch-command-includes-claude-command ()
"Normal: the configured claude command is in the launched shell command."
(let ((cj/ai-vterm-claude-command "claude --some-flag"))
(should (string-match-p
"claude --some-flag"
(cj/--ai-vterm-launch-command "/code/foo")))))
(ert-deftest test-ai-vterm--launch-command-tails-with-exec-bash ()
"Boundary: `exec bash' tails so the tmux window survives Claude exiting."
(let ((cj/ai-vterm-claude-command "claude"))
(should (string-match-p
"exec bash"
(cj/--ai-vterm-launch-command "/code/foo")))))
(ert-deftest test-ai-vterm--launch-command-handles-spaces-in-basename ()
"Boundary: a basename with whitespace becomes hyphenated before quoting."
(let ((cj/ai-vterm-claude-command "claude"))
(should (string-match-p
" -s my-work "
(cj/--ai-vterm-launch-command "/code/my work")))))
(provide 'test-ai-vterm--launch-command)
;;; test-ai-vterm--launch-command.el ends here
|