diff --git a/src/bin/sage-runtests b/src/bin/sage-runtests index 6d140aafe3a..965b6e86e75 100755 --- a/src/bin/sage-runtests +++ b/src/bin/sage-runtests @@ -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'") @@ -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 @@ -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. diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py index 01f32fb8e45..d5d3ac9b799 100644 --- a/src/sage/doctest/control.py +++ b/src/sage/doctest/control.py @@ -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 @@ -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 @@ -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()