Subject: bug#79027: xref/pp changes in latest versions?

From: Gonzalo Larumbe <[email-masked]>
Date: Wed, 16 Jul 2025 14:54:29 +0200

Thanks for the quick response.

The test compares a reference text file generated beforehand using `xref`
and `pp` (e.g.
https://github.com/gmlarumbe/verilog-ext/blob/main/test/ref/xref/ucontroller.xref.defs.el)
with a text file generated during the test.

Reference files and current test files are generated using the function
`test-hdl-process-file-fn`:
- Line 84 @
https://github.com/gmlarumbe/test-hdl/blob/86ed7f9dcb0d0697e6b7ce0a64d82b7245cfade9/test-hdl-common.el

This particular xref test compares a list of xref objects gathered from a
Verilog file using the following test function:
(cl-defun verilog-ext-test-xref-fn (&key refs type)
  (let (ret-val)
    (dolist (ref refs (nreverse ret-val))
      (push (verilog-ext-xref--find-symbol ref type) ret-val))))

The function `verilog-ext-xref--find-symbol` returns a list of `xref-items`
with their respective `xref-file-locations` from a hash-table created
previously by parsing the file using tree-sitter.
- Line 40 @
https://github.com/gmlarumbe/verilog-ext/blob/main/verilog-ext-xref.el

This list is pretty printed to a file using `pp-29` as
`pp-default-function` for compatibility in tests between Emacs 29 and 30.

Use of font-lock to have a list of fontified xref matches is customizable.
In this case the files are parsed and `font-lock-ensure` is run. This did
not seem to be a problem and the behaviour is the same for versions from
29.1 to 30.1.

I tried to override the existing definitions on `pp.el` and `xref.el` so
that all Emacs versions in CI used the same code. However the `snapshot`
build still fails.

El mié, 16 jul 2025 a las 13:39, Eli Zaretskii (<[email-masked]>) escribió:

> > From: Gonzalo Larumbe <[email-masked]>
> > Date: Wed, 16 Jul 2025 00:04:32 +0200
> >
> > I am experiencing an error in a CI job in GitHub in some packages I
> currently maintain (verilog-ext and
> > vhdl-ext, available on MELPA). The error only happens in the `snapshot`
> build, cached from a recent Emacs
> > version (https://github.com/purcell/nix-emacs-ci).
> >
> > In both of these packages (verilog-ext and vhdl-ext) I have created an
> `xref` backend based on tree-sitter.
> > To test it there is an ERT test suite that writes the xref items to a
> text file with `(pp-default-function #'pp-29)`
> > and compares it with a reference file created previously using the same
> function.
> >
> > This test works well with all Emacs versions from 29.1 to 30.1 and with
> release-snapshot. However with the
> > latest versions it seems something in `pp` or in `xref` might have
> changed that I am missing and maybe I
> > should update to. Is there any idea of what could it be?
> >
> > I attach the log of GitHub actions failing job in case it could be
> useful.
>
> Judging by the log, the failures are due to differences in text
> properties, and specifically to the differences in the 'fontified'
> properties.  Why is that significant for your test?  The 'fontified'
> property is used internally by JIT font-lock feature of Emacs, so it
> shouldn't matter to any Lisp program, unless the program is somehow
> related to font-lock machinery.
>
> For that matter, how about telling more about what
> test-hdl-files-equal does and what is its purpose and main ideas of
> implementation?  It's hard to tell anything intelligent without some
> additional information.
>