Newer
Older
let
sources = import nix/sources.nix;
in
{ pkgs ? import sources.release2105 {}
, pypiData ? sources.pypi-deps-db
, mach-nix ? import sources.mach-nix { inherit pkgs pypiData; }
, tahoe-lafs-source ? "tahoe-lafs"
, tahoe-lafs-repo ? sources.${tahoe-lafs-source}
, privatestorage ? import ./. {
inherit pkgs pypiData mach-nix;
inherit tahoe-lafs-repo;
}
, hypothesisProfile ? null
, collectCoverage ? false
, testSuite ? null
, trialArgs ? null
,
inherit (pkgs) lib;
inherit (privatestorage) zkapauthorizer;
hypothesisProfile' = if hypothesisProfile == null then "default" else hypothesisProfile;
defaultTrialArgs = [ "--rterrors" ] ++ (lib.optional (! collectCoverage) "--jobs=$NIX_BUILD_CORES");
trialArgs' = if trialArgs == null then defaultTrialArgs else trialArgs;
extraTrialArgs = builtins.concatStringsSep " " trialArgs';
testSuite' = if testSuite == null then "_zkapauthorizer" else testSuite;
python = mach-nix.mkPython {
inherit (zkapauthorizer.meta.mach-nix) python providers;
requirements =
packagesExtra = [ zkapauthorizer ];
_.hypothesis.postUnpack = "";
};
lint-python = mach-nix.mkPython {
python = "python39";
requirements = ''
isort
black
'';
};
pkgs.runCommand "zkapauthorizer-tests" {
passthru = {
inherit python;
};
} ''
${lint-python}/bin/black --check src
${lint-python}/bin/isort --check src
ZKAPAUTHORIZER_HYPOTHESIS_PROFILE=${hypothesisProfile'} ${python}/bin/python -m ${if collectCoverage
then "coverage run --debug=config --rcfile=${zkapauthorizer.src}/.coveragerc --module"
else ""
} twisted.trial ${extraTrialArgs} ${testSuite'}
''
mkdir -p "$out/coverage"
cp -v .coverage.* "$out/coverage"
''
}