2

I want to test whether or not the output of two different compilations of the same .tex file under different circumstances is equal.I first considered compiling to pdf and then comparing the pdf's visually, but decided that I want to compare using more than visual equality.

My second approach was compiling to pdf again and then comparing with the python package filecmp, which compares the two files byte-by-byte. However that gave me the result unequal when I expected them to be equal

I then tried compiling the tex file to dvi. When comparing the two dvi files, it failed initially again, but after adding the \year, \day etc. from this answer, the comparison gave the expected result of equal.

My question is the following: Is byte-wise equality of dvi files a good benchmark for testing whether two compilations were "equal"? And what could be the reason for the comparison of the pdf's failing?

  • 1
    Have you consider using the testing facilities of l3build? – samcarter_is_at_topanswers.xyz Oct 06 '23 at 13:09
  • @samcarter_is_at_topanswers.xyz I have not, since I didn't know about that package. I'm admittedly overwhelmed by the documentation on CTAN. Do you have any tips on where / how to get started with it? – Marc Miller Oct 06 '23 at 13:38
  • 1
    Maybe have a look at https://tug.org/TUGboat/tb43-1/tb133wright-l3build.pdf – samcarter_is_at_topanswers.xyz Oct 06 '23 at 13:44
  • 1
    As you noted, time lapse will result in different values for date and time. If you are using a package that adds one or more UUID (many do, especially with PDF/A and PDF/X) then each instance will have different UUID, and the files will never byte-match. If the document contains certain components (such as EPS converted to PDF, or some image formats) that were externally processed, then those components will differ if they are re-processed, especially on different machines or with different software. Short answer to your question: No, not a good idea. – rallg Oct 06 '23 at 17:40
  • 1
    pdf contains dates and so are typically different between runs. One can setup epoch dates and get identical results (at least over a short time, other things like font numbers often change too if e.g. the format uses another int_array). But if that is the best test for you is unclear as you are not saying what you are trying to test (and when you consider two compilations "equal"). – Ulrike Fischer Oct 06 '23 at 18:50

0 Answers0