@@ -513,7 +513,7 @@ def __init__(self, *args, **kwds):
513
513
514
514
- ``stdout`` -- an open file to restore for debugging
515
515
516
- - ``checker`` -- None, or an instance of
516
+ - ``checker`` -- `` None`` , or an instance of
517
517
:class:`doctest.OutputChecker`
518
518
519
519
- ``verbose`` -- boolean, determines whether verbose printing
@@ -522,6 +522,9 @@ def __init__(self, *args, **kwds):
522
522
- ``optionflags`` -- Controls the comparison with the expected
523
523
output. See :mod:`testmod` for more information.
524
524
525
+ - ``baseline`` -- ``None`` or a dictionary, the ``baseline_stats``
526
+ value
527
+
525
528
EXAMPLES::
526
529
527
530
sage: from sage.doctest.parsing import SageOutputChecker
@@ -535,6 +538,9 @@ def __init__(self, *args, **kwds):
535
538
O = kwds .pop ('outtmpfile' , None )
536
539
self .msgfile = kwds .pop ('msgfile' , None )
537
540
self .options = kwds .pop ('sage_options' )
541
+ self .baseline = kwds .pop ('baseline' , None )
542
+ if self .baseline is None :
543
+ self .baseline = {}
538
544
doctest .DocTestRunner .__init__ (self , * args , ** kwds )
539
545
self ._fakeout = SageSpoofInOut (O )
540
546
if self .msgfile is None :
@@ -1721,12 +1727,20 @@ def serial_dispatch(self):
1721
1727
"""
1722
1728
for source in self .controller .sources :
1723
1729
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]"
1724
1737
if not self .controller .options .only_errors :
1725
1738
self .controller .log (heading )
1726
1739
1727
1740
with tempfile .TemporaryFile () as outtmpfile :
1728
1741
result = DocTestTask (source )(self .controller .options ,
1729
- outtmpfile , self .controller .logger )
1742
+ outtmpfile , self .controller .logger ,
1743
+ baseline = the_baseline_stats )
1730
1744
outtmpfile .seek (0 )
1731
1745
output = bytes_to_str (outtmpfile .read ())
1732
1746
@@ -1985,10 +1999,17 @@ def sel_exit():
1985
1999
# Start a new worker.
1986
2000
import copy
1987
2001
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 = {}
1988
2007
if target_endtime is not None :
1989
2008
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 ])
1991
2010
heading = self .controller .reporter .report_head (w .source )
2011
+ if the_baseline_stats .get ('failed' , False ):
2012
+ heading += " # [failed in baseline]"
1992
2013
if not self .controller .options .only_errors :
1993
2014
w .messages = heading + "\n "
1994
2015
# Store length of heading to detect if the
@@ -2147,7 +2168,7 @@ class should be accessed by the child process.
2147
2168
sage: reporter.report(FDS, False, W.exitcode, result, "")
2148
2169
[... tests, ... s]
2149
2170
"""
2150
- def __init__ (self , source , options , funclist = []):
2171
+ def __init__ (self , source , options , funclist = [], baseline = None ):
2151
2172
"""
2152
2173
Initialization.
2153
2174
@@ -2171,6 +2192,7 @@ def __init__(self, source, options, funclist=[]):
2171
2192
self .source = source
2172
2193
self .options = options
2173
2194
self .funclist = funclist
2195
+ self .baseline = baseline
2174
2196
2175
2197
# Open pipe for messages. These are raw file descriptors,
2176
2198
# not Python file objects!
@@ -2242,7 +2264,7 @@ def run(self):
2242
2264
os .close (self .rmessages )
2243
2265
msgpipe = os .fdopen (self .wmessages , "w" )
2244
2266
try :
2245
- task (self .options , self .outtmpfile , msgpipe , self .result_queue )
2267
+ task (self .options , self .outtmpfile , msgpipe , self .result_queue , baseline = self . baseline )
2246
2268
finally :
2247
2269
msgpipe .close ()
2248
2270
self .outtmpfile .close ()
@@ -2508,7 +2530,8 @@ def __init__(self, source):
2508
2530
"""
2509
2531
self .source = source
2510
2532
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 ):
2512
2535
"""
2513
2536
Calling the task does the actual work of running the doctests.
2514
2537
@@ -2525,6 +2548,9 @@ def __call__(self, options, outtmpfile=None, msgfile=None, result_queue=None):
2525
2548
- ``result_queue`` -- an instance of :class:`multiprocessing.Queue`
2526
2549
to store the doctest result. For testing, this can also be None.
2527
2550
2551
+ - ``baseline`` -- ``None`` or a dictionary, the ``baseline_stats``
2552
+ value.
2553
+
2528
2554
OUTPUT:
2529
2555
2530
2556
- ``(doctests, result_dict)`` where ``doctests`` is the number of
@@ -2560,7 +2586,8 @@ def __call__(self, options, outtmpfile=None, msgfile=None, result_queue=None):
2560
2586
outtmpfile = outtmpfile ,
2561
2587
msgfile = msgfile ,
2562
2588
sage_options = options ,
2563
- optionflags = doctest .NORMALIZE_WHITESPACE | doctest .ELLIPSIS )
2589
+ optionflags = doctest .NORMALIZE_WHITESPACE | doctest .ELLIPSIS ,
2590
+ baseline = baseline )
2564
2591
runner .basename = self .source .basename
2565
2592
runner .filename = self .source .path
2566
2593
N = options .file_iterations
0 commit comments