Skip to content

Commit 22c6049

Browse files
committed
Add ghostel--copy-mode-active and refactor tests
1 parent 2e30df2 commit 22c6049

2 files changed

Lines changed: 34 additions & 11 deletions

File tree

ai-code-backends-infra-ghostel.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
(defvar ghostel--process nil)
2727
(defvar ghostel--term nil)
2828
(defvar ghostel--term-rows nil)
29+
(defvar ghostel--copy-mode-active nil)
2930

3031
(defun ai-code-backends-infra--ensure-ghostel-backend ()
3132
"Ensure the ghostel backend is available."

test/test_ai-code-backends-infra.el

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,49 @@
1717

1818
(defvar vterm-copy-mode-hook)
1919
(defvar ghostel-enable-title-tracking)
20-
(defvar ghostel--copy-mode-active)
2120
(defvar ghostel--process)
2221

22+
(ert-deftest test-ai-code-backends-infra-source-base-strips-source-and-bytecode-suffixes ()
23+
"Normalize both `.el' and `.elc' suffixes when comparing source paths."
24+
(should (equal (test-ai-code-backends-infra--source-base "/tmp/example.el")
25+
"/tmp/example"))
26+
(should (equal (test-ai-code-backends-infra--source-base "/tmp/example.elc")
27+
"/tmp/example")))
28+
29+
(defun test-ai-code-backends-infra--source-base (file)
30+
"Return FILE path without trailing `.elc' or `.el' extension."
31+
(let ((base (file-name-sans-extension file)))
32+
(if (string-suffix-p ".el" base)
33+
(file-name-sans-extension base)
34+
base)))
35+
2336
(defun test-ai-code-backends-infra--symbol-source-base (symbol)
2437
"Return SYMBOL definition file without extension."
25-
(file-name-sans-extension (symbol-file symbol 'defun)))
38+
(test-ai-code-backends-infra--source-base
39+
(symbol-file symbol 'defun)))
2640

2741
(defun test-ai-code-backends-infra--variable-source-base (symbol)
2842
"Return variable SYMBOL definition file without extension."
29-
(file-name-sans-extension (symbol-file symbol 'defvar)))
43+
(test-ai-code-backends-infra--source-base
44+
(symbol-file symbol 'defvar)))
3045

31-
(defun test-ai-code-backends-infra--assert-function-source-module (symbol module)
32-
"Assert function SYMBOL is defined in backend MODULE."
33-
(should (fboundp symbol))
46+
(defun test-ai-code-backends-infra--assert-source-module (symbol module
47+
predicate source-fn)
48+
"Assert SYMBOL satisfies PREDICATE and comes from MODULE via SOURCE-FN."
49+
(should (funcall predicate symbol))
3450
(should (string-suffix-p
3551
module
36-
(test-ai-code-backends-infra--symbol-source-base symbol))))
52+
(funcall source-fn symbol))))
53+
54+
(defun test-ai-code-backends-infra--assert-function-source-module (symbol module)
55+
"Assert function SYMBOL is defined in backend MODULE."
56+
(test-ai-code-backends-infra--assert-source-module
57+
symbol module #'fboundp #'test-ai-code-backends-infra--symbol-source-base))
3758

3859
(defun test-ai-code-backends-infra--assert-variable-source-module (symbol module)
3960
"Assert variable SYMBOL is defined in backend MODULE."
40-
(should (boundp symbol))
41-
(should (string-suffix-p
42-
module
43-
(test-ai-code-backends-infra--variable-source-base symbol))))
61+
(test-ai-code-backends-infra--assert-source-module
62+
symbol module #'boundp #'test-ai-code-backends-infra--variable-source-base))
4463

4564
(ert-deftest test-ai-code-backends-infra-output-meaningful-p-noise ()
4665
"Ensure terminal noise is not considered meaningful output."
@@ -357,6 +376,9 @@
357376
(test-ai-code-backends-infra--assert-variable-source-module
358377
'ai-code-backends-infra-eat-preserve-position
359378
"ai-code-backends-infra-eat")
379+
(test-ai-code-backends-infra--assert-variable-source-module
380+
'ghostel--copy-mode-active
381+
"ai-code-backends-infra-ghostel")
360382
(test-ai-code-backends-infra--assert-function-source-module
361383
'ai-code-backends-infra--configure-vterm-buffer
362384
"ai-code-backends-infra-vterm")

0 commit comments

Comments
 (0)