Skip to content

Commit

Permalink
nix: introduce single-page tests
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Mar 20, 2023
1 parent 865b397 commit 8419d4c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# When doing development you may want to shut this off to obtain the
# output file that you need to check in.
, doOutputDiff ? true
# Attempts to render every page individually to make sure the dependencies
# are set correctly.
, doPageChecks ? true
}:

let
Expand Down Expand Up @@ -204,15 +207,37 @@ in
stdenv.mkDerivation {
name = "codex32${shortId}";

buildInputs = if doPdfGeneration then [ ghostscript ] else [ ];
buildInputs = [ ghostscript ];

phases = [ "buildPhase" ];
buildPhase = ''
set -e
ghostscriptTest() {
echo "Ghostscript testing $1"
local output;
if ! output="$(gs -dNOPAUSE -dNODISPLAY "$1" < /dev/null 2>&1)"; then
echo "Failed to run ghostscript on $1"
echo "$output"
exit 1
fi
}
'' + lib.optionalString doPageChecks toString (
map
(page:
let
pageFile = renderBooklet
{
name = "test-single-page.ps";
pages = [ page ];
};
in "ghostscriptTest ${pageFile}\n")
fullBooklet.pages) + ''
FULL_BW="${renderBooklet fullBooklet}"
ghostscriptTest "$FULL_BW"
mkdir "$out"
cd "$out"
cp ${renderBooklet fullBooklet} SSS32.ps
cp "$FULL_BW" SSS32.ps
${lib.optionalString doOutputDiff "diff -C 5 ${src}/SSS32.ps SSS32.ps"}
sed -i 's/(revision \(.*\))/(revision \1${shortId})/' ./SSS32.ps
Expand Down

0 comments on commit 8419d4c

Please sign in to comment.