Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage/doctest/control.py, src/bin/sage-runtests: Implement sage -t…
Browse files Browse the repository at this point in the history
… --installed
  • Loading branch information
Matthias Koeppe committed Feb 24, 2022
1 parent 15c8011 commit de649be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/bin/sage-runtests
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if __name__ == "__main__":
parser.add_argument("-T", "--timeout", type=int, default=-1, help="timeout (in seconds) for doctesting one file, 0 for no timeout")
what = parser.add_mutually_exclusive_group()
what.add_argument("-a", "--all", action="store_true", default=False, help="test all files in the Sage library")
what.add_argument("--installed", action="store_true", default=False, help="test all installed modules of the Sage library")
parser.add_argument("--logfile", type=argparse.FileType('a'), metavar="FILE", help="log all output to FILE")

parser.add_argument("-l", "--long", action="store_true", default=False, help="include lines with the phrase 'long time'")
Expand Down Expand Up @@ -119,7 +120,7 @@ if __name__ == "__main__":
in_filenames = False
afterlog = False
for arg in sys.argv[1:]:
if arg in ('-n', '--new', '-a', '--all'):
if arg in ('-n', '--new', '-a', '--all', '--installed'):
need_filenames = False
elif need_filenames and not (afterlog or in_filenames) and os.path.exists(arg):
in_filenames = True
Expand All @@ -129,8 +130,8 @@ if __name__ == "__main__":

args = parser.parse_args(new_arguments)

if not args.filenames and not (args.all or args.new):
print('either use --new or --all or some filenames')
if not args.filenames and not (args.all or args.new or args.installed):
print('either use --new, --all, --installed, or some filenames')
sys.exit(2)

# Limit the number of threads to 2 to save system resources.
Expand Down
8 changes: 8 additions & 0 deletions src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def __init__(self, **kwds):
self.serial = False
self.timeout = -1
self.all = False
self.installed = False
self.logfile = None
self.long = False
self.warn_long = -1.0
Expand Down Expand Up @@ -732,6 +733,10 @@ def add_files(self):
else:
have_git = False

def all_installed_modules():
import sage
self.files.extend(sage.__path__)

def all_files():
self.files.append(opj(SAGE_SRC, 'sage'))
# Only test sage_setup and sage_docbuild if the relevant
Expand All @@ -751,6 +756,9 @@ def all_files():
if os.path.isdir(SAGE_DOC_SRC):
self.files.append(SAGE_DOC_SRC)

if self.options.installed:
self.log("Doctesting all installed modules of the Sage library.")
all_installed_modules()
if self.options.all or (self.options.new and not have_git):
self.log("Doctesting entire Sage library.")
all_files()
Expand Down

0 comments on commit de649be

Please sign in to comment.