Skip to content

Commit

Permalink
test_build_latex: move output to a separate output dir
Browse files Browse the repository at this point in the history
Related: sphinx-doc#11285
Co-authored-by: Jean-François B <2589111+jfbu@users.noreply.github.com>
  • Loading branch information
marxin and jfbu committed Apr 13, 2023
1 parent 188b869 commit b6e6805
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/test_build_latex.py
Expand Up @@ -27,7 +27,7 @@
from sphinx.util.osutil import _chdir as chdir

LATEX_ENGINES = ['pdflatex', 'lualatex', 'xelatex']
DOCCLASSES = ['howto', 'manual']
DOCCLASSES = ['manual', 'howto']
STYLEFILES = ['article.cls', 'fancyhdr.sty', 'titlesec.sty', 'amsmath.sty',
'framed.sty', 'color.sty', 'fancyvrb.sty',
'fncychap.sty', 'geometry.sty', 'kvoptions.sty', 'hyperref.sty',
Expand All @@ -51,17 +51,20 @@ def kpsetest(*filenames):


# compile latex document with app.config.latex_engine
def compile_latex_document(app, filename='python.tex'):
def compile_latex_document(app, filename='python.tex', docclass='manual'):
# now, try to run latex over it
try:
with chdir(app.outdir):
ensuredir(app.config.latex_engine)
# name latex output-directory according to both engine and docclass
# to avoid reuse of auxiliary files by one docclass from another
latex_outputdir = app.config.latex_engine + docclass
ensuredir(latex_outputdir)
# keep a copy of latex file for this engine in case test fails
copyfile(filename, app.config.latex_engine + '/' + filename)
copyfile(filename, latex_outputdir + '/' + filename)
args = [app.config.latex_engine,
'--halt-on-error',
'--interaction=nonstopmode',
'-output-directory=%s' % app.config.latex_engine,
'-output-directory=%s' % latex_outputdir,
filename]
subprocess.run(args, capture_output=True, check=True)
except OSError as exc: # most likely the latex executable was not found
Expand Down Expand Up @@ -117,7 +120,7 @@ def test_build_latex_doc(app, status, warning, engine, docclass):
# file from latex_additional_files
assert (app.outdir / 'svgimg.svg').isfile()

compile_latex_document(app, 'sphinxtests.tex')
compile_latex_document(app, 'sphinxtests.tex', docclass)


@pytest.mark.sphinx('latex')
Expand Down

0 comments on commit b6e6805

Please sign in to comment.