aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2025-06-06 11:23:31 -0700
committerGravatar Tom Willemse2025-06-06 11:25:46 -0700
commit4696b26a94cebc75b71710fc9e957e3de35b1c3f (patch)
treed5419ac7879211b4f48e9d2c6edb5e07ab242e65
parent45873bd7a1115783549a546a114e6b208b031e89 (diff)
downloadnew-dotfiles-4696b26a94cebc75b71710fc9e957e3de35b1c3f.tar.gz
new-dotfiles-4696b26a94cebc75b71710fc9e957e3de35b1c3f.zip
pop-os: Allow running test-at-point in Emacs
-rw-r--r--oni/home/config/pop-os/emacs.el46
1 files changed, 29 insertions, 17 deletions
diff --git a/oni/home/config/pop-os/emacs.el b/oni/home/config/pop-os/emacs.el
index 2a02c7f..7906e6b 100644
--- a/oni/home/config/pop-os/emacs.el
+++ b/oni/home/config/pop-os/emacs.el
@@ -88,7 +88,8 @@
["Arguments & Switches"
("-b" "Brand" "--brand=" :choices ("chanced" "punt"))
("-f" "Stop on failure" "--stop-on-failure")
- ("-p" "Pick test" "--pick")]
+ ("-p" "Pick test" "--pick")
+ ("-P" "Test at point" "--at-point")]
["Commands"
("t" "Test" artisan-chanced-test)])
@@ -97,44 +98,55 @@
(interactive (list (transient-args transient-current-command)))
(let ((pick (transient-arg-value "--pick" args))
(fail (transient-arg-value "--stop-on-failure" args))
- (brand (transient-arg-value "--brand=" args)))
+ (brand (transient-arg-value "--brand=" args))
+ (at-point (transient-arg-value "--at-point" args)))
(artisan--test-internal pick (or brand "chanced")
(if (string= brand "punt")
"chanced"
"punt")
- fail)))
+ fail
+ at-point)))
-(defvar artisan--test-last-file nil
+(defvar artisan--test-last-state nil
"The last testing commnand that was run in the test buffer.
This variable should always be buffer local and only set in test
buffers.")
-(make-variable-buffer-local 'artisan--test-last-file)
+(make-variable-buffer-local 'artisan--test-last-state)
-(defun artisan--test-internal (pick name ignore fail)
+(defun artisan--test-internal (pick name ignore fail test-at-point-p)
(let* ((default-directory (expand-file-name name (project-root (project-current))))
(buffer-name (format "*%s Tests*" (capitalize name)))
(buffer (get-buffer-create buffer-name))
- (files (cons '("all" . "")
- (mapcar (lambda (dir) (cons (file-name-nondirectory dir) dir))
- (directory-files-recursively "../" (rx "Test.php") nil (lambda (subdir) (not (or (string-suffix-p "vendor" subdir)
- (string-suffix-p "data" subdir)
- (string-suffix-p "cdk.out" subdir)
- (string-suffix-p ignore subdir))))))))
+ (state (with-current-buffer buffer
+ artisan--test-last-state))
+ (filter (or (map-elt state 'filter)
+ (when test-at-point-p (which-function))))
+ (files (unless (map-elt state 'file)
+ (cons '("all" . "")
+ (mapcar (lambda (dir) (cons (file-name-nondirectory dir) dir))
+ (directory-files-recursively "../" (rx "Test.php") nil (lambda (subdir) (not (or (string-suffix-p "vendor" subdir)
+ (string-suffix-p "data" subdir)
+ (string-suffix-p "cdk.out" subdir)
+ (string-suffix-p ignore subdir)))))))))
(file (or (and (not pick)
- (with-current-buffer buffer
- artisan--test-last-file))
+ (map-elt state 'file))
+ (and test-at-point-p
+ (concat "../" (file-relative-name (buffer-file-name) (project-root (project-current)))))
(map-elt files (completing-read "File: " files nil t))))
(command (with-current-buffer buffer
- (format "../../chanced-scripts/test %s %s %s"
+ (format "../../chanced-scripts/test %s %s %s %s"
name
(if fail "--stop-on-failure" "")
- file)) )
+ (if filter (format "--filter=%s" filter) "")
+ file)))
(compilation-scroll-output t))
(cl-letf (((symbol-function 'compilation-buffer-name)
(lambda (&rest _) buffer-name)))
(compile command))
(with-current-buffer buffer
- (setq artisan--test-last-file file)
+ (setq artisan--test-last-state
+ `((file . ,file)
+ (filter . ,filter)))
(local-set-key (kbd "g")
(lambda ()
(interactive)