-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend PDF-based tests to dvips
#278
Conversation
@@ -7,6 +7,11 @@ this project uses date-based 'snapshot' version identifiers. | |||
|
|||
## [Unreleased] | |||
|
|||
### Added | |||
- Force non-Windows diff program to consider all files to be text files | |||
- Extend PDF-based tests to `dvips` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does l3build
test changes need to be listed in CHANGELOG?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean - that the change may require .tlg
updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the changes only involving "using l3build to test l3build itself"
--[[ FIXME: | ||
- setting specialformats in config-pdf.lua results in "binary" set to "latexdvips" (should be "latex") | ||
- setting specialformats in build.lua disables specifying engine | ||
l3build save -c config-pdf -e latexdvips 00-test-2 | ||
]] | ||
specialformats = specialformats or {} | ||
specialformats["latex"] = specialformats["latex"] or | ||
{ | ||
latexdvips = {binary = "latex", format = ""} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the wired limitations are caused by some l3build
problems, but for now let's just use a way that "works".
@@ -551,6 +551,11 @@ local function normalize_pdf(content) | |||
binary = false | |||
stream = true | |||
stream_content = "stream" .. os_newline | |||
elseif match(line, "/Length %d+>>stream$") then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe ">>stream$"
is enough, but I chose a more strict pattern, mainly to not match a non-stream.
l3experimental | ||
latex-lab | ||
pdfmanagement-testphase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these three packages too experimental to cause less stable test output files?
% needed by dvips (ps2pdf), to normalize pdf metadata | ||
\ifdefined\pdfoutput\ifnum\pdfoutput=0 | ||
\DocumentMetadata{} | ||
\fi\fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditionals are used to limit \DocumentMetadata{}
to dvips
. Otherwise pdftex
and xetex
engines will generate PDFs containing a long, decompressed stream with XML metedata.
(Feels like I should move some of these comments to commit messages.)
Setting
At the moment I can't find a ghostscript cli option acts like the Just for more real cases, here are all the different beginning patterns found in /N 3/Length 8>>stream
/ProcSet [/PDF/ImageB/Text]>>/Length 170>>stream
/Resources<</ProcSet [/PDF/ImageB]>>/Length 107>>stream
/Resources<</ProcSet [/PDF/ImageB]>>/Length 108>>stream
/Resources<</ProcSet [/PDF]>>/Length 8>>stream
/Size[256]/Length 12>>stream
/Subtype /text#2fplain/Length 13>>stream
/Subtype/Type1C/Length 1006>>stream
/Subtype/XML/Length 1144>>stream
/Type/EmbeddedFile/Length 21>>stream
/Type/Metadata/Length 1547>>stream
/yyy(bla)/Length 89>>stream
<</Filter/FlateDecode/Length 172>>stream
>>>>/Length 71>>stream Update: I'm inclined to add |
I have a feeling that This can be done either by adding the option to variable On macOS, $ grep -B 2 -- '-dBATCH' `which ps2pdfwr`
# We have to include the options twice because -I only takes effect if it
# appears before other options.
exec "$GS_EXECUTABLE" $OPTIONS -q -P- -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sstdout=%stderr "-sOutputFile=$outfile" $OPTIONS "$infile" |
This pattern would match pretty generic streams and rely on implementation details regarding spacing in order not to remove something important. That sounds rather fragile. IMO normalization should only happen for data which is known not to be important. |
Yes I too realized the fragility of the new pattern in #278 (comment). But then with the following three pieces of info, I tend to think the new pattern is not as fragile as we may think.
|
Where did we get to here? |
I think this PR can be closed for now. Maybe I'll do another try in the future. The controversial part is, is the new stream match-and-drop logic added to Update: Part of the changes current PR wants to merge has been split in separate PRs which already got merged. |
This PR adds
dvips
chain to the list of check engines use for PDF-based tests, and of course the new test output.With the help from @u-fischer in #274, timestamp metadata in PDFs generated by
ps2pdf
is normalized by adding\DocumentMedadata{}
to tex file, which defines\__pdf_backend_set_regression_data:
to be used byregression-test.tex
.Two by-produces (perhaps they should live in separate PRs, but due to relations with current PR...):
-a
todiff
program call, to make it consider all files to be text files.fc
in Windows is/b
.00-test-2.latexdvips.tpf
, two streams were not normalized. Their beginning marks were/Subtype/Type1C/Length 938>>stream
and/Type/Metadata/Length 1546>>stream
, so I use a strict pattern/Length %d+>>stream
to try to match them. (a sample 00-test-2.latexdvips.tpf.zip)My original purpose was to test against #273, but it ends with findings that
dvips
chain (more specifically, the ghostscript behindps2pdf
) doesn't need the epoch settings in env vars to generate normalized metadata in PDF. Evidence: checks are passed for commit af4950c which reverts #273.The settings are kept, as it does no harm and is used by
dvips
.