From 93855017ba6d46a7e83c289b29defc9e82a24d55 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 26 Mar 2022 11:48:50 -0700 Subject: [PATCH] src/bin/sage: Implement 'sage --pytest' --- src/bin/sage | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/bin/sage b/src/bin/sage index d8432a43c8d..69a157b7d1f 100755 --- a/src/bin/sage +++ b/src/bin/sage @@ -443,6 +443,10 @@ usage_advanced() { echo " --help -- show tox help" command -v tox &>/dev/null || \ echo " (not installed currently, run sage -i tox)" + echo " --pytest [options] -- run pytest on the Sage library" + command -v pytest &>/dev/null || \ + echo " (not installed currently, run sage -i pytest)" + echo " --help -- show pytest help" fi echo echo "Some developer utilities:" @@ -940,10 +944,24 @@ if [ "$1" = '-tox' -o "$1" = '--tox' ]; then if command -v tox >/dev/null ; then exec tox -c "$SAGE_SRC" "$@" else - echo "Run sage -i tox to install" + echo "Run 'sage -i tox' to install" fi else - echo >&2 "error: Sage source directory or tox.ini not avialable" + echo >&2 "error: Sage source directory or tox.ini not available" + exit 1 + fi +fi + +if [ "$1" = '-pytest' -o "$1" = '--pytest' ]; then + shift + if [ -n "$SAGE_SRC" -a -f "$SAGE_SRC/tox.ini" ]; then + if command -v pytest >/dev/null ; then + exec pytest --rootdir="$SAGE_SRC" --import-mode importlib "$@" + else + echo "Run 'sage -i pytest' to install" + fi + else + echo >&2 "error: Sage source directory or tox.ini not available" exit 1 fi fi