diff options
author | Marijan Petričević <marijan.petricevic94@gmail.com> | 2021-12-06 12:49:23 +0000 |
---|---|---|
committer | Marijan Petričević <marijan.petricevic94@gmail.com> | 2021-12-10 12:27:45 +0000 |
commit | ab693de868e1a0e6e75fd31027b165dce8420c73 (patch) | |
tree | 163f8712e960149879dcd6158e4aa28156aabdab /nixos/lib/testing-python.nix | |
parent | 61727e0e57e73113aca16981ea00275b299fbf94 (diff) |
nixos/test-driver: make the test-driver a python package
Diffstat (limited to 'nixos/lib/testing-python.nix')
-rw-r--r-- | nixos/lib/testing-python.nix | 73 |
1 files changed, 11 insertions, 62 deletions
diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index 4306d102b2d64..365e22714573e 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -16,65 +16,6 @@ rec { inherit pkgs; - # Reifies and correctly wraps the python test driver for - # the respective qemu version and with or without ocr support - pythonTestDriver = { - qemu_pkg ? pkgs.qemu_test - , enableOCR ? false - }: - let - name = "nixos-test-driver"; - testDriverScript = ./test-driver/test-driver.py; - ocrProg = tesseract4.override { enableLanguages = [ "eng" ]; }; - imagemagick_tiff = imagemagick_light.override { inherit libtiff; }; - in stdenv.mkDerivation { - inherit name; - - nativeBuildInputs = [ makeWrapper ]; - buildInputs = [ (python3.withPackages (p: [ p.ptpython p.colorama ])) ]; - checkInputs = with python3Packages; [ pylint black mypy ]; - - dontUnpack = true; - - preferLocalBuild = true; - - buildPhase = '' - python <<EOF - from pydoc import importfile - with open('driver-symbols', 'w') as fp: - t = importfile('${testDriverScript}') - d = t.Driver([],[],"") - test_symbols = d.test_symbols() - fp.write(','.join(test_symbols.keys())) - EOF - ''; - - doCheck = true; - checkPhase = '' - mypy --disallow-untyped-defs \ - --no-implicit-optional \ - --ignore-missing-imports ${testDriverScript} - pylint --errors-only ${testDriverScript} - black --check --diff ${testDriverScript} - ''; - - installPhase = - '' - mkdir -p $out/bin - cp ${testDriverScript} $out/bin/nixos-test-driver - chmod u+x $out/bin/nixos-test-driver - # TODO: copy user script part into this file (append) - - wrapProgram $out/bin/nixos-test-driver \ - --argv0 ${name} \ - --prefix PATH : "${lib.makeBinPath [ qemu_pkg vde2 netpbm coreutils socat ]}" \ - ${lib.optionalString enableOCR - "--prefix PATH : '${ocrProg}/bin:${imagemagick_tiff}/bin'"} \ - - install -m 0644 -vD driver-symbols $out/nix-support/driver-symbols - ''; - }; - # Run an automated test suite in the given virtual network. runTests = { driver, pos }: stdenv.mkDerivation { @@ -112,8 +53,15 @@ rec { , passthru ? {} }: let - # FIXME: get this pkg from the module system - testDriver = pythonTestDriver { inherit qemu_pkg enableOCR;}; + # Reifies and correctly wraps the python test driver for + # the respective qemu version and with or without ocr support + testDriver = pkgs.callPackage ./test-driver { + inherit enableOCR; + qemu_pkg = qemu_test; + imagemagick_light = imagemagick_light.override { inherit libtiff; }; + tesseract4 = tesseract4.override { enableLanguages = [ "eng" ]; }; + }; + testDriverName = let @@ -178,10 +126,11 @@ rec { echo -n "$testScript" > $out/test-script ln -s ${testDriver}/bin/nixos-test-driver $out/bin/nixos-test-driver + ${testDriver}/bin/generate-driver-symbols ${lib.optionalString (!skipLint) '' PYFLAKES_BUILTINS="$( echo -n ${lib.escapeShellArg (lib.concatStringsSep "," nodeHostNames)}, - < ${lib.escapeShellArg "${testDriver}/nix-support/driver-symbols"} + < ${lib.escapeShellArg "driver-symbols"} )" ${python3Packages.pyflakes}/bin/pyflakes $out/test-script ''} |