Merge pull request #2504 from nl5887/develop

Bind '<leader> t b' prefix to benchmarks
This commit is contained in:
Henrik Lissner 2020-02-09 18:37:39 -05:00 committed by GitHub
commit 02b8c3f239
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -41,6 +41,21 @@
(+go--run-tests (concat "-run" "='" (match-string-no-properties 2) "'")))
(error "Must be in a _test.go file")))
;;;###autoload
(defun +go/bench-all ()
(interactive)
(+go--run-tests "-test.run=NONE -test.bench=\".*\""))
;;;###autoload
(defun +go/bench-single ()
(interactive)
(if (string-match "_test\\.go" buffer-file-name)
(save-excursion
(re-search-backward "^func[ ]+\\(([[:alnum:]]*?[ ]?[*]?[[:alnum:]]+)[ ]+\\)?\\(Benchmark[[:alnum:]_]+\\)(.*)")
(+go--run-tests (concat "-test.run=NONE -test.bench" "='" (match-string-no-properties 2) "'")))
(error "Must be in a _test.go file")))
;;;###autoload
(defun +go/play-buffer-or-region (&optional beg end)
"TODO"

View file

@ -55,7 +55,10 @@
"n" #'+go/test-nested
"g" #'go-gen-test-dwim
"G" #'go-gen-test-all
"e" #'go-gen-test-exported)))
"e" #'go-gen-test-exported
(:prefix ("b" . "bench")
"s" #'+go/bench-single
"a" #'+go/bench-all))))
(use-package! gorepl-mode