lang/go: add unit test commands
This commit is contained in:
parent
3722f17808
commit
3445e44926
1 changed files with 35 additions and 0 deletions
35
modules/lang/go/autoload.el
Normal file
35
modules/lang/go/autoload.el
Normal file
|
@ -0,0 +1,35 @@
|
|||
;;; lang/go/autoload.el
|
||||
|
||||
(defvar +go-test-last nil
|
||||
"The last test run.")
|
||||
|
||||
(defun +go--run-tests (args)
|
||||
(save-selected-window
|
||||
(async-shell-command (concat "go test " args))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +go/test-rerun ()
|
||||
(interactive)
|
||||
(if +go-test-last
|
||||
(funcall +go-test-last)
|
||||
(+go/run-all-tests)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +go/test-all ()
|
||||
(interactive)
|
||||
(+go--run-tests ""))
|
||||
|
||||
;;;###autoload
|
||||
(defun +go/test-nested ()
|
||||
(interactive)
|
||||
(+go--run-tests "./..."))
|
||||
|
||||
;;;###autoload
|
||||
(defun +go/test-single ()
|
||||
(interactive)
|
||||
(if (string-match "_test\\.go" buffer-file-name)
|
||||
(save-excursion
|
||||
(re-search-backward "^func[ ]+\\(([[:alnum:]]*?[ ]?[*]?[[:alnum:]]+)[ ]+\\)?\\(Test[[:alnum:]_]+\\)(.*)")
|
||||
(+go--run-tests (concat "-run" "='" (match-string-no-properties 2) "'")))
|
||||
(error "Must be in a _test.go file")))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue