Subject: bug#74786: [PATCH] Add custom args to test compile step

From: "O'Brien, Will" <[email-masked]>
Date: Wed, 11 Dec 2024 16:31:49 +0000

On Wed, Dec 11 2024 at 16:58, Robert Pluim <[email-masked]> wrote:

>>>>>> On Wed, 11 Dec 2024 17:45:59 +0200, Eli Zaretskii <[email-masked]> said:
>
> Iʼm not Randy, but:
>
>     >> +(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)
>     >> +    ""))
>     >> +
>
> This entire function is not needed, since
>
> (string-join nil) => ""
>
>     >>  (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)))
>     >> 
>
> so you could just inline the `string-join' here.

Ah, thanks!  I've attached a new patch with the simplification.

best
--
will

>From 497266302d7ac20be411685c8d7a6dba0126360a Mon Sep 17 00:00:00 2001
From: w08r <[email-masked]>
Date: Wed, 11 Dec 2024 09:31:47 +0000
Subject: [PATCH] Add custom args to test compile step

---
 lisp/progmodes/go-ts-mode.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
index 86e74ad58a8..acf458bf63b 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 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)
@@ -396,7 +402,8 @@ specifying build tags."
   "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'"
+                   (string-join go-ts-mode-test-args)
                    (go-ts-mode--get-build-tags-flag)
                    regexp)))
 
-- 
2.32.0