ghostscript
The atago project wrote these specs on its own initiative and runs them in its own CI, to exercise atago against a real program. They are not ghostscript’s official test suite, and the ghostscript project is not affiliated with atago.
Summary #
1 suite · 10 scenarios
Contents #
- Ghostscript (PostScript and PDF pipeline) — 10 scenarios
- PostScript becomes a PDF with the pages and text it declared
- a DOCINFO pdfmark reaches the Info dictionary
- selecting one page keeps that page’s text and drops the other
- merging two documents yields the sum of their pages
- txtwrite agrees with the text inside the PDF
- rasterizing a page produces an image of the requested size
- converting the same input twice yields the same text
- a missing input fails, naming the file on stdout
- a failed conversion still leaves a PDF behind
- an unknown device is refused
Ghostscript (PostScript and PDF pipeline) #
Ghostscript turns PostScript into PDF, PDF
into text, and PDF into raster images. Its output is the kind a test usually
gives up on — a binary document — so this suite asserts the document itself:
page count, the text really inside it, and the Info-dictionary metadata,
with pdf:; and the rasterized page with image:.
The relationships are pinned, not just single outputs: selecting one page of a two-page document yields exactly that page’s text and not the other’s, merging two documents yields the sum of their pages, and converting the same input twice yields the same extracted text. The input PostScript is written by the spec, so nothing third-party is committed.
One honest surprise is recorded as a scenario: a failed conversion still leaves a PDF behind. That is Ghostscript’s behavior, not a recommendation.
Source: test/e2e/thirdparty/ghostscript/ghostscript.atago.yaml
Scenario: PostScript becomes a PDF with the pages and text it declared #
only when gs --version succeeds
Given #
- Fixture file
doc.psis created. - The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture doc.ps:
%!PS-Adobe-3.0
/Helvetica findfont 24 scalefont setfont
72 720 moveto (Quarterly earnings report) show
showpage
/Helvetica findfont 18 scalefont setfont
72 700 moveto (Appendix and totals) show
showpage
When #
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o out.pdf doc.ps
Then #
- exit code is
0 - the step changed exactly created
out.pdf, modified nothing, deleted nothing - pdf
out.pdf2 pages - pdf
out.pdftext containsQuarterly earnings report,Appendix and totals
Scenario: a DOCINFO pdfmark reaches the Info dictionary #
only when gs --version succeeds
Given #
- Fixture file
doc.psis created.
Inputs #
Fixture doc.ps:
%!PS-Adobe-3.0
/Helvetica findfont 24 scalefont setfont
72 720 moveto (Report body) show
showpage
When #
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o titled.pdf -c "[/Title (Quarterly Report) /Author (atago) /DOCINFO pdfmark" -f doc.ps
Then #
- exit code is
0 - pdf
titled.pdfauthor containsatago, title containsQuarterly Report - pdf
titled.pdfproducer containsGhostscript
Scenario: selecting one page keeps that page’s text and drops the other #
only when gs --version succeeds
Given #
- Fixture file
doc.psis created.
Inputs #
Fixture doc.ps:
%!PS-Adobe-3.0
/Helvetica findfont 24 scalefont setfont
72 720 moveto (First page marker) show
showpage
72 720 moveto (Second page marker) show
showpage
When #
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o whole.pdf doc.ps
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dFirstPage=2 -dLastPage=2 -o second.pdf whole.pdf
Then #
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o whole.pdf doc.ps:- exit code is
0 - pdf
whole.pdf2 pages
- exit code is
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dFirstPage=2 -dLastPage=2 -o second.pdf whole.pdf:- exit code is
0 - pdf
second.pdf1 page - pdf
second.pdftext containsSecond page marker - pdf
second.pdftext does not containFirst page marker
- exit code is
Scenario: merging two documents yields the sum of their pages #
only when gs --version succeeds
Given #
- Fixture file
one.psis created. - Fixture file
two.psis created.
Inputs #
Fixture one.ps:
%!PS-Adobe-3.0
/Helvetica findfont 24 scalefont setfont
72 720 moveto (Document one) show
showpage
Fixture two.ps:
%!PS-Adobe-3.0
/Helvetica findfont 24 scalefont setfont
72 720 moveto (Document two page A) show
showpage
72 700 moveto (Document two page B) show
showpage
When #
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o one.pdf one.ps
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o two.pdf two.ps
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o merged.pdf one.pdf two.pdf
Then #
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o one.pdf one.ps:- exit code is
0 - pdf
one.pdf1 page
- exit code is
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o two.pdf two.ps:- exit code is
0 - pdf
two.pdf2 pages
- exit code is
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o merged.pdf one.pdf two.pdf:- exit code is
0 - pdf
merged.pdf3 pages - pdf
merged.pdftext containsDocument one,Document two page A,Document two page B
- exit code is
Scenario: txtwrite agrees with the text inside the PDF #
only when gs --version succeeds
Given #
- Fixture file
doc.psis created.
Inputs #
Fixture doc.ps:
%!PS-Adobe-3.0
/Helvetica findfont 24 scalefont setfont
72 720 moveto (Extractable sentence) show
showpage
When #
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o out.pdf doc.ps
gs -q -dNOPAUSE -dBATCH -sDEVICE=txtwrite -o extracted.txt out.pdf
Then #
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o out.pdf doc.ps:- exit code is
0 - pdf
out.pdftext containsExtractable sentence
- exit code is
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=txtwrite -o extracted.txt out.pdf:- exit code is
0 - file
extracted.txtcontainsExtractable sentence
- exit code is
Scenario: rasterizing a page produces an image of the requested size #
only when gs --version succeeds
Given #
- Fixture file
doc.psis created.
Inputs #
Fixture doc.ps:
%!PS-Adobe-3.0
<< /PageSize [200 100] >> setpagedevice
/Helvetica findfont 12 scalefont setfont
20 50 moveto (Raster me) show
showpage
When #
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o out.pdf doc.ps
gs -q -dNOPAUSE -dBATCH -sDEVICE=png16m -r72 -o page.png out.pdf
gs -q -dNOPAUSE -dBATCH -sDEVICE=png16m -r144 -o page2x.png out.pdf
Then #
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o out.pdf doc.ps:- exit code is
0
- exit code is
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=png16m -r72 -o page.png out.pdf:- exit code is
0 - image
page.pngispng, width 200, height 100
- exit code is
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=png16m -r144 -o page2x.png out.pdf:- exit code is
0 - image
page2x.pngwidth 400, height 200
- exit code is
Generated artifacts #
page.pngpage2x.png
Scenario: converting the same input twice yields the same text #
only when gs --version succeeds
Given #
- Fixture file
doc.psis created.
Inputs #
Fixture doc.ps:
%!PS-Adobe-3.0
/Helvetica findfont 24 scalefont setfont
72 720 moveto (Deterministic content) show
showpage
When #
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o first.pdf doc.ps
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o second.pdf doc.ps
gs -q -dNOPAUSE -dBATCH -sDEVICE=txtwrite -o first.txt first.pdf
gs -q -dNOPAUSE -dBATCH -sDEVICE=txtwrite -o second.txt second.pdf
Then #
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o first.pdf doc.ps:- exit code is
0
- exit code is
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o second.pdf doc.ps:- exit code is
0
- exit code is
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=txtwrite -o first.txt first.pdf:- exit code is
0
- exit code is
- after
gs -q -dNOPAUSE -dBATCH -sDEVICE=txtwrite -o second.txt second.pdf:- exit code is
0 - file
second.txtis byte-identical tofirst.txt
- exit code is
Scenario: a missing input fails, naming the file on stdout #
only when gs --version succeeds
When #
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o out.pdf no-such-input.ps
Then #
- exit code is
1 - stdout contains
undefinedfilename,no-such-input.ps - stderr contains
Unrecoverable error
Scenario: a failed conversion still leaves a PDF behind #
only when gs --version succeeds
Given #
- Fixture file
broken.psis created.
Inputs #
Fixture broken.ps:
this is not postscript {{{
When #
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -o out.pdf broken.ps
Then #
- exit code is
1 - stderr contains
Unrecoverable error - pdf
out.pdf1 page - pdf
out.pdftext does not containthis is not postscript
Scenario: an unknown device is refused #
only when gs --version succeeds
Given #
- Fixture file
doc.psis created.
Inputs #
Fixture doc.ps:
%!PS-Adobe-3.0
/Helvetica findfont 24 scalefont setfont
72 720 moveto (body) show
showpage
When #
gs -q -dNOPAUSE -dBATCH -sDEVICE=notadevice -o out.any doc.ps
Then #
- exit code is not
0 - stdout contains
Unknown device: notadevice