Subject: Re: bug#42146: [PATCH core-updates 1/?] build: substitute: Don't fail silently.

From: Ludovic Courtès <[email-masked]>
Date: Mon, 23 Oct 2023 10:48:12 +0200

Hi,

Maxim Cournoyer <[email-masked]> skribis:

> From: Jakub Kądziołka <[email-masked]>
>
> * guix/build/utils.scm (substitute, substitute*)
> [require-matches?]: New argument.
> * tests/build-utils.scm ("substitute*"): New test group.
> ("substitute*, no match error")
> ("substitute*, partial no match error"): New tests.
>
> Co-authored-by: Maxim Cournoyer <[email-masked]>
> Change-Id: I66ed33d72aa73cd35e5642521efec70bf756f86e

[…]

> +(define-condition-type &substitute-error &error
> +  substitute-error?
> +  (file substitute-error-file)
> +  (patterns substitute-error-patterns))
> +
> +(define %substitute-requires-matches?
> +  (make-parameter #t))

[…]

> @@ -1048,9 +1086,19 @@ (define-syntax substitute*
>  Alternatively, FILE may be a list of file names, in which case they are
>  all subject to the substitutions.
>  
> +By default, SUBSTITUTE* will raise a &message condition if one of the patterns

I think it’s ‘&substitute-error’ rather than ‘&message’.

> +(define-substitute*-test test-error "substitute*, partial no match error"
> +  #t                                  ;expected
> +  "a\0b"                              ;content
> +  (("a") "c"
> +   ("Oops!") "c"))

Maybe it’s not all that important here, but I think ‘test-error’ tests
for any exception, whereas we’re looking specifically for a
‘&substitute-error’ condition filled with the right values.

Ludo’.