nixos/tests/cups-pdf: migration to runTest
https://github.com/NixOS/nixpkgs/issues/386873
This commit is contained in:
@@ -343,7 +343,7 @@ in
|
|||||||
crabfit = handleTest ./crabfit.nix { };
|
crabfit = handleTest ./crabfit.nix { };
|
||||||
cri-o = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./cri-o.nix { };
|
cri-o = handleTestOn [ "aarch64-linux" "x86_64-linux" ] ./cri-o.nix { };
|
||||||
cryptpad = runTest ./cryptpad.nix;
|
cryptpad = runTest ./cryptpad.nix;
|
||||||
cups-pdf = handleTest ./cups-pdf.nix { };
|
cups-pdf = runTest ./cups-pdf.nix;
|
||||||
curl-impersonate = handleTest ./curl-impersonate.nix { };
|
curl-impersonate = handleTest ./curl-impersonate.nix { };
|
||||||
custom-ca = handleTest ./custom-ca.nix { };
|
custom-ca = handleTest ./custom-ca.nix { };
|
||||||
croc = handleTest ./croc.nix { };
|
croc = handleTest ./croc.nix { };
|
||||||
|
|||||||
@@ -1,47 +1,45 @@
|
|||||||
import ./make-test-python.nix (
|
{ hostPkgs, lib, ... }:
|
||||||
{ lib, pkgs, ... }:
|
{
|
||||||
{
|
name = "cups-pdf";
|
||||||
name = "cups-pdf";
|
|
||||||
|
|
||||||
nodes.machine =
|
nodes.machine =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
imports = [ ./common/user-account.nix ];
|
imports = [ ./common/user-account.nix ];
|
||||||
environment.systemPackages = [ pkgs.poppler-utils ];
|
environment.systemPackages = [ pkgs.poppler-utils ];
|
||||||
fonts.packages = [ pkgs.dejavu_fonts ]; # yields more OCR-able pdf
|
fonts.packages = [ pkgs.dejavu_fonts ]; # yields more OCR-able pdf
|
||||||
services.printing.cups-pdf.enable = true;
|
services.printing.cups-pdf.enable = true;
|
||||||
services.printing.cups-pdf.instances = {
|
services.printing.cups-pdf.instances = {
|
||||||
opt = { };
|
opt = { };
|
||||||
noopt.installPrinter = false;
|
noopt.installPrinter = false;
|
||||||
};
|
|
||||||
hardware.printers.ensurePrinters = [
|
|
||||||
{
|
|
||||||
name = "noopt";
|
|
||||||
model = "CUPS-PDF_noopt.ppd";
|
|
||||||
deviceUri = "cups-pdf:/noopt";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
hardware.printers.ensurePrinters = [
|
||||||
|
{
|
||||||
|
name = "noopt";
|
||||||
|
model = "CUPS-PDF_noopt.ppd";
|
||||||
|
deviceUri = "cups-pdf:/noopt";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# we cannot check the files with pdftotext, due to
|
# we cannot check the files with pdftotext, due to
|
||||||
# https://github.com/alexivkin/CUPS-PDF-to-PDF/issues/7
|
# https://github.com/alexivkin/CUPS-PDF-to-PDF/issues/7
|
||||||
# we need `imagemagickBig` as it has ghostscript support
|
# we need `imagemagickBig` as it has ghostscript support
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
from subprocess import run
|
from subprocess import run
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
for name in ("opt", "noopt"):
|
for name in ("opt", "noopt"):
|
||||||
text = f"test text {name}".upper()
|
text = f"test text {name}".upper()
|
||||||
machine.wait_until_succeeds(f"lpstat -v {name}")
|
machine.wait_until_succeeds(f"lpstat -v {name}")
|
||||||
machine.succeed(f"su - alice -c 'echo -e \"\n {text}\" | lp -d {name}'")
|
machine.succeed(f"su - alice -c 'echo -e \"\n {text}\" | lp -d {name}'")
|
||||||
# wait until the pdf files are completely produced and readable by alice
|
# wait until the pdf files are completely produced and readable by alice
|
||||||
machine.wait_until_succeeds(f"su - alice -c 'pdfinfo /var/spool/cups-pdf-{name}/users/alice/*.pdf'")
|
machine.wait_until_succeeds(f"su - alice -c 'pdfinfo /var/spool/cups-pdf-{name}/users/alice/*.pdf'")
|
||||||
machine.succeed(f"cp /var/spool/cups-pdf-{name}/users/alice/*.pdf /tmp/{name}.pdf")
|
machine.succeed(f"cp /var/spool/cups-pdf-{name}/users/alice/*.pdf /tmp/{name}.pdf")
|
||||||
machine.copy_from_vm(f"/tmp/{name}.pdf", "")
|
machine.copy_from_vm(f"/tmp/{name}.pdf", "")
|
||||||
run(f"${pkgs.imagemagickBig}/bin/convert -density 300 $out/{name}.pdf $out/{name}.jpeg", shell=True, check=True)
|
run(f"${hostPkgs.imagemagickBig}/bin/convert -density 300 $out/{name}.pdf $out/{name}.jpeg", shell=True, check=True)
|
||||||
assert text.encode() in run(f"${lib.getExe pkgs.tesseract} $out/{name}.jpeg stdout", shell=True, check=True, capture_output=True).stdout
|
assert text.encode() in run(f"${lib.getExe hostPkgs.tesseract} $out/{name}.jpeg stdout", shell=True, check=True, capture_output=True).stdout
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta.maintainers = [ lib.maintainers.yarny ];
|
meta.maintainers = [ lib.maintainers.yarny ];
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user