Opened 2 years ago

Closed 2 years ago

#25308 closed defect (fixed)

sage -t --show-skipped says "5 latex tests not run" while they are

Reported by: slabbe Owned by:
Priority: major Milestone: sage-8.3
Component: doctest framework Keywords:
Cc: Merged in:
Authors: Sébastien Labbé Reviewers: Vincent Klein
Report Upstream: N/A Work issues:
Branch: 8993459 (Commits) Commit: 8993459ac293b362b047118468b365cfd16cfc65
Dependencies: Stopgaps:

Description (last modified by slabbe)

First I add a problem in the output of a #optional - latex doctest:

  • src/sage/misc/latex.py

    diff --git a/src/sage/misc/latex.py b/src/sage/misc/latex.py
    index 4771a1c..01e9cb4 100644
    a b Warning: `{}` is not part of this computer's TeX installation.""".format(file_na 
    15481548            sage: latex.add_package_to_preamble_if_available("xypic")
    15491549            sage: latex.add_package_to_preamble_if_available("nonexistent_package")
    15501550            sage: latex.extra_preamble()       # optional - latex
    1551             '\\usepackage{xypic}\n'
     1551            '\\usepackage{xypic}\n' PROBLEM
    15521552            sage: latex.extra_preamble('')
    15531553        """
    15541554        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.

Change History (14)

comment:1 Changed 2 years ago by slabbe

  • Authors set to Sébastien Labbé
  • Branch set to u/slabbe/25308
  • Commit set to 40499307fc0aad58e061bceae35fa11f53cefc95
  • Status changed from new to needs_review

New commits:

404993025308: fix --show-skipped for external softwares

comment:2 Changed 2 years ago by slabbe

  • Description modified (diff)

comment:3 Changed 2 years ago by jdemeyer

While this probably solves the problem, I wonder if we could just update self.controller.options.optional or have some API to return the optional tags.

comment:4 Changed 2 years ago by slabbe

The header of the external.py says that the detection of external software is done lazily:

"""
Detecting external software

This module makes up a list of external software that Sage interfaces. Availability
of each software is tested only when necessary. This is mainly used for the doctests
which require certain external software installed on the system.

...

class AvailableSoftware(object):
    """
    This class keeps the set of available software whose availability is detected lazily
    from the list of external software.

...

So what you mean is to update self.controller.options.optional every time an external software is detected?

comment:5 Changed 2 years ago by jdemeyer

To be honest, I don't know exactly what I mean. I was more thinking of abstracting this check in a method like

def have_optional_tag(self, tag):
    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

and then using that.

comment:6 Changed 2 years ago by git

  • Commit changed from 40499307fc0aad58e061bceae35fa11f53cefc95 to 5d6bb67a43028cbbb1501c54ba2a808b1d5a8788

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

1bb26ff25308: fix --show-skipped for external softwares
5d6bb6725308: adding method have_optional_tag

comment:7 Changed 2 years ago by slabbe

Good idea. I added such a method. And I rebased the branch on top on 8.3.beta0 to avoid merge commits.

comment:8 Changed 2 years ago by git

  • Commit changed from 5d6bb67a43028cbbb1501c54ba2a808b1d5a8788 to 8993459ac293b362b047118468b365cfd16cfc65

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

899345925308: adding method have_optional_tag

comment:9 Changed 2 years ago by slabbe

Improved doc. Re-needs review.

comment:10 Changed 2 years ago by slabbe

ping

comment:11 Changed 2 years ago by vklein

  • Status changed from needs_review to positive_review

Tested. It's fine for me.

comment:12 Changed 2 years ago by slabbe

  • Reviewers set to Vincent Klein

comment:13 Changed 2 years ago by slabbe

Thanks for the review.

comment:14 Changed 2 years ago by vbraun

  • Branch changed from u/slabbe/25308 to 8993459ac293b362b047118468b365cfd16cfc65
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.