Skip to content

Commit 8419d4c

Browse files
committed
nix: introduce single-page tests
1 parent 865b397 commit 8419d4c

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

default.nix

+27-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
# When doing development you may want to shut this off to obtain the
99
# output file that you need to check in.
1010
, doOutputDiff ? true
11+
# Attempts to render every page individually to make sure the dependencies
12+
# are set correctly.
13+
, doPageChecks ? true
1114
}:
1215

1316
let
@@ -204,15 +207,37 @@ in
204207
stdenv.mkDerivation {
205208
name = "codex32${shortId}";
206209

207-
buildInputs = if doPdfGeneration then [ ghostscript ] else [ ];
210+
buildInputs = [ ghostscript ];
208211

209212
phases = [ "buildPhase" ];
210213
buildPhase = ''
211214
set -e
212215
216+
ghostscriptTest() {
217+
echo "Ghostscript testing $1"
218+
local output;
219+
if ! output="$(gs -dNOPAUSE -dNODISPLAY "$1" < /dev/null 2>&1)"; then
220+
echo "Failed to run ghostscript on $1"
221+
echo "$output"
222+
exit 1
223+
fi
224+
}
225+
'' + lib.optionalString doPageChecks toString (
226+
map
227+
(page:
228+
let
229+
pageFile = renderBooklet
230+
{
231+
name = "test-single-page.ps";
232+
pages = [ page ];
233+
};
234+
in "ghostscriptTest ${pageFile}\n")
235+
fullBooklet.pages) + ''
236+
FULL_BW="${renderBooklet fullBooklet}"
237+
ghostscriptTest "$FULL_BW"
213238
mkdir "$out"
214239
cd "$out"
215-
cp ${renderBooklet fullBooklet} SSS32.ps
240+
cp "$FULL_BW" SSS32.ps
216241
217242
${lib.optionalString doOutputDiff "diff -C 5 ${src}/SSS32.ps SSS32.ps"}
218243
sed -i 's/(revision \(.*\))/(revision \1${shortId})/' ./SSS32.ps

0 commit comments

Comments
 (0)