diff --git a/pkgs/applications/science/math/sage/sage-tests.nix b/pkgs/applications/science/math/sage/sage-tests.nix index feccf75a7ac..12433e12fe9 100644 --- a/pkgs/applications/science/math/sage/sage-tests.nix +++ b/pkgs/applications/science/math/sage/sage-tests.nix @@ -3,7 +3,12 @@ , sage-with-env , makeWrapper , files ? null # "null" means run all tests -, longTests ? true # run tests marked as "long time" +, longTests ? true # run tests marked as "long time" (roughly doubles runtime) +# Run as many tests as possible in approximately n seconds. This will give each +# file to test a "time budget" and stop tests if it is exceeded. 300 is the +# upstream default value. +# https://trac.sagemath.org/ticket/25270 for details. +, timeLimit ? null }: # for a quick test of some source files: @@ -14,6 +19,7 @@ let runAllTests = files == null; testArgs = if runAllTests then "--all" else testFileList; patienceSpecifier = if longTests then "--long" else ""; + timeSpecifier = if timeLimit == null then "" else "--short ${toString timeLimit}"; relpathToArg = relpath: lib.escapeShellArg "${src}/${relpath}"; # paths need to be absolute testFileList = lib.concatStringsSep " " (map relpathToArg files); in @@ -45,7 +51,7 @@ stdenv.mkDerivation rec { export HOME="$TMPDIR/sage-home" mkdir -p "$HOME" - # "--long" tests are in the order of 1h, without "--long" its 1/2h - "sage" -t --nthreads "$NIX_BUILD_CORES" --optional=sage ${patienceSpecifier} ${testArgs} + echo "Running sage tests with arguments ${timeSpecifier} ${patienceSpecifier} ${testArgs}" + "sage" -t --nthreads "$NIX_BUILD_CORES" --optional=sage ${timeSpecifier} ${patienceSpecifier} ${testArgs} ''; } diff --git a/pkgs/applications/science/math/sage/sage.nix b/pkgs/applications/science/math/sage/sage.nix index ac255643a34..541b9cb36dc 100644 --- a/pkgs/applications/science/math/sage/sage.nix +++ b/pkgs/applications/science/math/sage/sage.nix @@ -54,6 +54,7 @@ stdenv.mkDerivation rec { passthru = { tests = sage-tests; + quicktest = sage-tests.override { longTests = false; timeLimit = 600; }; # as many tests as possible in ~10m doc = sagedoc; lib = sage-with-env.env.lib; kernelspec = jupyter-kernel-definition;