Subject: Re: bug#68919: 30.0.50; etc/w32-feature.el: tests do not work under --batch

From: Eli Zaretskii <[email-masked]>
Date: Sun, 04 Feb 2024 09:08:56 +0200

> Date: Sat, 03 Feb 2024 21:41:34 -0600
> From: [email-masked]
> 
> On 2024-02-03 21:37, Corwin Brust wrote:
> > 
> > This currently fails because the harfbuzz test is ungated: it runs
> > irrespective of whether a (graphical) display is attached.  Once I
> > receive a confirmation with this Bug# for the commit message, I'll
> > send along a tiny patch to address this using `display-graphic-p'.
> > 
> 
> Patch is attached
> 
> diff --git a/etc/w32-feature.el b/etc/w32-feature.el
> index 8d36e32e0fb..3bd818ea6ea 100644
> --- a/etc/w32-feature.el
> +++ b/etc/w32-feature.el
> @@ -45,10 +45,12 @@ feature-optimization
>     (string-match-p "CFLAGS=-O2" system-configuration-options)))
>  
>  (ert-deftest feature-harfbuzz ()
> -  (should
> -   (eq
> -    'harfbuzz
> -    (car (frame-parameter nil 'font-backend)))))
> +  (if (display-graphic-p)
> +      (should
> +       (eq
> +	'harfbuzz
> +	(car (frame-parameter nil 'font-backend))))
> +    (ert-skip "No graphic display")))

We can do better than this, I think.  The following works in batch
mode:

  emacs -batch --eval "(message \"%s\" (get 'uniscribe 'font-driver-superseded-by))"
   => harfbuzz

So I suggest to rewrite the above test to use this technique.  See
syms_of_w32uniscribe_for_pdumper for the details: the above will only
yield 'harfbuzz' if Emacs was built with HarfBuzz support and
succeeded to load the HarfBuzz DLL at run time.