gusbrs / zref-clever

Clever LaTeX cross-references based on zref
LaTeX Project Public License v1.3c
11 stars 4 forks source link

Make .tlg independent of l3backend declarations #27

Closed muzimuzhi closed 3 months ago

muzimuzhi commented 3 months ago

This PR loads latex3 backend driver before enabling check-declarations debugging option, therefore makes .tlg files independent of changes in l3backend declarations, and makes changes like fa2a9b3 (Update regression tests for upstream change, 2024-05-03) no longer needed in the future.

A regression-test.cfg config file is added. It is auto-loaded by regression-test.tex, and it now loads l3backend driver and sets \debug_on:n { ... } shared by all test files.

muzimuzhi commented 3 months ago

By default (in LaTeX) l3backend driver is loaded at the beginning of \document, and it's supported and totally safe to load it earlier, see https://github.com/latex3/latex3/issues/1180#issuecomment-1454616342.

gusbrs commented 3 months ago

Hi @muzimuzhi ! Thank you very much for looking out for zref-clever. :-)

However, I'm not quite sure about this one. Preloading the l3backend driver feels a bit like over-engineering the test files. Is this something the community at large is doing in the .lvts? This is another area where I learned by looking what others more capable than myself did, and I don't recall seeing \sys_ensure_backend: around. Perhaps I missed it, or dismissed it for not understanding the reason for it then. But I don't recall.

Besides, the test files affected by this are a few where I wanted to test something which occurs during \begin{document} and had thus to move \START before it. So I expect these tests to be noisy, and include a number of things which are irrelevant, and out of my control. Thus requiring an occasional commit like this one just to adjust the .tlgs for an unrelated change somewhere. True, preloading the l3backend reduces a little this noise, which is welcome, but the base problem will remain.

About extracting common setup tasks to regression-test.cfg, I'm not sure either. I won't say I originally gave much thought about it, but my first reaction to this commit is that I think it would be wisest to keep each test file self-sufficient, even at the cost of some repetition. For example, I do have a test file for which I can't enable check-declarations because of polyglossia (https://github.com/gusbrs/postnotes/blob/c01aa4c2855e96c751ae63bf86489a1348bdd1d9/testfiles/pn-languages-polyglossia01.lvt#L5-L8). [I don't recall the details of why I needed to disable this, but I suppose you might know something about it, since you moved the \input{regression-test} line in tests involving polyglossia in this PR]. And extracting the setup to a config file would complicate adjusting to this kind of particular requirement.

What do you think?

muzimuzhi commented 3 months ago

[I don't recall the details of why I needed to disable this, but I suppose you might know something about it, since you moved the \input{regression-test} line in tests involving polyglossia in this PR]

Ya I made some unconventional changes. Usually regression-test.tex is loaded at an early stage and then use \debug_on:n at a latter place, for efficiency considerations could be as late as right before \START.

What I presume why \sys_ensure_backend: is not commonly used is partly because it was not introduced until 2022-07-29. It is identical to \@expl@sys@load@backend@@ used in \document and has some usages in latex3 (mostly l3kernel) tests.

So maybe adding \sys_ensure_backend: to the five test files in which \START come before \begin{document} is more doable?

gusbrs commented 3 months ago

What I presume why \sys_ensure_backend: is not commonly used is partly because it was not introduced until 2022-07-29. It is identical to \@expl@sys@load@backend@@ used in \document and has some usages in latex3 (mostly l3kernel) tests.

Yep, pretty rare, and specialized use. But, indeed, possibly because it is new.

So maybe adding \sys_ensure_backend: to the five test files in which \START come before \begin{document} is more doable?

That's pretty much what I was thinking too. Could you please review the PR in this direction?

gusbrs commented 3 months ago

@muzimuzhi Merged. Once again, thank you very much!

muzimuzhi commented 3 months ago

Oh sorry I missed two tests, due to use of restrictive searching pattern \l__pdf_internal_box. Something like File: l3backend- seems more general.

Update: Hmm nope, they're tests in another repo. 🐱

gusbrs commented 3 months ago

Yup, I just applied the good suggestion to zref-check and postnotes as well. ;-)