Function: bazel-go-test-at-point

bazel-go-test-at-point is a natively compiled function defined in bazel.el.

Signature

(bazel-go-test-at-point)

Documentation

Return the name of the Go test at point.

Useful for ‘bazel-test-at-point-functions’. See URL ‘https://pkg.go.dev/testing’.

Source Code

;; Defined in /nix/store/ws8pkszjvcad1rgzqw6wja7qxacylfhn-emacs-packages-deps/share/emacs/site-lisp/elpa/bazel-20261002.1510/bazel.el
(defun bazel-go-test-at-point ()
  "Return the name of the Go test at point.
Useful for ‘bazel-test-at-point-functions’.
See URL ‘https://pkg.go.dev/testing’."
  (declare (ftype (function () (or string null))))
  (save-excursion
    (let ((case-fold-search nil)
          (search-spaces-regexp nil))
      (and (beginning-of-defun)
           (looking-at (rx bol "func" (+ blank)
                           (group (or "Test" "Benchmark" "Example")
                                  ;; https://go.dev/ref/spec#Identifiers
                                  (* (any alnum ?_)))
                           (* blank) ?\())
           ;; Go interprets the filter as unanchored regular expression,
           ;; cf. https://pkg.go.dev/testing#hdr-Subtests_and_Sub_benchmarks.
           ;; So we anchor and quote the function name.  Don’t use
           ;; ‘regexp-quote’, since the Emacs and Go regular expression syntaxes
           ;; aren’t compatible.
           (concat "^\\Q" (match-string-no-properties 1) "\\E$")))))