mirror of https://github.com/tLDP/python-tldp
improve testing coverage of driver.py
adjust calling pattern for prepare_{script,build}_mode so that they are easier to test embed the creation of build directories into the prepare_build_mode
This commit is contained in:
parent
a488ae53de
commit
f4367e943f
|
@ -211,14 +211,19 @@ def prepare_docs_script_mode(config, docs):
|
||||||
source.working = OutputDirectory.fromsource(config.pubdir, source)
|
source.working = OutputDirectory.fromsource(config.pubdir, source)
|
||||||
else:
|
else:
|
||||||
source.working = source.output
|
source.working = source.output
|
||||||
|
return True, None
|
||||||
|
|
||||||
|
|
||||||
def prepare_docs_build_mode(config, docs):
|
def prepare_docs_build_mode(config, docs):
|
||||||
|
ready, error = create_dtworkingdir(config, docs)
|
||||||
|
if not ready:
|
||||||
|
return ready, error
|
||||||
for source in docs:
|
for source in docs:
|
||||||
d = source.dtworkingdir
|
d = source.dtworkingdir
|
||||||
source.working = OutputDirectory.fromsource(d, source)
|
source.working = OutputDirectory.fromsource(d, source)
|
||||||
if not source.output:
|
if not source.output:
|
||||||
source.output = OutputDirectory.fromsource(config.pubdir, source)
|
source.output = OutputDirectory.fromsource(config.pubdir, source)
|
||||||
|
return True, None
|
||||||
|
|
||||||
|
|
||||||
def docbuild(config, docs, **kwargs):
|
def docbuild(config, docs, **kwargs):
|
||||||
|
@ -238,7 +243,9 @@ def docbuild(config, docs, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def script(config, docs, **kwargs):
|
def script(config, docs, **kwargs):
|
||||||
prepare_docs_script_mode(config, docs)
|
ready, error = prepare_docs_script_mode(config, docs)
|
||||||
|
if not ready:
|
||||||
|
return error
|
||||||
file = kwargs.get('file', sys.stdout)
|
file = kwargs.get('file', sys.stdout)
|
||||||
print(preamble, file=file)
|
print(preamble, file=file)
|
||||||
result = docbuild(config, docs, **kwargs)
|
result = docbuild(config, docs, **kwargs)
|
||||||
|
@ -252,10 +259,9 @@ def build(config, docs, **kwargs):
|
||||||
ready, error = builddir_setup(config)
|
ready, error = builddir_setup(config)
|
||||||
if not ready:
|
if not ready:
|
||||||
return error
|
return error
|
||||||
ready, error = create_dtworkingdir(config, docs)
|
ready, error = prepare_docs_build_mode(config, docs)
|
||||||
if not ready:
|
if not ready:
|
||||||
return error
|
return error
|
||||||
prepare_docs_build_mode(config, docs)
|
|
||||||
return docbuild(config, docs, **kwargs)
|
return docbuild(config, docs, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue