2010-09-16 02:19:06 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
test_build_texinfo
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Test the build process with Texinfo builder with the test root.
|
|
|
|
|
2017-12-31 10:06:58 -06:00
|
|
|
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
|
2010-09-16 02:19:06 -05:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
2014-01-19 04:17:10 -06:00
|
|
|
from __future__ import print_function
|
2010-09-16 02:19:06 -05:00
|
|
|
|
|
|
|
import os
|
2010-10-22 03:17:35 -05:00
|
|
|
import re
|
2010-09-16 02:19:06 -05:00
|
|
|
from subprocess import Popen, PIPE
|
|
|
|
|
2014-09-21 10:17:02 -05:00
|
|
|
from six import PY3
|
2017-01-05 10:14:47 -06:00
|
|
|
import pytest
|
2014-04-28 21:46:47 -05:00
|
|
|
|
2010-11-07 00:41:47 -05:00
|
|
|
from sphinx.writers.texinfo import TexinfoTranslator
|
|
|
|
|
2017-05-16 09:53:46 -05:00
|
|
|
from sphinx.testing.util import remove_unicode_literals, strip_escseq
|
2010-09-16 02:19:06 -05:00
|
|
|
from test_build_html import ENV_WARNINGS
|
|
|
|
|
|
|
|
|
2010-11-07 00:41:47 -05:00
|
|
|
TEXINFO_WARNINGS = ENV_WARNINGS + """\
|
2016-07-14 09:12:57 -05:00
|
|
|
%(root)s/index.rst:\\d+: WARNING: unknown option: &option
|
|
|
|
%(root)s/index.rst:\\d+: WARNING: citation not found: missing
|
|
|
|
%(root)s/index.rst:\\d+: WARNING: no matching candidate for image URI u'foo.\\*'
|
|
|
|
%(root)s/index.rst:\\d+: WARNING: no matching candidate for image URI u'svgimg.\\*'
|
2010-11-07 00:41:47 -05:00
|
|
|
"""
|
2010-10-22 03:17:35 -05:00
|
|
|
|
2014-04-30 07:30:46 -05:00
|
|
|
if PY3:
|
2010-09-16 02:19:06 -05:00
|
|
|
TEXINFO_WARNINGS = remove_unicode_literals(TEXINFO_WARNINGS)
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('texinfo', testroot='warnings', freshenv=True)
|
2016-07-14 09:12:57 -05:00
|
|
|
def test_texinfo_warnings(app, status, warning):
|
2010-09-16 02:19:06 -05:00
|
|
|
app.builder.build_all()
|
2017-05-01 16:19:53 -05:00
|
|
|
warnings = strip_escseq(re.sub(re.escape(os.sep) + '{1,2}', '/', warning.getvalue()))
|
2016-07-14 09:12:57 -05:00
|
|
|
warnings_exp = TEXINFO_WARNINGS % {
|
2014-09-21 10:17:02 -05:00
|
|
|
'root': re.escape(app.srcdir.replace(os.sep, '/'))}
|
2016-07-14 09:12:57 -05:00
|
|
|
assert re.match(warnings_exp + '$', warnings), \
|
2014-09-21 10:17:02 -05:00
|
|
|
'Warnings don\'t match:\n' + \
|
2016-07-14 09:12:57 -05:00
|
|
|
'--- Expected (regex):\n' + warnings_exp + \
|
|
|
|
'--- Got:\n' + warnings
|
|
|
|
|
|
|
|
|
2017-01-05 10:14:47 -06:00
|
|
|
@pytest.mark.sphinx('texinfo')
|
2016-07-14 09:12:57 -05:00
|
|
|
def test_texinfo(app, status, warning):
|
|
|
|
TexinfoTranslator.ignore_missing_images = True
|
|
|
|
app.builder.build_all()
|
2010-09-16 02:19:06 -05:00
|
|
|
# now, try to run makeinfo over it
|
|
|
|
cwd = os.getcwd()
|
|
|
|
os.chdir(app.outdir)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
p = Popen(['makeinfo', '--no-split', 'SphinxTests.texi'],
|
|
|
|
stdout=PIPE, stderr=PIPE)
|
|
|
|
except OSError:
|
2017-04-27 09:38:42 -05:00
|
|
|
raise pytest.skip.Exception # most likely makeinfo was not found
|
2010-09-16 02:19:06 -05:00
|
|
|
else:
|
|
|
|
stdout, stderr = p.communicate()
|
|
|
|
retcode = p.returncode
|
|
|
|
if retcode != 0:
|
2014-01-19 04:17:10 -06:00
|
|
|
print(stdout)
|
|
|
|
print(stderr)
|
2010-09-16 02:19:06 -05:00
|
|
|
assert False, 'makeinfo exited with return code %s' % retcode
|
|
|
|
finally:
|
|
|
|
os.chdir(cwd)
|