aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2026-02-03 11:44:44 -0800
committerGravatar Tom Willemse2026-02-09 10:44:09 -0800
commitff8796172e865481dfe7425f3c02a7ee0b7d15f4 (patch)
tree32d4137c446f6b44e29f6a203717958152cb035b
parentcfbafae5e69e6753b01416b3f76d22b01560a19e (diff)
downloadnew-dotfiles-ff8796172e865481dfe7425f3c02a7ee0b7d15f4.tar.gz
new-dotfiles-ff8796172e865481dfe7425f3c02a7ee0b7d15f4.zip
pop-os/emacs: Add some more test runner functions
-rw-r--r--oni/home/config/pop-os/emacs.el61
1 files changed, 46 insertions, 15 deletions
diff --git a/oni/home/config/pop-os/emacs.el b/oni/home/config/pop-os/emacs.el
index 7e7f3f9..24a48d6 100644
--- a/oni/home/config/pop-os/emacs.el
+++ b/oni/home/config/pop-os/emacs.el
@@ -28,8 +28,11 @@
""))
(local-set-key (kbd "C-c c") #'artisan-transient)
(local-set-key (kbd "C-c t t") '("Run tests" . artisan-run-test))
+ (local-set-key (kbd "C-c t T") '("Run tests (stop on failure)" . artisan-run-test-and-stop))
(local-set-key (kbd "C-c t f") '("Run tests in current file" . artisan-run-current-file-test))
+ (local-set-key (kbd "C-c t F") '("Run tests in current file (stop on failure)" . artisan-run-current-file-test-and-stop))
(local-set-key (kbd "C-c t p") '("Run Test at point" . artisan-run-test-at-point))
+ (local-set-key (kbd "C-c t P") '("Run Test at point (stop on failure)" . artisan-run-test-at-point-and-stop))
(when (equal major-mode 'php-mode)
(add-hook 'before-save-hook 'snowball-reformat-chanced-file nil t)))))
@@ -122,11 +125,15 @@ This variable should always be buffer local and only set in test
buffers.")
(make-variable-buffer-local 'artisan--test-last-state)
-(defun artisan-run-test (name &optional file filter)
+(defun oni-read-brand ()
+ "Ask for Chanced or Punt."
+ (nth 1 (read-multiple-choice "Chanced or Punt? " '((?c "chanced" "Chanced")
+ (?p "punt" "Punt")))))
+
+(cl-defun artisan-run-test (name &key file filter stop-on-failure-p)
(interactive
(let* ((refresh current-prefix-arg)
- (project (nth 1 (read-multiple-choice "Project:" '((?c "chanced" "Chanced")
- (?p "punt" "Punt")))))
+ (project (oni-read-brand))
(buffer-name (format "*%s Tests*" (capitalize project)))
(buffer (get-buffer-create buffer-name)))
(append (list project)
@@ -137,19 +144,24 @@ buffers.")
(buffer-name (format "*%s Tests*" (capitalize name)))
(buffer (get-buffer-create buffer-name))
(command (with-current-buffer buffer
- (format "../../chanced-scripts/test %s %s %s"
+ (format "../../chanced-scripts/test %s %s %s %s"
name
- (if filter (format "--filter=%s" filter) "")
+ (if filter (format "--filter='::%s$'" filter) "")
+ (if stop-on-failure-p "--stop-on-defect" "")
(or file "")))))
(cl-letf (((symbol-function 'compilation-buffer-name)
(lambda (&rest _) buffer-name)))
(compile command))
(with-current-buffer buffer
- (setq artisan--test-last-state (list file filter))
+ (setq artisan--test-last-state
+ (list :file file :filter filter :stop-on-failure-p stop-on-failure-p))
(local-set-key (kbd "g")
(lambda ()
(interactive)
- (artisan-run-test name file filter)))
+ (artisan-run-test name
+ :file file
+ :filter filter
+ :stop-on-failure-p stop-on-failure-p)))
(local-set-key (kbd "q") #'bury-buffer)
(local-set-key (kbd "s") (lambda () (interactive) (interrupt-process)))
(local-set-key (kbd "M-p") (lambda ()
@@ -161,22 +173,41 @@ buffers.")
(forward-line)
(search-forward " •"))))))
-(defun artisan-run-current-file-test (name)
+(defun artisan-run-test-and-stop (name)
+ (interactive
+ (list (oni-read-brand)))
+ (artisan-run-test name :stop-on-failure-p t))
+
+(defun artisan-run-current-file-test (name &optional stopp)
+ "Run PHP artisan test on the current file NAME.
+Optional argument STOPP means stop on any defect."
(interactive
- (list (nth 1 (read-multiple-choice "Chanced or Punt? " '((?c "chanced" "Chanced")
- (?p "punt" "Punt"))))))
+ (list (oni-read-brand)))
(let* ((project-root (project-root (project-current)))
(file (concat "../" (file-relative-name (buffer-file-name) project-root))))
- (artisan-run-test name file nil)))
+ (artisan-run-test name
+ :file file
+ :stop-on-failure-p stopp)))
-(defun artisan-run-test-at-point (name)
+(defun artisan-run-test-at-point (name &optional stopp)
+ "Run PHP artisan test on the function NAME.
+Optional argument STOPP means stop on any defect."
(interactive
- (list (nth 1 (read-multiple-choice "Chanced or Punt? " '((?c "chanced" "Chanced")
- (?p "punt" "Punt"))))))
+ (list (oni-read-brand)))
(let* ((project-root (project-root (project-current)))
(file (concat "../" (file-relative-name (buffer-file-name) project-root)))
(test (which-function)))
- (artisan-run-test name file test)))
+ (artisan-run-test name :file file :filter test :stop-on-failure-p stopp)))
+
+(defun artisan-run-current-file-test-and-stop (name)
+ (interactive
+ (list (oni-read-brand)))
+ (artisan-run-current-file-test name t))
+
+(defun artisan-run-test-at-point-and-stop (name)
+ (interactive
+ (list (oni-read-brand)))
+ (artisan-run-test-at-point name t))
;; (defun artisan--test-internal (pick name ignore fail test-at-point-p)
;; (let* ((default-directory (expand-file-name name (project-root (project-current))))