Skip to content

Commit

Permalink
Trac #25308: sage -t --show-skipped says "5 latex tests not run" whil…
Browse files Browse the repository at this point in the history
…e they are

First I add a problem in the output of a `#optional - latex` doctest:
{{{
#!diff
diff --git a/src/sage/misc/latex.py b/src/sage/misc/latex.py
index 4771a1c..01e9cb4 100644
--- a/src/sage/misc/latex.py
+++ b/src/sage/misc/latex.py
@@ -1548,7 +1548,7 @@ Warning: `{}` is not part of this computer's TeX
installation.""".format(file_na
             sage: latex.add_package_to_preamble_if_available("xypic")
             sage:
latex.add_package_to_preamble_if_available("nonexistent_package")
             sage: latex.extra_preamble()       # optional - latex
-            '\\usepackage{xypic}\n'
+            '\\usepackage{xypic}\n' PROBLEM
             sage: latex.extra_preamble('')
         """
         assert isinstance(package_name, str)
}}}

Then this is OK:

{{{
$ sage -t --show-skipped src/sage/misc/latex.py
Using --optional=ccache,dot2tex,mpir,notedown,pandoc_attributes,python2,
rst2ipynb,sage
Doctesting 1 file.
sage -t src/sage/misc/latex.py
    1 imagemagick test not run
    5 latex tests not run
    3 other tests skipped
    [310 tests, 1.23 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
}}}

Then, writing `--optional=sage,external` detects that `latex` is
available and runs the 5  `latex` optional tests (total number of tests
goes from 310 to 315).

{{{
$ sage -t --show-skipped --optional=sage,external src/sage/misc/latex.py
Using --optional=external,sage
External software to be detected: cplex,gurobi,internet,latex,macaulay2,
magma,maple,mathematica,matlab,octave,scilab
Doctesting 1 file.
sage -t src/sage/misc/latex.py
**********************************************************************
File "src/sage/misc/latex.py", line 1550, in
sage.misc.latex.Latex.add_package_to_preamble_if_available
Failed example:
    latex.extra_preamble()       # optional - latex
Expected:
    '\\usepackage{xypic}\n' PROBLEM
Got:
    '\\usepackage{xypic}\n'
**********************************************************************
1 item had failures:
   1 of   5 in
sage.misc.latex.Latex.add_package_to_preamble_if_available
    1 imagemagick test not run
    5 latex tests not run
    3 other tests skipped
    [315 tests, 1 failure, 1.55 s]
----------------------------------------------------------------------
sage -t src/sage/misc/latex.py  # 1 doctest failed
----------------------------------------------------------------------
Total time for all tests: 1.8 seconds
    cpu time: 0.6 seconds
    cumulative wall time: 1.5 seconds
External software detected for doctesting: latex
}}}

But `--show-skipped` still says that `5 latex tests not run`.

URL: https://trac.sagemath.org/25308
Reported by: slabbe
Ticket author(s): Sébastien Labbé
Reviewer(s): Vincent Klein
  • Loading branch information
Release Manager authored and vbraun committed Jun 20, 2018
2 parents 2196618 + 8993459 commit 335a218
Showing 1 changed file with 42 additions and 9 deletions.
51 changes: 42 additions & 9 deletions src/sage/doctest/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from sage.structure.sage_object import SageObject
from sage.doctest.util import count_noun
from sage.doctest.sources import DictAsObject
from .external import available_software

def signal_name(sig):
"""
Expand Down Expand Up @@ -112,6 +113,39 @@ def __init__(self, controller):
self.stats = {}
self.error_status = 0

def have_optional_tag(self, tag):
r"""
Return whether doctests marked with this tag are run.
INPUT:
- ``tag`` -- string
EXAMPLES::
sage: from sage.doctest.reporting import DocTestReporter
sage: from sage.doctest.control import DocTestController, DocTestDefaults
sage: from sage.env import SAGE_SRC
sage: import os
sage: filename = os.path.join(SAGE_SRC,'sage','doctest','reporting.py')
sage: DC = DocTestController(DocTestDefaults(),[filename])
sage: DTR = DocTestReporter(DC)
::
sage: DTR.have_optional_tag('sage')
True
sage: DTR.have_optional_tag('nice_unavailable_package')
False
"""
if tag in self.controller.options.optional:
return True
if 'external' in self.controller.options.optional:
if tag in available_software.seen():
return True
return False

def report_head(self, source):
"""
Return the "sage -t [options] file.py" line as string.
Expand Down Expand Up @@ -453,15 +487,14 @@ def report(self, source, timeout, return_code, results, output, pid=None):
log(" %s not run"%(count_noun(nskipped, "long test")))
elif tag in ("not tested", "not implemented"):
untested += nskipped
else:
if tag not in self.controller.options.optional:
seen_other = True
if tag == "bug":
log(" %s not run due to known bugs"%(count_noun(nskipped, "test")))
elif tag == "":
log(" %s not run"%(count_noun(nskipped, "unlabeled test")))
else:
log(" %s not run"%(count_noun(nskipped, tag + " test")))
elif not self.have_optional_tag(tag):
seen_other = True
if tag == "bug":
log(" %s not run due to known bugs"%(count_noun(nskipped, "test")))
elif tag == "":
log(" %s not run"%(count_noun(nskipped, "unlabeled test")))
else:
log(" %s not run"%(count_noun(nskipped, tag + " test")))
if untested:
log(" %s skipped"%(count_noun(untested, "%stest"%("other " if seen_other else ""))))
if not (self.controller.options.only_errors and not f):
Expand Down

0 comments on commit 335a218

Please sign in to comment.