2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/go/autoload.el -*- lexical-binding: t; -*-
|
2017-03-20 03:49:13 -04:00
|
|
|
|
2017-04-07 01:45:57 -04:00
|
|
|
;;;###autoload
|
|
|
|
;; TODO (defun +go/build ())
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Tests
|
|
|
|
;;
|
|
|
|
|
2017-03-20 03:49:13 -04:00
|
|
|
(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")))
|
|
|
|
|