diff --git a/TODO b/TODO index 80bc195..8e6a5fa 100644 --- a/TODO +++ b/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 diff --git a/tests/test_driver.py b/tests/test_driver.py index 3d908db..59556f3 100644 --- a/tests/test_driver.py +++ b/tests/test_driver.py @@ -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 diff --git a/tests/tldptesttools.py b/tests/tldptesttools.py index a1ced44..3126bf1 100644 --- a/tests/tldptesttools.py +++ b/tests/tldptesttools.py @@ -169,10 +169,13 @@ 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) - mysource.addsourcefile(stem + ex.ext, ex.filename) + if content: + mysource.addsourcefile(stem + ex.ext, content) + else: + mysource.addsourcefile(stem + ex.ext, ex.filename) def add_orphan(self, stem, ex): c = self.config diff --git a/tldp/driver.py b/tldp/driver.py index f42b63a..da94418 100644 --- a/tldp/driver.py +++ b/tldp/driver.py @@ -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() - return 0 + 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):