Now Sphinx exits with non-zero status code if builder status is not success. Closes #508.

This commit is contained in:
Takayuki Shimizukawa
2014-08-29 01:14:54 +09:00
parent e9aae6563d
commit ad69dadd14
3 changed files with 19 additions and 2 deletions

View File

@@ -42,6 +42,9 @@ Bugs fixed
* #1544: `make text` generate wrong table when it has empty table cells.
* #1522: Footnotes from table get displayed twice in LaTeX. This problem has
been appeared from Sphinx-1.2.1 by #949.
* #508: Sphinx every time exit with zero when is invoked from setup.py command.
ex. `python setup.py build_sphinx -b doctest` return zero even if doctest
failed.
Release 1.2.2 (released Mar 2, 2014)
====================================

View File

@@ -17,7 +17,7 @@ import os
import types
from StringIO import StringIO
from distutils.cmd import Command
from distutils.errors import DistutilsOptionError
from distutils.errors import DistutilsOptionError, DistutilsExecError
from sphinx.application import Sphinx
from sphinx.util.console import darkred, nocolor, color_terminal
@@ -159,6 +159,9 @@ class BuildDoc(Command):
try:
app.build(force_all=self.all_files)
if app.statuscode:
raise DistutilsExecError(
'caused by %s builder.' % app.builder.name)
except Exception, err:
from docutils.utils import SystemMessage
if isinstance(err, SystemMessage):

View File

@@ -47,7 +47,7 @@ def with_setup_command(root, *args, **kwds):
env=dict(os.environ, PYTHONPATH=pythonpath),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
func(pkgrootdir, proc, *args, **kwds)
func(pkgrootdir, proc)
finally:
tempdir.rmtree(ignore_errors=True)
os.chdir(cwd)
@@ -92,3 +92,14 @@ def test_build_sphinx_with_nonascii_path(pkgroot, proc):
print(out)
print(err)
assert proc.returncode == 0
@with_setup_command(root, '-b', 'linkcheck')
def test_build_sphinx_return_nonzero_status(pkgroot, proc):
srcdir = (pkgroot / 'doc')
(srcdir / 'contents.txt').write_text(
'http://localhost.unexistentdomain/index.html')
out, err = proc.communicate()
print(out)
print(err)
assert proc.returncode != 0, 'expect non-zero status for setup.py'