Skip to content

Commit e944a54

Browse files
author
Matthias Koeppe
committed
src/sage/doctest/forker.py: Show '# [failed in baseline]' earlier
1 parent e249bef commit e944a54

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

src/sage/doctest/forker.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def __init__(self, *args, **kwds):
513513
514514
- ``stdout`` -- an open file to restore for debugging
515515
516-
- ``checker`` -- None, or an instance of
516+
- ``checker`` -- ``None``, or an instance of
517517
:class:`doctest.OutputChecker`
518518
519519
- ``verbose`` -- boolean, determines whether verbose printing
@@ -522,6 +522,9 @@ def __init__(self, *args, **kwds):
522522
- ``optionflags`` -- Controls the comparison with the expected
523523
output. See :mod:`testmod` for more information.
524524
525+
- ``baseline`` -- ``None`` or a dictionary, the ``baseline_stats``
526+
value
527+
525528
EXAMPLES::
526529
527530
sage: from sage.doctest.parsing import SageOutputChecker
@@ -535,6 +538,9 @@ def __init__(self, *args, **kwds):
535538
O = kwds.pop('outtmpfile', None)
536539
self.msgfile = kwds.pop('msgfile', None)
537540
self.options = kwds.pop('sage_options')
541+
self.baseline = kwds.pop('baseline', None)
542+
if self.baseline is None:
543+
self.baseline = {}
538544
doctest.DocTestRunner.__init__(self, *args, **kwds)
539545
self._fakeout = SageSpoofInOut(O)
540546
if self.msgfile is None:
@@ -1721,12 +1727,20 @@ def serial_dispatch(self):
17211727
"""
17221728
for source in self.controller.sources:
17231729
heading = self.controller.reporter.report_head(source)
1730+
basename = source.basename
1731+
if self.controller.baseline_stats:
1732+
the_baseline_stats = self.controller.baseline_stats.get(basename, {})
1733+
else:
1734+
the_baseline_stats = {}
1735+
if the_baseline_stats.get('failed', False):
1736+
heading += " # [failed in baseline]"
17241737
if not self.controller.options.only_errors:
17251738
self.controller.log(heading)
17261739

17271740
with tempfile.TemporaryFile() as outtmpfile:
17281741
result = DocTestTask(source)(self.controller.options,
1729-
outtmpfile, self.controller.logger)
1742+
outtmpfile, self.controller.logger,
1743+
baseline=the_baseline_stats)
17301744
outtmpfile.seek(0)
17311745
output = bytes_to_str(outtmpfile.read())
17321746

@@ -1985,10 +1999,17 @@ def sel_exit():
19851999
# Start a new worker.
19862000
import copy
19872001
worker_options = copy.copy(opt)
2002+
basename = source.basename
2003+
if self.controller.baseline_stats:
2004+
the_baseline_stats = self.controller.baseline_stats.get(basename, {})
2005+
else:
2006+
the_baseline_stats = {}
19882007
if target_endtime is not None:
19892008
worker_options.target_walltime = (target_endtime - now) / (max(1, pending_tests / opt.nthreads))
1990-
w = DocTestWorker(source, options=worker_options, funclist=[sel_exit])
2009+
w = DocTestWorker(source, options=worker_options, baseline=the_baseline_stats, funclist=[sel_exit])
19912010
heading = self.controller.reporter.report_head(w.source)
2011+
if the_baseline_stats.get('failed', False):
2012+
heading += " # [failed in baseline]"
19922013
if not self.controller.options.only_errors:
19932014
w.messages = heading + "\n"
19942015
# Store length of heading to detect if the
@@ -2147,7 +2168,7 @@ class should be accessed by the child process.
21472168
sage: reporter.report(FDS, False, W.exitcode, result, "")
21482169
[... tests, ... s]
21492170
"""
2150-
def __init__(self, source, options, funclist=[]):
2171+
def __init__(self, source, options, funclist=[], baseline=None):
21512172
"""
21522173
Initialization.
21532174
@@ -2171,6 +2192,7 @@ def __init__(self, source, options, funclist=[]):
21712192
self.source = source
21722193
self.options = options
21732194
self.funclist = funclist
2195+
self.baseline = baseline
21742196

21752197
# Open pipe for messages. These are raw file descriptors,
21762198
# not Python file objects!
@@ -2242,7 +2264,7 @@ def run(self):
22422264
os.close(self.rmessages)
22432265
msgpipe = os.fdopen(self.wmessages, "w")
22442266
try:
2245-
task(self.options, self.outtmpfile, msgpipe, self.result_queue)
2267+
task(self.options, self.outtmpfile, msgpipe, self.result_queue, baseline=self.baseline)
22462268
finally:
22472269
msgpipe.close()
22482270
self.outtmpfile.close()
@@ -2508,7 +2530,8 @@ def __init__(self, source):
25082530
"""
25092531
self.source = source
25102532

2511-
def __call__(self, options, outtmpfile=None, msgfile=None, result_queue=None):
2533+
def __call__(self, options, outtmpfile=None, msgfile=None, result_queue=None, *,
2534+
baseline=None):
25122535
"""
25132536
Calling the task does the actual work of running the doctests.
25142537
@@ -2525,6 +2548,9 @@ def __call__(self, options, outtmpfile=None, msgfile=None, result_queue=None):
25252548
- ``result_queue`` -- an instance of :class:`multiprocessing.Queue`
25262549
to store the doctest result. For testing, this can also be None.
25272550
2551+
- ``baseline`` -- ``None`` or a dictionary, the ``baseline_stats``
2552+
value.
2553+
25282554
OUTPUT:
25292555
25302556
- ``(doctests, result_dict)`` where ``doctests`` is the number of
@@ -2560,7 +2586,8 @@ def __call__(self, options, outtmpfile=None, msgfile=None, result_queue=None):
25602586
outtmpfile=outtmpfile,
25612587
msgfile=msgfile,
25622588
sage_options=options,
2563-
optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS)
2589+
optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS,
2590+
baseline=baseline)
25642591
runner.basename = self.source.basename
25652592
runner.filename = self.source.path
25662593
N = options.file_iterations

0 commit comments

Comments
 (0)