|
17 | 17 |
|
18 | 18 | (defvar vterm-copy-mode-hook) |
19 | 19 | (defvar ghostel-enable-title-tracking) |
20 | | -(defvar ghostel--copy-mode-active) |
21 | 20 | (defvar ghostel--process) |
22 | 21 |
|
| 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 | + |
23 | 36 | (defun test-ai-code-backends-infra--symbol-source-base (symbol) |
24 | 37 | "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))) |
26 | 40 |
|
27 | 41 | (defun test-ai-code-backends-infra--variable-source-base (symbol) |
28 | 42 | "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))) |
30 | 45 |
|
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)) |
34 | 50 | (should (string-suffix-p |
35 | 51 | 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)) |
37 | 58 |
|
38 | 59 | (defun test-ai-code-backends-infra--assert-variable-source-module (symbol module) |
39 | 60 | "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)) |
44 | 63 |
|
45 | 64 | (ert-deftest test-ai-code-backends-infra-output-meaningful-p-noise () |
46 | 65 | "Ensure terminal noise is not considered meaningful output." |
|
357 | 376 | (test-ai-code-backends-infra--assert-variable-source-module |
358 | 377 | 'ai-code-backends-infra-eat-preserve-position |
359 | 378 | "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") |
360 | 382 | (test-ai-code-backends-infra--assert-function-source-module |
361 | 383 | 'ai-code-backends-infra--configure-vterm-buffer |
362 | 384 | "ai-code-backends-infra-vterm") |
|
0 commit comments