Skip to content

Commit

Permalink
src/sage/doctest: specify walltime in per-file doctest report
Browse files Browse the repository at this point in the history
Now that cpu seconds are used for --warn-long, we should disambiguate
wherever wall seconds are still used. One such place is in the doctest
runner's per-file report, which outputs (for example)

  [14 tests, 0.26 s]

after testing a file with 14 tests that took 0.26 wall seconds. This
commit changes that output to

    [14 tests, 0.26s wall]

which is explicit about the type of measurement used.

Issue: sagemathGH-32981
  • Loading branch information
orlitzky committed Oct 12, 2024
1 parent 1334027 commit 945665c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
14 changes: 7 additions & 7 deletions src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ def run_doctests(self):
sage: DC.run_doctests()
Doctesting 1 file.
sage -t .../sage/rings/homset.py
[... tests, ... s]
[... tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down Expand Up @@ -1231,7 +1231,7 @@ def cleanup(self, final=True):
Running doctests with ID ...
Doctesting 1 file.
sage -t .../rings/all.py
[... tests, ... s]
[... tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down Expand Up @@ -1435,7 +1435,7 @@ def run(self):
Running doctests with ID ...
Doctesting 1 file.
sage -t .../sage/sets/non_negative_integers.py
[... tests, ... s]
[... tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand All @@ -1459,7 +1459,7 @@ def run(self):
Features to be detected: ...
Doctesting 1 file.
sage -t ....py
[0 tests, ... s]
[0 tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand All @@ -1485,7 +1485,7 @@ def run(self):
Features to be detected: ...
Doctesting 1 file.
sage -t ....py
[4 tests, ... s]
[4 tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand All @@ -1503,7 +1503,7 @@ def run(self):
Features to be detected: ...
Doctesting 1 file.
sage -t ....py
[4 tests, ... s]
[4 tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down Expand Up @@ -1629,7 +1629,7 @@ def run_doctests(module, options=None):
Running doctests with ID ...
Doctesting 1 file.
sage -t .../sage/rings/all.py
[... tests, ... s]
[... tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down
20 changes: 10 additions & 10 deletions src/sage/doctest/forker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,9 +1758,9 @@ def serial_dispatch(self):
sage: DC.timer = Timer().start()
sage: DD.serial_dispatch()
sage -t .../rings/homset.py
[... tests, ... s]
[... tests, ...s wall]
sage -t .../rings/ideal.py
[... tests, ... s]
[... tests, ...s wall]
"""
for source in self.controller.sources:
heading = self.controller.reporter.report_head(source)
Expand Down Expand Up @@ -1804,9 +1804,9 @@ def parallel_dispatch(self):
sage: DC.timer = Timer().start()
sage: DD.parallel_dispatch()
sage -t .../databases/cremona.py
[... tests, ... s]
[... tests, ...s wall]
sage -t .../rings/big_oh.py
[... tests, ... s]
[... tests, ...s wall]
If the ``exitfirst=True`` option is given, the results for a failing
module will be immediately printed and any other ongoing tests
Expand Down Expand Up @@ -1841,7 +1841,7 @@ def parallel_dispatch(self):
**********************************************************************
1 item had failures:
1 of 1 in ...
[1 test, 1 failure, ... s]
[1 test, 1 failure, ...s wall]
Killing test ...
"""
opt = self.controller.options
Expand Down Expand Up @@ -2135,9 +2135,9 @@ def dispatch(self):
sage: DC.timer = Timer().start()
sage: DD.dispatch()
sage -t .../sage/modules/free_module_homspace.py
[... tests, ... s]
[... tests, ...s wall]
sage -t .../sage/rings/big_oh.py
[... tests, ... s]
[... tests, ...s wall]
"""
if self.controller.options.serial:
self.serial_dispatch()
Expand Down Expand Up @@ -2187,7 +2187,7 @@ class should be accessed by the child process.
sage: W.join() # Wait for worker to finish
sage: result = W.result_queue.get()
sage: reporter.report(FDS, False, W.exitcode, result, "")
[... tests, ... s]
[... tests, ...s wall]
"""
def __init__(self, source, options, funclist=[], baseline=None):
"""
Expand All @@ -2199,7 +2199,7 @@ def __init__(self, source, options, funclist=[], baseline=None):
Running doctests with ID ...
Doctesting 1 file.
sage -t .../sage/rings/big_oh.py
[... tests, ... s]
[... tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down Expand Up @@ -2246,7 +2246,7 @@ def run(self):
Running doctests with ID ...
Doctesting 1 file.
sage -t .../sage/symbolic/units.py
[... tests, ... s]
[... tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions src/sage/doctest/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
0
sage: DTR.report(FDS, False, 0, (sum([len(t.examples) for t in doctests]), D),
....: "Good tests")
[... tests, ... s]
[... tests, ...s wall]
sage: DTR.stats
{'sage.doctest.reporting': {'ntests': ..., 'walltime': ...}}
Expand All @@ -414,7 +414,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
1
sage: DTR.report(FDS, False, 0, (sum([len(t.examples) for t in doctests]), D),
....: "Doctest output including the failure...")
[... tests, 1 failure, ... s]
[... tests, 1 failure, ...s wall]
If the user has requested that we report on skipped doctests,
we do so::
Expand All @@ -433,7 +433,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
5 magma tests not run
2 not tested tests not run
0 tests not run because we ran out of time
[... tests, ... s]
[... tests, ...s wall]
Test an internal error in the reporter::
Expand Down Expand Up @@ -466,7 +466,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
1
sage: DTR.report(FDS, False, 0, (sum([len(t.examples) for t in doctests]), D),
....: "Failed test")
[... tests, 1 failure, ... s]
[... tests, 1 failure, ...s wall]
"""
log = self.controller.log
process_name = 'process (pid={0})'.format(pid) if pid else 'process'
Expand Down Expand Up @@ -625,7 +625,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
else:
total = count_noun(ntests, "test")
if not (self.controller.options.only_errors and not f):
log(" [%s, %s%.2f s]" % (total, "%s, " % (count_noun(f, "failure")) if f else "", wall))
log(" [%s, %s%.2fs wall]" % (total, "%s, "%(count_noun(f, "failure")) if f else "", wall))

self.sources_completed += 1

Expand Down Expand Up @@ -680,13 +680,13 @@ def finalize(self):
0
sage: DTR.report(FDS, False, 0, (sum([len(t.examples) for t in doctests]), D),
....: "Good tests")
[... tests, ... s]
[... tests, ...s wall]
sage: runner.failures = 1
sage: runner.update_results(D)
1
sage: DTR.report(FDS, False, 0, (sum([len(t.examples) for t in doctests]), D),
....: "Doctest output including the failure...")
[... tests, 1 failure, ... s]
[... tests, 1 failure, ...s wall]
Now we can show the output of finalize::
Expand Down
18 changes: 9 additions & 9 deletions src/sage/doctest/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Running doctests...
Doctesting 1 file.
sage -t --warn-long 0.0 --random-seed=0 longtime.rst
[0 tests, ...s]
[0 tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand All @@ -40,7 +40,7 @@
Running doctests...
Doctesting 1 file.
sage -t --long --warn-long 0.0 --random-seed=0 longtime.rst
[1 test, ...s]
[1 test, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down Expand Up @@ -442,7 +442,7 @@
Running doctests...
Doctesting 1 file...
sage -t... 1second.rst...
[2 tests, ... s]
[2 tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down Expand Up @@ -471,7 +471,7 @@
1 long test not run
1 not tested test not run
0 tests not run because we ran out of time
[2 tests, ... s]
[2 tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand All @@ -488,7 +488,7 @@
2 tests not run due to known bugs
1 not tested test not run
0 tests not run because we ran out of time
[4 tests, ... s]
[4 tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand All @@ -504,7 +504,7 @@
1 not tested test not run
2 sage tests not run
0 tests not run because we ran out of time
[2 tests, ... s]
[2 tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down Expand Up @@ -533,7 +533,7 @@
Running doctests...
Doctesting 1 file.
sage -t --warn-long 0.0 --random-seed=0 atexit.rst
[3 tests, ... s]
[3 tests, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down Expand Up @@ -564,7 +564,7 @@
**********************************************************************
1 item had failures:
1 of 2 in sage.doctest.tests.random_seed
[1 test, 1 failure, ...s]
[1 test, 1 failure, ...s wall]
----------------------------------------------------------------------
sage -t --warn-long 0.0 --random-seed=0 random_seed.rst # 1 doctest failed
----------------------------------------------------------------------
Expand All @@ -575,7 +575,7 @@
Running doctests...
Doctesting 1 file.
sage -t --warn-long 0.0 --random-seed=1 random_seed.rst
[1 test, ...s]
[1 test, ...s wall]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Expand Down

0 comments on commit 945665c

Please sign in to comment.