2018-11-12 22:28:29 +00:00
|
|
|
{ stdenv
|
2018-11-24 17:58:29 +00:00
|
|
|
, lib
|
2018-11-12 22:28:29 +00:00
|
|
|
, sage-with-env
|
|
|
|
, makeWrapper
|
2018-11-24 17:58:29 +00:00
|
|
|
, files ? null # "null" means run all tests
|
|
|
|
, longTests ? true # run tests marked as "long time"
|
2018-11-12 22:28:29 +00:00
|
|
|
}:
|
|
|
|
|
2018-11-24 17:58:29 +00:00
|
|
|
# for a quick test of some source files:
|
|
|
|
# nix-build -E 'with (import ./. {}); sage.tests.override { files = [ "src/sage/misc/cython.py" ];}'
|
|
|
|
|
|
|
|
let
|
|
|
|
src = sage-with-env.env.lib.src;
|
|
|
|
runAllTests = files == null;
|
|
|
|
testArgs = if runAllTests then "--all" else testFileList;
|
|
|
|
patienceSpecifier = if longTests then "--long" else "";
|
|
|
|
relpathToArg = relpath: lib.escapeShellArg "${src}/${relpath}"; # paths need to be absolute
|
|
|
|
testFileList = lib.concatStringsSep " " (map relpathToArg files);
|
|
|
|
in
|
2018-11-12 22:28:29 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
version = src.version;
|
|
|
|
name = "sage-tests-${version}";
|
2018-11-24 17:58:29 +00:00
|
|
|
inherit src;
|
2018-11-12 22:28:29 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
makeWrapper
|
2018-11-24 17:58:29 +00:00
|
|
|
sage-with-env
|
2018-11-12 22:28:29 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
unpackPhase = "#do nothing";
|
|
|
|
configurePhase = "#do nothing";
|
|
|
|
buildPhase = "#do nothing";
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
# This output is not actually needed for anything, the package just
|
|
|
|
# exists to decouple the sage build from its t ests.
|
|
|
|
|
|
|
|
mkdir -p "$out/bin"
|
|
|
|
# Like a symlink, but make sure that $0 points to the original.
|
|
|
|
makeWrapper "${sage-with-env}/bin/sage" "$out/bin/sage"
|
|
|
|
'';
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
export HOME="$TMPDIR/sage-home"
|
|
|
|
mkdir -p "$HOME"
|
|
|
|
|
|
|
|
# "--long" tests are in the order of 1h, without "--long" its 1/2h
|
2018-11-24 17:58:29 +00:00
|
|
|
"sage" -t --nthreads "$NIX_BUILD_CORES" --optional=sage ${patienceSpecifier} ${testArgs}
|
2018-11-12 22:28:29 +00:00
|
|
|
'';
|
|
|
|
}
|