feat(go): add test-file function and keybinding
This commit is contained in:
parent
55544200be
commit
887e9fd12c
2 changed files with 14 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
"a" #'+go/test-all
|
||||
"s" #'+go/test-single
|
||||
"n" #'+go/test-nested
|
||||
"f" #'+go/test-file
|
||||
"g" #'go-gen-test-dwim
|
||||
"G" #'go-gen-test-all
|
||||
"e" #'go-gen-test-exported
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue