mirror of https://github.com/tLDP/python-tldp
build() only returns 0 (success) for all builds
before, the build() function lacked the logic to retain, and return that there was a failure during the building of one of the documents; it now returns a 1, which is passed directly to sys.exit(), if any single build fails
This commit is contained in:
parent
97181b167a
commit
9cb92dce7c
2
TODO
2
TODO
|
@ -10,8 +10,6 @@ python-tldp TODO
|
|||
|
||||
* add a manpage
|
||||
|
||||
* build should return 0, only if all documents build successfully
|
||||
|
||||
* figure out how/if to build the outputs in a separate place
|
||||
rather than in the real output directory
|
||||
|
||||
|
|
|
@ -196,5 +196,22 @@ class TestDriverBuild(TestInventoryBase):
|
|||
doc = docs.pop(0)
|
||||
self.assertTrue(doc.output.iscomplete)
|
||||
|
||||
|
||||
def test_build_one_broken(self):
|
||||
c = self.config
|
||||
self.add_new('Frobnitz-DocBook-XML-4-HOWTO', example.ex_docbook4xml)
|
||||
# -- mangle the content of a valid DocBook XML file
|
||||
borked = example.ex_docbook4xml.content[:-12]
|
||||
self.add_new('Frobnitz-Borked-XML-4-HOWTO',
|
||||
example.ex_docbook4xml, content=borked)
|
||||
c.docbook4xml_xslsingle = os.path.join(extras, 'ldp-html.xsl')
|
||||
c.docbook4xml_xslprint = os.path.join(extras, 'ldp-print.xsl')
|
||||
c.docbook4xml_xslchunk = os.path.join(extras, 'ldp-html-chunk.xsl')
|
||||
inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
|
||||
self.assertEquals(2, len(inv.all.keys()))
|
||||
docs = inv.all.values()
|
||||
result = tldp.driver.build(c, docs)
|
||||
self.assertEquals(1, result)
|
||||
|
||||
#
|
||||
# -- end of file
|
||||
|
|
|
@ -169,9 +169,12 @@ class TestInventoryBase(unittest.TestCase):
|
|||
assert fname is not None
|
||||
os.unlink(fname)
|
||||
|
||||
def add_new(self, stem, ex):
|
||||
def add_new(self, stem, ex, content=None):
|
||||
c = self.config
|
||||
mysource = TestSourceDocSkeleton(c.sourcedir)
|
||||
if content:
|
||||
mysource.addsourcefile(stem + ex.ext, content)
|
||||
else:
|
||||
mysource.addsourcefile(stem + ex.ext, ex.filename)
|
||||
|
||||
def add_orphan(self, stem, ex):
|
||||
|
|
|
@ -63,6 +63,7 @@ def detail(config, docs, **kwargs):
|
|||
|
||||
|
||||
def build(config, docs, **kwargs):
|
||||
result = list()
|
||||
for x, source in enumerate(docs, 1):
|
||||
if not isinstance(source, tldp.sources.SourceDocument):
|
||||
logger.info("%s (%d of %d) skipping, no source for orphan",
|
||||
|
@ -79,8 +80,13 @@ def build(config, docs, **kwargs):
|
|||
runner = source.doctype(source=source, output=output, config=config)
|
||||
logger.info("%s (%d of %d) initiating build",
|
||||
source.stem, x, len(docs))
|
||||
runner.generate()
|
||||
result.append(runner.generate())
|
||||
if all(result):
|
||||
return 0
|
||||
for errcode, source in zip(result, docs):
|
||||
if not errcode:
|
||||
logger.error("%s build failed", source.stem)
|
||||
return 1
|
||||
|
||||
|
||||
# def script(config, docs, inv, **kwargs):
|
||||
|
|
Loading…
Reference in New Issue