2020-01-12 11:52:40 -08:00
|
|
|
testArgs:
|
|
|
|
|
|
|
|
let
|
2020-05-04 02:53:19 -07:00
|
|
|
pkgs = import <nixpkgs> { config = {}; overlays = []; };
|
2020-01-12 11:52:40 -08:00
|
|
|
|
2020-11-18 18:01:44 -08:00
|
|
|
test = (import "${pkgs.path}/nixos/tests/make-test-python.nix") (testArgs pkgs);
|
2020-01-12 11:52:40 -08:00
|
|
|
|
|
|
|
fixedTest = { system ? builtins.currentSystem, ... }@args:
|
|
|
|
let
|
|
|
|
pkgsFixed = pkgs // {
|
2020-02-26 16:28:20 -08:00
|
|
|
# Fix the black Python code formatter that's used in the test to allow the test
|
|
|
|
# script to have longer lines. The default width of 88 chars is too restrictive for
|
|
|
|
# our script.
|
2020-01-12 11:52:40 -08:00
|
|
|
python3Packages = pkgs.python3Packages // {
|
|
|
|
black = pkgs.writeScriptBin "black" ''
|
|
|
|
fileToCheck=''${@:$#}
|
|
|
|
[[ $fileToCheck = *test-script ]] && extraArgs='--line-length 100'
|
|
|
|
exec ${pkgs.python3Packages.black}/bin/black $extraArgs "$@"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2020-11-11 06:12:05 -08:00
|
|
|
test' = test (args // { pkgs = pkgsFixed; });
|
2020-01-12 11:52:40 -08:00
|
|
|
in
|
2020-11-11 06:12:05 -08:00
|
|
|
# See nixpkgs/nixos/lib/testing-python.nix for the original definition
|
|
|
|
test'.overrideAttrs (_: {
|
|
|
|
# 1. Save test output
|
|
|
|
# 2. Add link to driver so that a gcroot to a test prevents the driver from
|
|
|
|
# being garbage-collected
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir $out
|
|
|
|
LOGFILE=$out/output.xml tests='exec(os.environ["testScript"])' ${test'.driver}/bin/nixos-test-driver
|
|
|
|
ln -s ${test'.driver} $out/driver
|
|
|
|
'';
|
|
|
|
}) // { inherit (test') nodes driver; } ;
|
|
|
|
|
2020-01-12 11:52:40 -08:00
|
|
|
in
|
|
|
|
fixedTest
|