summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorDmitry Kalinkin <dmitry.kalinkin@gmail.com>2021-03-18 20:55:00 -0400
committerDmitry Kalinkin <dmitry.kalinkin@gmail.com>2021-03-18 20:55:35 -0400
commit6829f9e141095512add567a6f0c54c914c6ed7e2 (patch)
tree8e31a70137b6eddf4c60366cef228299acc21af2 /pkgs/test
parent03eb6426afb58c8d58d9aa155dcc3a884e28a031 (diff)
downloadnixpkgs-6829f9e141095512add567a6f0c54c914c6ed7e2.tar
nixpkgs-6829f9e141095512add567a6f0c54c914c6ed7e2.tar.gz
nixpkgs-6829f9e141095512add567a6f0c54c914c6ed7e2.tar.bz2
nixpkgs-6829f9e141095512add567a6f0c54c914c6ed7e2.tar.lz
nixpkgs-6829f9e141095512add567a6f0c54c914c6ed7e2.tar.xz
nixpkgs-6829f9e141095512add567a6f0c54c914c6ed7e2.tar.zst
nixpkgs-6829f9e141095512add567a6f0c54c914c6ed7e2.zip
texlive.bin.dvipng: refactor gs hardcoding, add a test for it
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/texlive/default.nix45
1 files changed, 43 insertions, 2 deletions
diff --git a/pkgs/test/texlive/default.nix b/pkgs/test/texlive/default.nix
index 30d0026c848..7a6affd6cbe 100644
--- a/pkgs/test/texlive/default.nix
+++ b/pkgs/test/texlive/default.nix
@@ -1,4 +1,4 @@
-{ runCommandNoCC, fetchurl, file, texlive }:
+{ runCommandNoCC, fetchurl, file, texlive, writeShellScript }:
 
 {
   chktex = runCommandNoCC "texlive-test-chktex" {
@@ -17,7 +17,7 @@
   '';
 
   # https://github.com/NixOS/nixpkgs/issues/75605
-  dvipng = runCommandNoCC "texlive-test-dvipng" {
+  dvipng.basic = runCommandNoCC "texlive-test-dvipng-basic" {
     nativeBuildInputs = [ file texlive.combined.scheme-medium ];
     input = fetchurl {
       name = "test_dvipng.tex";
@@ -38,6 +38,47 @@
     mv document*.png "$out"/
   '';
 
+  # test dvipng's limited capability to render postscript specials via GS
+  dvipng.ghostscript = runCommandNoCC "texlive-test-ghostscript" {
+    nativeBuildInputs = [ file (with texlive; combine { inherit scheme-small dvipng; }) ];
+    input = builtins.toFile "postscript-sample.tex" ''
+      \documentclass{minimal}
+      \begin{document}
+        Ni
+        \special{ps:
+          newpath
+          0 0 moveto
+          7 7 rlineto
+          0 7 moveto
+          7 -7 rlineto
+          stroke
+          showpage
+        }
+      \end{document}
+    '';
+    gs_trap = writeShellScript "gs_trap.sh" ''
+      exit 1
+    '';
+  } ''
+    cp "$gs_trap" ./gs
+    export PATH=$PWD:$PATH
+    # check that the trap works
+    gs && exit 1
+
+    cp "$input" ./document.tex
+
+    latex document.tex
+    dvipng -T 1in,1in -strict -picky document.dvi
+    for f in document*.png; do
+      file "$f" | tee output
+      grep PNG output
+    done
+
+    mkdir "$out"
+    mv document*.png "$out"/
+  '';
+
+
   # https://github.com/NixOS/nixpkgs/issues/75070
   dvisvgm = runCommandNoCC "texlive-test-dvisvgm" {
     nativeBuildInputs = [ file texlive.combined.scheme-medium ];