From 0f3059391479511013c560e16858f453d342cba5 Mon Sep 17 00:00:00 2001 From: w08r Date: Wed, 11 Dec 2024 09:31:47 +0000 Subject: [PATCH] Add custom args to test compile step --- lisp/progmodes/go-ts-mode.el | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index 86e74ad58a8..b926e6d7c64 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el @@ -52,6 +52,12 @@ :type '(repeat string) :group 'go) +(defcustom go-ts-mode-test-args nil + "List of extra args for the go-ts-mode test commands." + :version "31.1" + :type '(repeat string) + :group 'go) + (defvar go-ts-mode--syntax-table (let ((table (make-syntax-table))) (modify-syntax-entry ?+ "." table) @@ -392,11 +398,20 @@ specifying build tags." (format "-tags %s" (string-join go-ts-mode-build-tags ",")) "")) +(defun go-ts-mode--get-test-args () + "Return the test args. +This function respects the `go-ts-mode-test-args' variable for +specifying test args, such as adding coverage file." + (if go-ts-mode-test-args + (string-join go-ts-mode-test-args) + "")) + (defun go-ts-mode--compile-test (regexp) "Compile the tests matching REGEXP. This function respects the `go-ts-mode-build-tags' variable for specifying build tags." - (compile (format "go test -v %s -run '%s'" + (compile (format "go test %s -v %s -run '%s'" + (go-ts-mode--get-test-args) (go-ts-mode--get-build-tags-flag) regexp))) -- 2.32.0