nixos/test-driver: add option to add extra python packages to test code

This commit is contained in:
tljuniper 2022-05-23 11:08:13 +02:00
parent 5862243e1a
commit a99736e399
2 changed files with 17 additions and 5 deletions

View file

@ -10,6 +10,7 @@
, socat , socat
, tesseract4 , tesseract4
, vde2 , vde2
, extraPythonPackages ? (_ : [])
}: }:
python3Packages.buildPythonApplication rec { python3Packages.buildPythonApplication rec {
@ -17,8 +18,17 @@ python3Packages.buildPythonApplication rec {
version = "1.1"; version = "1.1";
src = ./.; src = ./.;
propagatedBuildInputs = [ coreutils netpbm python3Packages.colorama python3Packages.ptpython qemu_pkg socat vde2 ] propagatedBuildInputs = [
++ (lib.optionals enableOCR [ imagemagick_light tesseract4 ]); coreutils
netpbm
python3Packages.colorama
python3Packages.ptpython
qemu_pkg
socat
vde2
]
++ (lib.optionals enableOCR [ imagemagick_light tesseract4 ])
++ extraPythonPackages python3Packages;
doCheck = true; doCheck = true;
checkInputs = with python3Packages; [ mypy pylint black ]; checkInputs = with python3Packages; [ mypy pylint black ];

View file

@ -52,12 +52,13 @@ rec {
, skipLint ? false , skipLint ? false
, passthru ? {} , passthru ? {}
, interactive ? false , interactive ? false
, extraPythonPackages ? (_ :[])
}: }:
let let
# Reifies and correctly wraps the python test driver for # Reifies and correctly wraps the python test driver for
# the respective qemu version and with or without ocr support # the respective qemu version and with or without ocr support
testDriver = pkgs.callPackage ./test-driver { testDriver = pkgs.callPackage ./test-driver {
inherit enableOCR; inherit enableOCR extraPythonPackages;
qemu_pkg = qemu_test; qemu_pkg = qemu_test;
imagemagick_light = imagemagick_light.override { inherit libtiff; }; imagemagick_light = imagemagick_light.override { inherit libtiff; };
tesseract4 = tesseract4.override { enableLanguages = [ "eng" ]; }; tesseract4 = tesseract4.override { enableLanguages = [ "eng" ]; };
@ -161,6 +162,7 @@ rec {
(if meta.description or null != null (if meta.description or null != null
then builtins.unsafeGetAttrPos "description" meta then builtins.unsafeGetAttrPos "description" meta
else builtins.unsafeGetAttrPos "testScript" t) else builtins.unsafeGetAttrPos "testScript" t)
, extraPythonPackages ? (_ : [])
} @ t: } @ t:
let let
mkNodes = qemu_pkg: mkNodes = qemu_pkg:
@ -213,13 +215,13 @@ rec {
); );
driver = setupDriverForTest { driver = setupDriverForTest {
inherit testScript enableOCR skipLint passthru; inherit testScript enableOCR skipLint passthru extraPythonPackages;
testName = name; testName = name;
qemu_pkg = pkgs.qemu_test; qemu_pkg = pkgs.qemu_test;
nodes = mkNodes pkgs.qemu_test; nodes = mkNodes pkgs.qemu_test;
}; };
driverInteractive = setupDriverForTest { driverInteractive = setupDriverForTest {
inherit testScript enableOCR skipLint passthru; inherit testScript enableOCR skipLint passthru extraPythonPackages;
testName = name; testName = name;
qemu_pkg = pkgs.qemu; qemu_pkg = pkgs.qemu;
nodes = mkNodes pkgs.qemu; nodes = mkNodes pkgs.qemu;