mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
feat(go): add test-file function and keybinding
This commit is contained in:
committed by
Henrik Lissner
parent
55544200be
commit
887e9fd12c
@ -11,7 +11,7 @@
|
||||
(compile cmd)))
|
||||
|
||||
(defun +go--run-tests (args)
|
||||
(let ((cmd (concat "go test " args)))
|
||||
(let ((cmd (concat "go test -test.v " args)))
|
||||
(setq +go-test-last (concat "cd " default-directory ";" cmd))
|
||||
(+go--spawn cmd)))
|
||||
|
||||
@ -41,6 +41,18 @@
|
||||
(+go--run-tests (concat "-run" "='^\\Q" (match-string-no-properties 2) "\\E$'")))
|
||||
(error "Must be in a _test.go file")))
|
||||
|
||||
;;;###autoload
|
||||
(defun +go/test-file ()
|
||||
(interactive)
|
||||
(if (string-match "_test\\.go" buffer-file-name)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(let ((func-list))
|
||||
(while (re-search-forward "^func[ ]+\\(([[:alnum:]]*?[ ]?[*]?[[:alnum:]]+)[ ]+\\)?\\(Test[[:alnum:]_]+\\)(.*)" nil t)
|
||||
(push (match-string-no-properties 2) func-list))
|
||||
(+go--run-tests (concat "-run" "='^(" (string-join func-list "|") ")$'"))))
|
||||
(error "Must be in a _test.go file")))
|
||||
|
||||
;;;###autoload
|
||||
(defun +go/bench-all ()
|
||||
(interactive)
|
||||
|
Reference in New Issue
Block a user