2020-01-12 19:52:40 +00:00
|
|
|
testArgs:
|
|
|
|
|
|
|
|
let
|
|
|
|
pkgs = import <nixpkgs> { config = {}; overlays = []; };
|
2020-01-13 09:39:19 +00:00
|
|
|
unstable = (import ../pkgs/nixpkgs-pinned.nix).nixpkgs-unstable;
|
2020-01-12 19:52:40 +00:00
|
|
|
|
|
|
|
# Stable nixpkgs doesn't yet include the Python testing framework.
|
|
|
|
# Use unstable nixpkgs and patch it so that it uses stable nixpkgs for the VM
|
|
|
|
# machine configuration.
|
2020-01-13 09:39:19 +00:00
|
|
|
testingPkgs =
|
2020-01-12 19:52:40 +00:00
|
|
|
pkgs.runCommand "nixpkgs-testing" {} ''
|
2020-01-13 09:39:19 +00:00
|
|
|
cp -r ${unstable} $out
|
2020-01-12 19:52:40 +00:00
|
|
|
cd $out
|
|
|
|
chmod +w -R .
|
|
|
|
patch -p1 < ${./use-stable-pkgs.patch}
|
|
|
|
'';
|
|
|
|
|
|
|
|
test = (import "${testingPkgs}/nixos/tests/make-test-python.nix") testArgs;
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
fixedTest = { system ? builtins.currentSystem, ... }@args:
|
|
|
|
let
|
|
|
|
pkgs = (import testingPkgs { inherit system; config = {}; overlays = []; } );
|
|
|
|
pkgsFixed = pkgs // {
|
|
|
|
python3Packages = pkgs.python3Packages // {
|
|
|
|
black = pkgs.writeScriptBin "black" ''
|
|
|
|
fileToCheck=''${@:$#}
|
|
|
|
[[ $fileToCheck = *test-script ]] && extraArgs='--line-length 100'
|
|
|
|
exec ${pkgs.python3Packages.black}/bin/black $extraArgs "$@"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
test (args // { pkgs = pkgsFixed; });
|
|
|
|
in
|
|
|
|
fixedTest
|