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.
|
|
|
|
|
2015-01-03 14:36:32 -06:00
|
|
|
:copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
|
2010-09-16 02:19:06 -05:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
2010-10-22 03:17:35 -05:00
|
|
|
import re
|
2010-09-16 02:19:06 -05:00
|
|
|
import sys
|
|
|
|
from StringIO import StringIO
|
|
|
|
from subprocess import Popen, PIPE
|
|
|
|
|
2010-11-07 00:41:47 -05:00
|
|
|
from sphinx.writers.texinfo import TexinfoTranslator
|
|
|
|
|
2013-09-22 19:57:36 -05:00
|
|
|
from util import test_root, SkipTest, remove_unicode_literals, with_app
|
2010-09-16 02:19:06 -05:00
|
|
|
from test_build_html import ENV_WARNINGS
|
|
|
|
|
|
|
|
|
|
|
|
def teardown_module():
|
|
|
|
(test_root / '_build').rmtree(True)
|
|
|
|
|
|
|
|
|
|
|
|
texinfo_warnfile = StringIO()
|
|
|
|
|
2010-11-07 00:41:47 -05:00
|
|
|
TEXINFO_WARNINGS = ENV_WARNINGS + """\
|
2013-05-01 20:37:12 -05:00
|
|
|
None:None: WARNING: citation not found: missing
|
2010-11-07 00:41:47 -05:00
|
|
|
None:None: WARNING: no matching candidate for image URI u'foo.\\*'
|
2011-03-05 23:59:34 -06:00
|
|
|
None:None: 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
|
|
|
|
2010-09-16 02:19:06 -05:00
|
|
|
if sys.version_info >= (3, 0):
|
|
|
|
TEXINFO_WARNINGS = remove_unicode_literals(TEXINFO_WARNINGS)
|
|
|
|
|
|
|
|
|
|
|
|
@with_app(buildername='texinfo', warning=texinfo_warnfile, cleanenv=True)
|
|
|
|
def test_texinfo(app):
|
2010-11-07 00:41:47 -05:00
|
|
|
TexinfoTranslator.ignore_missing_images = True
|
2010-09-16 02:19:06 -05:00
|
|
|
app.builder.build_all()
|
2010-10-22 03:17:35 -05:00
|
|
|
texinfo_warnings = texinfo_warnfile.getvalue().replace(os.sep, '/')
|
2012-05-01 22:05:41 -05:00
|
|
|
texinfo_warnings_exp = TEXINFO_WARNINGS % {
|
|
|
|
'root': re.escape(app.srcdir.replace(os.sep, '/'))}
|
2010-10-22 04:27:33 -05:00
|
|
|
assert re.match(texinfo_warnings_exp + '$', texinfo_warnings), \
|
|
|
|
'Warnings don\'t match:\n' + \
|
|
|
|
'--- Expected (regex):\n' + texinfo_warnings_exp + \
|
|
|
|
'--- Got:\n' + texinfo_warnings
|
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:
|
2013-09-22 19:57:36 -05:00
|
|
|
raise SkipTest # 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:
|
|
|
|
print stdout
|
|
|
|
print stderr
|
|
|
|
del app.cleanup_trees[:]
|
|
|
|
assert False, 'makeinfo exited with return code %s' % retcode
|
|
|
|
finally:
|
|
|
|
os.chdir(cwd)
|