Skip to content

Commit 6ebb8fc

Browse files
bogdanteleagasyl20bnr
authored andcommitted
Change regex to accomodate cases where there's no test suite
1 parent 7352dd5 commit 6ebb8fc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

layers/+lang/go/packages.el

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"-check.f"
4343
"-run")))
4444
(save-excursion
45-
(re-search-backward "^func[ ]+([[:alnum:]]*?[ ]?[*]?\\([[:alnum:]]+\\))[ ]+\\(Test[[:alnum:]]+\\)(.*)")
45+
(re-search-backward "^func[ ]+\\(([[:alnum:]]*?[ ]?[*]?[[:alnum:]]+)[ ]+\\)?\\(Test[[:alnum:]]+\\)(.*)")
4646
(spacemacs/go-run-tests (concat test-method "='" (match-string-no-properties 2) "'"))))
4747
(message "Must be in a _test.go file to run go-run-test-current-function")))
4848

@@ -51,8 +51,8 @@
5151
(if (string-match "_test\.go" buffer-file-name)
5252
(if go-use-gocheck-for-testing
5353
(save-excursion
54-
(re-search-backward "^func[ ]+([[:alnum:]]*?[ ]?[*]?\\([[:alnum:]]+\\))[ ]+\\(Test[[:alnum:]]+\\)(.*)")
55-
(spacemacs/go-run-tests (concat "-check.f='" (match-string-no-properties 1) "'")))
54+
(re-search-backward "^func[ ]+\\(([[:alnum:]]*?[ ]?[*]?\\([[:alnum:]]+\\))[ ]+\\)?Test[[:alnum:]]+(.*)")
55+
(spacemacs/go-run-tests (concat "-check.f='" (match-string-no-properties 2) "'")))
5656
(message "Gocheck is needed to test the current suite"))
5757
(message "Must be in a _test.go file to run go-test-current-suite")))
5858

0 commit comments

Comments
 (0)