mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-07 02:46:49 +00:00
Allow the test package to run unit or integration tests
This commit is contained in:
parent
9393c9ad10
commit
c17341c2d9
@ -410,7 +410,7 @@ jobs:
|
||||
--cores 8 \
|
||||
--argstr pkgsVersion "nixpkgs-<<parameters.nixpkgs>>" \
|
||||
--argstr pythonVersion "<<parameters.pythonVersion>>" \
|
||||
nix/tests.nix
|
||||
nix/unittests.nix
|
||||
|
||||
typechecks:
|
||||
docker:
|
||||
|
@ -44,6 +44,4 @@ callPackage ./nix/tahoe-lafs.nix {
|
||||
# symlink, etc) as possible to avoid needing to re-build when files that
|
||||
# make no difference to the package have changed.
|
||||
tahoe-lafs-src = pkgs.lib.cleanSource ./.;
|
||||
|
||||
doCheck = false;
|
||||
}
|
||||
|
5
nix/integrationtests.nix
Normal file
5
nix/integrationtests.nix
Normal file
@ -0,0 +1,5 @@
|
||||
# Build the package with the integration test suite enabled.
|
||||
args@{...}:
|
||||
(import ./tests.nix args).override {
|
||||
checks = [ "integration" ];
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
, extrasNames
|
||||
|
||||
# control how the test suite is run
|
||||
, doCheck
|
||||
, checks ? []
|
||||
}:
|
||||
let
|
||||
pname = "tahoe-lafs";
|
||||
@ -57,17 +57,77 @@ let
|
||||
testtools
|
||||
];
|
||||
|
||||
integrationTestDependencies = with pythonPackages; [
|
||||
html5lib
|
||||
paramiko
|
||||
pytest
|
||||
pytest-timeout
|
||||
pytest-twisted
|
||||
];
|
||||
|
||||
doUnit = builtins.elem "unit" checks;
|
||||
doIntegration = builtins.elem "integration" checks;
|
||||
in
|
||||
buildPythonPackage {
|
||||
buildPythonPackage rec {
|
||||
inherit pname version;
|
||||
src = tahoe-lafs-src;
|
||||
|
||||
# Supply all of the build and runtime dependencies.
|
||||
propagatedBuildInputs = pythonPackageDependencies;
|
||||
|
||||
inherit doCheck;
|
||||
checkInputs = unitTestDependencies;
|
||||
checkPhase = ''
|
||||
# The source doesn't include version information - so dump some in
|
||||
# to it here.
|
||||
postPatch =
|
||||
let
|
||||
versionContent = builtins.toFile "_version.py" ''
|
||||
# This _version.py is generated by tahoe-lafs.nix.
|
||||
|
||||
__pkgname__ = "tahoe-lafs"
|
||||
|
||||
# TODO: We can have more metadata after we switch to flakes.
|
||||
# Then the `self` input will have a `sourceInfo` attribute telling us
|
||||
# things like git revision, a revision counter, etc.
|
||||
real_version = "${version}.post1"
|
||||
full_version = real_version
|
||||
branch = "master"
|
||||
verstr = real_version
|
||||
__version__ = verstr
|
||||
'';
|
||||
in
|
||||
''
|
||||
cp ${versionContent} src/allmydata/_version.py
|
||||
'';
|
||||
|
||||
# If either kind of check is enabled, run checks.
|
||||
doCheck = doUnit || doIntegration;
|
||||
|
||||
# Checks run at build time so check inputs are "native" (they run on
|
||||
# the build host). Give all of the build and runtime dependencies
|
||||
# as well as all of the additional test-only dependencies (for
|
||||
# whichever test suites are enabled).
|
||||
nativeCheckInputs = propagatedBuildInputs ++ (
|
||||
lib.optionals (doUnit || doIntegration) unitTestDependencies ++
|
||||
lib.optionals doIntegration integrationTestDependencies
|
||||
);
|
||||
|
||||
# Our own command line tool, tahoe, will not be on PATH yet but the
|
||||
# test suite may try to use it - so put it there. We can also do
|
||||
# other general test environment setup here.
|
||||
preCheck = ''
|
||||
PATH=$out/bin:$PATH
|
||||
type -p flogtool || (echo "flogtool missing" && exit 1)
|
||||
type -p tahoe || (echo "tahoe missing" && exit 1)
|
||||
export TAHOE_LAFS_HYPOTHESIS_PROFILE=ci
|
||||
python -m twisted.trial -j $NIX_BUILD_CORES allmydata
|
||||
echo "PATH: $PATH"
|
||||
'';
|
||||
|
||||
# Define how the tests are run. Include commands for whichever test
|
||||
# suites are enabled. Also be sure to let check hooks run.
|
||||
checkPhase = ''
|
||||
runHook preCheck
|
||||
${lib.optionalString doUnit "python -m twisted.trial -j $NIX_BUILD_CORES allmydata"}
|
||||
${lib.optionalString doIntegration "python -m pytest --timeout=1800 -s -v integration"}
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
|
@ -1,4 +1,5 @@
|
||||
# Build the package with the test suite enabled.
|
||||
args@{...}: (import ../. args).override {
|
||||
doCheck = true;
|
||||
# Build the package with the whole test suite enabled.
|
||||
args@{ checks ? [ "unit" "integration" ], ...}:
|
||||
(import ../. (builtins.removeAttrs args [ "checks" ])).override {
|
||||
inherit checks;
|
||||
}
|
||||
|
5
nix/unittests.nix
Normal file
5
nix/unittests.nix
Normal file
@ -0,0 +1,5 @@
|
||||
# Build the package with the unit test suite enabled.
|
||||
args@{...}:
|
||||
(import ./tests.nix args).override {
|
||||
checks = [ "unit" ];
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user