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

From: Robert Pluim <[email-masked]>
Date: Wed, 11 Dec 2024 16:58:03 +0100

>>>>> On Wed, 11 Dec 2024 17:45:59 +0200, Eli Zaretskii <[email-masked]> said:

    >> From: "O'Brien, Will" <[email-masked]>
    >> Date: Wed, 11 Dec 2024 10:18:04 +0000
    >> 
    >> First time trying to contribute here, so apologies for any wrong doing.  I
    >> haven't signed FSF papers; would be happy to but believe this may fit in to
    >> tiny patch territory.

    Eli> It does.  But you may wish to start the paperwork regardless, so we
    Eli> could accept your future contributions without limitations.  Let me
    Eli> know if you want me to send you the form and instructions.

    >> This is a feature request to pass custom flags down to the test compile
    >> step in go-ts-mode-test-... functions.  Specifically I wanted to
    >> add the coverprofile argument to unit test invocation.
    >> 
    >> The attached patch seems to do the trick for me.

    Eli> Thanks.

    Eli> Randy, any comments or suggestions?

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.

Robert
--