Subject: [bug#76594] [PATCH v2 1/5] gnu: quilt: Respect #:tests? key in check phase.

From: Liliana Marie Prikler <[email-masked]>
Date: Sun, 13 Apr 2025 17:45:18 +0200

Am Sonntag, dem 13.04.2025 um 10:57 -0400 schrieb Morgan Smith:
> * gnu/packages/patchutils.scm (quilt): Respect #:tests? key in check
> phase.
> 
> Change-Id: Ie44938ee080f2ac6b3947899e9589174fd3c6446
> ---
>  gnu/packages/patchutils.scm | 65 +++++++++++++++++++----------------
> --
>  1 file changed, 33 insertions(+), 32 deletions(-)
> 
> diff --git a/gnu/packages/patchutils.scm
> b/gnu/packages/patchutils.scm
> index 3cd3507b07..8ba227a3d3 100644
> --- a/gnu/packages/patchutils.scm
> +++ b/gnu/packages/patchutils.scm
> @@ -205,38 +205,39 @@ (define-public quilt
>                     ,(map cmd-path
>                           (list "find" "grep" "mkdir")))))))
>           (add-after 'compress-documentation 'check
> -           (lambda _
> -             (substitute* '("test/run" "test/edit.test")
> -               (("/bin/sh") (which "sh"))
> -               (("rm -rf") (string-append (which "rm") " -rf")))
> -             (substitute* "Makefile"
> -               (("^(PATH|QUILT_DIR).*" &)
> -                (string-append "#" &)) ; Test the installed 'quilt'
> -               (("export QUILT_DIR") "export")
> -               (("\\| sort") (string-append "| " (which "sort")))
> -               (("\\| sed") (string-append "| " (which "sed")))
> -               (("(chmod|touch)" &) (which &)))
> -             ;; Tests are scripts interpreted by `test/run` and may
> specify
> -             ;; the execution of several tools.  But PATH will be
> empty, so
> -             ;; rewrite with the full file name:
> -             (setenv "PATH" (string-append %output "/bin" ":"
> (getenv "PATH")))
> -             (substitute* (find-files "test" "\\.test$")
> -               (("([\\$\\|] )([[:graph:]]+)([[:blank:]\n]+)"
> -                 & > cmd <)
> -                (if (string=? cmd "zcat")
> -                    ;; The `zcat` program is a script, and it will
> not be able
> -                    ;; to invoke its `gzip` with PATH unset.  It's a
> simple
> -                    ;; script though, so just translate here:
> -                    (string-append > (which "gzip") " -cd " <)
> -                    (or (and=> (which cmd)
> -                               (lambda (p) (string-append > p <)))
> -                        &))))
> -             (let ((make (which "make")))
> -               ;; Assert the installed 'quilt' can find utilities it
> needs.
> -               (unsetenv "PATH")
> -               ;; Used by some tests for access to internal
> "scripts"
> -               (setenv "QUILT_DIR" (string-append %output
> "/share/quilt"))
> -               (invoke make "check")))))))
> +           (lambda* (#:key tests? #:allow-other-keys)
> +             (when tests?
> +               (substitute* '("test/run" "test/edit.test")
> +                 (("/bin/sh") (which "sh"))
> +                 (("rm -rf") (string-append (which "rm") " -rf")))
> +               (substitute* "Makefile"
> +                 (("^(PATH|QUILT_DIR).*" &)
> +                  (string-append "#" &)) ; Test the installed
> 'quilt'
> +                 (("export QUILT_DIR") "export")
> +                 (("\\| sort") (string-append "| " (which "sort")))
> +                 (("\\| sed") (string-append "| " (which "sed")))
> +                 (("(chmod|touch)" &) (which &)))
> +               ;; Tests are scripts interpreted by `test/run` and
> may specify
> +               ;; the execution of several tools.  But PATH will be
> empty, so
> +               ;; rewrite with the full file name:
> +               (setenv "PATH" (string-append %output "/bin" ":"
> (getenv "PATH")))
> +               (substitute* (find-files "test" "\\.test$")
> +                 (("([\\$\\|] )([[:graph:]]+)([[:blank:]\n]+)"
> +                   & > cmd <)
> +                  (if (string=? cmd "zcat")
> +                      ;; The `zcat` program is a script, and it will
> not be able
> +                      ;; to invoke its `gzip` with PATH unset.  It's
> a simple
> +                      ;; script though, so just translate here:
> +                      (string-append > (which "gzip") " -cd " <)
> +                      (or (and=> (which cmd)
> +                                 (lambda (p) (string-append > p <)))
> +                          &))))
Everything above this line should probably be done in a pre-check or
post-unpack phase.

> +               (let ((make (which "make")))
> +                 ;; Assert the installed 'quilt' can find utilities
> it needs.
> +                 (unsetenv "PATH")
> +                 ;; Used by some tests for access to internal
> "scripts"
> +                 (setenv "QUILT_DIR" (string-append %output
> "/share/quilt"))
> +                 (invoke make "check"))))))))
Could this be handled with arguments to make?

Cheers