summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--sphinx/setup_command.py5
-rw-r--r--tests/test_setup_command.py13
3 files changed, 19 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 50cc401c3..13c8d3a70 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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)
====================================
diff --git a/sphinx/setup_command.py b/sphinx/setup_command.py
index e6b5b8f71..a487b2a2a 100644
--- a/sphinx/setup_command.py
+++ b/sphinx/setup_command.py
@@ -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):
diff --git a/tests/test_setup_command.py b/tests/test_setup_command.py
index ef7fd1f3c..c165b2d33 100644
--- a/tests/test_setup_command.py
+++ b/tests/test_setup_command.py
@@ -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'