From 74089e4ac2d1a2f96ec922b0f6f5bf59956a3ca9 Mon Sep 17 00:00:00 2001 From: Dirk Baechle Date: Wed, 24 Jun 2020 17:18:02 +0200 Subject: Fix for failing Docbook slides tests. --- SCons/Tool/docbook/__init__.py | 27 ++++++++++++++---- .../basedir/slideshtml/image/.exclude_tests | 1 + test/Docbook/basedir/slideshtml/image/SConstruct | 11 +++++++- .../basedir/slideshtml/image/SConstruct.cmd | 11 +++++++- test/Docbook/basedir/slideshtml/image/slides.xsl | 18 +----------- test/Docbook/basedir/slideshtml/image/virtns.xml | 33 ++++++++++++++++++++++ test/Docbook/basedir/slideshtml/image/xsltver.py | 20 +++++++++++++ test/Docbook/basedir/slideshtml/slideshtml.py | 7 +---- test/Docbook/basedir/slideshtml/slideshtml_cmd.py | 7 +---- test/Docbook/basic/slideshtml/image/.exclude_tests | 1 + test/Docbook/basic/slideshtml/image/SConstruct | 11 +++++++- test/Docbook/basic/slideshtml/image/SConstruct.cmd | 11 +++++++- test/Docbook/basic/slideshtml/image/virtns.xml | 33 ++++++++++++++++++++++ test/Docbook/basic/slideshtml/image/xsltver.py | 20 +++++++++++++ test/Docbook/basic/slideshtml/slideshtml.py | 7 +---- test/Docbook/basic/slideshtml/slideshtml_cmd.py | 7 +---- .../rootname/slideshtml/image/.exclude_tests | 1 + test/Docbook/rootname/slideshtml/image/SConstruct | 11 +++++++- test/Docbook/rootname/slideshtml/image/slides.xsl | 18 +----------- test/Docbook/rootname/slideshtml/image/virtns.xml | 33 ++++++++++++++++++++++ test/Docbook/rootname/slideshtml/image/xsltver.py | 20 +++++++++++++ test/Docbook/rootname/slideshtml/slideshtml.py | 7 +---- 22 files changed, 240 insertions(+), 75 deletions(-) create mode 100644 test/Docbook/basedir/slideshtml/image/.exclude_tests create mode 100644 test/Docbook/basedir/slideshtml/image/virtns.xml create mode 100644 test/Docbook/basedir/slideshtml/image/xsltver.py create mode 100644 test/Docbook/basic/slideshtml/image/.exclude_tests create mode 100644 test/Docbook/basic/slideshtml/image/virtns.xml create mode 100644 test/Docbook/basic/slideshtml/image/xsltver.py create mode 100644 test/Docbook/rootname/slideshtml/image/.exclude_tests create mode 100644 test/Docbook/rootname/slideshtml/image/virtns.xml create mode 100644 test/Docbook/rootname/slideshtml/image/xsltver.py diff --git a/SCons/Tool/docbook/__init__.py b/SCons/Tool/docbook/__init__.py index c5261a2..366dff4 100644 --- a/SCons/Tool/docbook/__init__.py +++ b/SCons/Tool/docbook/__init__.py @@ -255,7 +255,16 @@ def __generate_xsltproc_action(source, target, env, for_signature): base_dir = env.subst('$base_dir') if base_dir: # Yes, so replace target path by its filename - return cmd.replace('$TARGET','${TARGET.file}') + return cmd.replace('$TARGET', os.path.join(base_dir, '${TARGET.file}')) + return cmd + +def __generate_xsltproc_nobase_action(source, target, env, for_signature): + cmd = env['DOCBOOK_XSLTPROCCOM'] + # Does the environment have a base_dir defined? + base_dir = env.subst('$base_dir') + if base_dir: + # Yes, so replace target path by its filename + return cmd.replace('$TARGET', '${TARGET.file}') return cmd @@ -374,6 +383,12 @@ __xsltproc_builder = SCons.Builder.Builder( src_suffix = '.xml', source_scanner = docbook_xml_scanner, emitter = __emit_xsl_basedir) +__xsltproc_nobase_builder = SCons.Builder.Builder( + action = SCons.Action.CommandGeneratorAction(__generate_xsltproc_nobase_action, + {'cmdstr' : '$DOCBOOK_XSLTPROCCOMSTR'}), + src_suffix = '.xml', + source_scanner = docbook_xml_scanner, + emitter = __emit_xsl_basedir) __xmllint_builder = SCons.Builder.Builder( action = SCons.Action.Action('$DOCBOOK_XMLLINTCOM','$DOCBOOK_XMLLINTCOMSTR'), suffix = '.xml', @@ -450,7 +465,7 @@ def DocbookEpub(env, target, source=None, *args, **kw): __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_EPUB', ['epub','docbook.xsl']) # Setup builder - __builder = __select_builder(__lxml_noresult_builder, __xsltproc_builder) + __builder = __select_builder(__lxml_noresult_builder, __xsltproc_nobase_builder) # Create targets result = [] @@ -519,7 +534,7 @@ def DocbookHtmlChunked(env, target, source=None, *args, **kw): __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTMLCHUNKED', ['html','chunkfast.xsl']) # Setup builder - __builder = __select_builder(__lxml_noresult_builder, __xsltproc_builder) + __builder = __select_builder(__lxml_noresult_builder, __xsltproc_nobase_builder) # Detect base dir base_dir = kw.get('base_dir', '') @@ -554,7 +569,7 @@ def DocbookHtmlhelp(env, target, source=None, *args, **kw): __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_HTMLHELP', ['htmlhelp','htmlhelp.xsl']) # Setup builder - __builder = __select_builder(__lxml_noresult_builder, __xsltproc_builder) + __builder = __select_builder(__lxml_noresult_builder, __xsltproc_nobase_builder) # Detect base dir base_dir = kw.get('base_dir', '') @@ -700,10 +715,10 @@ def DocbookSlidesHtml(env, target, source=None, *args, **kw): source = [source] # Init XSL stylesheet - __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_SLIDESHTML', ['slides','html','plain.xsl']) + __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_SLIDESHTML', ['slides','xhtml','plain.xsl']) # Setup builder - __builder = __select_builder(__lxml_noresult_builder, __xsltproc_builder) + __builder = __select_builder(__lxml_builder, __xsltproc_builder) # Detect base dir base_dir = kw.get('base_dir', '') diff --git a/test/Docbook/basedir/slideshtml/image/.exclude_tests b/test/Docbook/basedir/slideshtml/image/.exclude_tests new file mode 100644 index 0000000..966db3c --- /dev/null +++ b/test/Docbook/basedir/slideshtml/image/.exclude_tests @@ -0,0 +1 @@ +xsltver.py \ No newline at end of file diff --git a/test/Docbook/basedir/slideshtml/image/SConstruct b/test/Docbook/basedir/slideshtml/image/SConstruct index 0620efb..2bb86f0 100644 --- a/test/Docbook/basedir/slideshtml/image/SConstruct +++ b/test/Docbook/basedir/slideshtml/image/SConstruct @@ -1,3 +1,12 @@ +import xsltver + +v = xsltver.detectXsltVersion('/usr/share/xml/docbook/stylesheet/docbook-xsl') + +ns_ext = '' +if v >= (1, 78, 0): + # Use namespace-aware input file + ns_ext = 'ns' + env = Environment(tools=['docbook']) -env.DocbookSlidesHtml('virt', xsl='slides.xsl', base_dir='output/') +env.DocbookSlidesHtml('virt'+ns_ext, xsl='slides.xsl', base_dir='output/') diff --git a/test/Docbook/basedir/slideshtml/image/SConstruct.cmd b/test/Docbook/basedir/slideshtml/image/SConstruct.cmd index d5b73f9..f82444d 100644 --- a/test/Docbook/basedir/slideshtml/image/SConstruct.cmd +++ b/test/Docbook/basedir/slideshtml/image/SConstruct.cmd @@ -1,4 +1,13 @@ +import xsltver + +v = xsltver.detectXsltVersion('/usr/share/xml/docbook/stylesheet/docbook-xsl') + +ns_ext = '' +if v >= (1, 78, 0): + # Use namespace-aware input file + ns_ext = 'ns' + env = Environment(DOCBOOK_PREFER_XSLTPROC=1, tools=['docbook']) env.Append(DOCBOOK_XSLTPROCFLAGS=['--novalid', '--nonet']) -env.DocbookSlidesHtml('virt', xsl='slides.xsl', base_dir='output/') +env.DocbookSlidesHtml('virt'+ns_ext, xsl='slides.xsl', base_dir='output/') diff --git a/test/Docbook/basedir/slideshtml/image/slides.xsl b/test/Docbook/basedir/slideshtml/image/slides.xsl index 24e076d..a94e54f 100644 --- a/test/Docbook/basedir/slideshtml/image/slides.xsl +++ b/test/Docbook/basedir/slideshtml/image/slides.xsl @@ -26,6 +26,7 @@ @@ -34,22 +35,5 @@ - -/appendix toc,title -article/appendix nop -/article toc,title -book toc,title,figure,table,example,equation -/chapter toc,title -part toc,title -/preface toc,title -reference toc,title -/sect1 toc -/sect2 toc -/sect3 toc -/sect4 toc -/sect5 toc -/section toc -set toc,title - diff --git a/test/Docbook/basedir/slideshtml/image/virtns.xml b/test/Docbook/basedir/slideshtml/image/virtns.xml new file mode 100644 index 0000000..f64c624 --- /dev/null +++ b/test/Docbook/basedir/slideshtml/image/virtns.xml @@ -0,0 +1,33 @@ + + + + Virtuelles Kopieren + + Virtuelles Kopieren + + + 2007 + + Femutec GmbH + + + + Dirk + + Baechle + + + 09.07.2007 + + + +Group + + sfForming + + + + + diff --git a/test/Docbook/basedir/slideshtml/image/xsltver.py b/test/Docbook/basedir/slideshtml/image/xsltver.py new file mode 100644 index 0000000..c845324 --- /dev/null +++ b/test/Docbook/basedir/slideshtml/image/xsltver.py @@ -0,0 +1,20 @@ +import os +import re + +def detectXsltVersion(fpath): + """ Return a tuple with the version of the Docbook XSLT stylesheets, + or (0, 0, 0) if no stylesheets are installed or the VERSION + file couldn't be found/parsed correctly. + """ + with open(os.path.join(fpath, 'VERSION'), 'rb') as fin: + re_version = re.compile("([^<]+)".encode('utf-8')) + m = re_version.search(fin.read()) + if m: + try: + return tuple(map(int, m.group(1).split(b'.'))) + except Exception: + return (0, 0, 0) + + return (0, 0, 0) + + return (0, 0, 0) diff --git a/test/Docbook/basedir/slideshtml/slideshtml.py b/test/Docbook/basedir/slideshtml/slideshtml.py index b4bdec3..674138d 100644 --- a/test/Docbook/basedir/slideshtml/slideshtml.py +++ b/test/Docbook/basedir/slideshtml/slideshtml.py @@ -46,16 +46,11 @@ test.dir_fixture('image') # Normal invocation test.run(stderr=None) test.must_not_be_empty(test.workpath('output/index.html')) -test.must_not_be_empty(test.workpath('output/toc.html')) -test.must_not_be_empty(test.workpath('output/foil01.html')) -test.must_not_be_empty(test.workpath('output/foilgroup01.html')) +test.must_contain(test.workpath('output/index.html'), 'sfForming') # Cleanup test.run(arguments='-c') test.must_not_exist(test.workpath('output/index.html')) -test.must_not_exist(test.workpath('output/toc.html')) -test.must_not_exist(test.workpath('output/foil01.html')) -test.must_not_exist(test.workpath('output/foilgroup01.html')) test.pass_test() diff --git a/test/Docbook/basedir/slideshtml/slideshtml_cmd.py b/test/Docbook/basedir/slideshtml/slideshtml_cmd.py index 5d2556d..901d94e 100644 --- a/test/Docbook/basedir/slideshtml/slideshtml_cmd.py +++ b/test/Docbook/basedir/slideshtml/slideshtml_cmd.py @@ -43,16 +43,11 @@ test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd'], stderr=None) test.must_not_be_empty(test.workpath('output/index.html')) -test.must_not_be_empty(test.workpath('output/toc.html')) -test.must_not_be_empty(test.workpath('output/foil01.html')) -test.must_not_be_empty(test.workpath('output/foilgroup01.html')) +test.must_contain(test.workpath('output/index.html'), 'sfForming') # Cleanup test.run(arguments=['-f','SConstruct.cmd','-c'], stderr=None) test.must_not_exist(test.workpath('output/index.html')) -test.must_not_exist(test.workpath('output/toc.html')) -test.must_not_exist(test.workpath('output/foil01.html')) -test.must_not_exist(test.workpath('output/foilgroup01.html')) test.pass_test() diff --git a/test/Docbook/basic/slideshtml/image/.exclude_tests b/test/Docbook/basic/slideshtml/image/.exclude_tests new file mode 100644 index 0000000..966db3c --- /dev/null +++ b/test/Docbook/basic/slideshtml/image/.exclude_tests @@ -0,0 +1 @@ +xsltver.py \ No newline at end of file diff --git a/test/Docbook/basic/slideshtml/image/SConstruct b/test/Docbook/basic/slideshtml/image/SConstruct index 034a3c7..e1437da 100644 --- a/test/Docbook/basic/slideshtml/image/SConstruct +++ b/test/Docbook/basic/slideshtml/image/SConstruct @@ -1,3 +1,12 @@ +import xsltver + +v = xsltver.detectXsltVersion('/usr/share/xml/docbook/stylesheet/docbook-xsl') + +ns_ext = '' +if v >= (1, 78, 0): + # Use namespace-aware input file + ns_ext = 'ns' + env = Environment(tools=['docbook']) -env.DocbookSlidesHtml('virt') +env.DocbookSlidesHtml('virt'+ns_ext, xsl='/usr/share/xml/docbook/stylesheet/docbook-xsl/slides/xhtml/plain.xsl') diff --git a/test/Docbook/basic/slideshtml/image/SConstruct.cmd b/test/Docbook/basic/slideshtml/image/SConstruct.cmd index ad5668c..08cbc31 100644 --- a/test/Docbook/basic/slideshtml/image/SConstruct.cmd +++ b/test/Docbook/basic/slideshtml/image/SConstruct.cmd @@ -1,4 +1,13 @@ +import xsltver + +v = xsltver.detectXsltVersion('/usr/share/xml/docbook/stylesheet/docbook-xsl') + +ns_ext = '' +if v >= (1, 78, 0): + # Use namespace-aware input file + ns_ext = 'ns' + env = Environment(DOCBOOK_PREFER_XSLTPROC=1, tools=['docbook']) env.Append(DOCBOOK_XSLTPROCFLAGS=['--novalid', '--nonet']) -env.DocbookSlidesHtml('virt') +env.DocbookSlidesHtml('virt'+ns_ext, xsl='/usr/share/xml/docbook/stylesheet/docbook-xsl/slides/xhtml/plain.xsl') diff --git a/test/Docbook/basic/slideshtml/image/virtns.xml b/test/Docbook/basic/slideshtml/image/virtns.xml new file mode 100644 index 0000000..f64c624 --- /dev/null +++ b/test/Docbook/basic/slideshtml/image/virtns.xml @@ -0,0 +1,33 @@ + + + + Virtuelles Kopieren + + Virtuelles Kopieren + + + 2007 + + Femutec GmbH + + + + Dirk + + Baechle + + + 09.07.2007 + + + +Group + + sfForming + + + + + diff --git a/test/Docbook/basic/slideshtml/image/xsltver.py b/test/Docbook/basic/slideshtml/image/xsltver.py new file mode 100644 index 0000000..c845324 --- /dev/null +++ b/test/Docbook/basic/slideshtml/image/xsltver.py @@ -0,0 +1,20 @@ +import os +import re + +def detectXsltVersion(fpath): + """ Return a tuple with the version of the Docbook XSLT stylesheets, + or (0, 0, 0) if no stylesheets are installed or the VERSION + file couldn't be found/parsed correctly. + """ + with open(os.path.join(fpath, 'VERSION'), 'rb') as fin: + re_version = re.compile("([^<]+)".encode('utf-8')) + m = re_version.search(fin.read()) + if m: + try: + return tuple(map(int, m.group(1).split(b'.'))) + except Exception: + return (0, 0, 0) + + return (0, 0, 0) + + return (0, 0, 0) diff --git a/test/Docbook/basic/slideshtml/slideshtml.py b/test/Docbook/basic/slideshtml/slideshtml.py index 2cfe3e8..9359210 100644 --- a/test/Docbook/basic/slideshtml/slideshtml.py +++ b/test/Docbook/basic/slideshtml/slideshtml.py @@ -46,16 +46,11 @@ test.dir_fixture('image') # Normal invocation test.run(stderr=None) test.must_not_be_empty(test.workpath('index.html')) -test.must_not_be_empty(test.workpath('toc.html')) -test.must_not_be_empty(test.workpath('foil01.html')) -test.must_not_be_empty(test.workpath('foilgroup01.html')) +test.must_contain(test.workpath('index.html'), 'sfForming') # Cleanup test.run(arguments='-c') test.must_not_exist(test.workpath('index.html')) -test.must_not_exist(test.workpath('toc.html')) -test.must_not_exist(test.workpath('foil01.html')) -test.must_not_exist(test.workpath('foilgroup01.html')) test.pass_test() diff --git a/test/Docbook/basic/slideshtml/slideshtml_cmd.py b/test/Docbook/basic/slideshtml/slideshtml_cmd.py index c51f831..7ebc8d4 100644 --- a/test/Docbook/basic/slideshtml/slideshtml_cmd.py +++ b/test/Docbook/basic/slideshtml/slideshtml_cmd.py @@ -43,16 +43,11 @@ test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd'], stderr=None) test.must_not_be_empty(test.workpath('index.html')) -test.must_not_be_empty(test.workpath('toc.html')) -test.must_not_be_empty(test.workpath('foil01.html')) -test.must_not_be_empty(test.workpath('foilgroup01.html')) +test.must_contain(test.workpath('index.html'), 'sfForming') # Cleanup test.run(arguments=['-f','SConstruct.cmd','-c'], stderr=None) test.must_not_exist(test.workpath('index.html')) -test.must_not_exist(test.workpath('toc.html')) -test.must_not_exist(test.workpath('foil01.html')) -test.must_not_exist(test.workpath('foilgroup01.html')) test.pass_test() diff --git a/test/Docbook/rootname/slideshtml/image/.exclude_tests b/test/Docbook/rootname/slideshtml/image/.exclude_tests new file mode 100644 index 0000000..966db3c --- /dev/null +++ b/test/Docbook/rootname/slideshtml/image/.exclude_tests @@ -0,0 +1 @@ +xsltver.py \ No newline at end of file diff --git a/test/Docbook/rootname/slideshtml/image/SConstruct b/test/Docbook/rootname/slideshtml/image/SConstruct index 769314c..4f1079e 100644 --- a/test/Docbook/rootname/slideshtml/image/SConstruct +++ b/test/Docbook/rootname/slideshtml/image/SConstruct @@ -1,3 +1,12 @@ +import xsltver + +v = xsltver.detectXsltVersion('/usr/share/xml/docbook/stylesheet/docbook-xsl') + +ns_ext = '' +if v >= (1, 78, 0): + # Use namespace-aware input file + ns_ext = 'ns' + env = Environment(tools=['docbook']) -env.DocbookSlidesHtml('manual.html', 'virt', xsl='slides.xsl') +env.DocbookSlidesHtml('manual.html', 'virt'+ns_ext, xsl='slides.xsl') diff --git a/test/Docbook/rootname/slideshtml/image/slides.xsl b/test/Docbook/rootname/slideshtml/image/slides.xsl index 29058f1..a490b0a 100644 --- a/test/Docbook/rootname/slideshtml/image/slides.xsl +++ b/test/Docbook/rootname/slideshtml/image/slides.xsl @@ -26,6 +26,7 @@ @@ -34,22 +35,5 @@ - -/appendix toc,title -article/appendix nop -/article toc,title -book toc,title,figure,table,example,equation -/chapter toc,title -part toc,title -/preface toc,title -reference toc,title -/sect1 toc -/sect2 toc -/sect3 toc -/sect4 toc -/sect5 toc -/section toc -set toc,title - diff --git a/test/Docbook/rootname/slideshtml/image/virtns.xml b/test/Docbook/rootname/slideshtml/image/virtns.xml new file mode 100644 index 0000000..f64c624 --- /dev/null +++ b/test/Docbook/rootname/slideshtml/image/virtns.xml @@ -0,0 +1,33 @@ + + + + Virtuelles Kopieren + + Virtuelles Kopieren + + + 2007 + + Femutec GmbH + + + + Dirk + + Baechle + + + 09.07.2007 + + + +Group + + sfForming + + + + + diff --git a/test/Docbook/rootname/slideshtml/image/xsltver.py b/test/Docbook/rootname/slideshtml/image/xsltver.py new file mode 100644 index 0000000..c845324 --- /dev/null +++ b/test/Docbook/rootname/slideshtml/image/xsltver.py @@ -0,0 +1,20 @@ +import os +import re + +def detectXsltVersion(fpath): + """ Return a tuple with the version of the Docbook XSLT stylesheets, + or (0, 0, 0) if no stylesheets are installed or the VERSION + file couldn't be found/parsed correctly. + """ + with open(os.path.join(fpath, 'VERSION'), 'rb') as fin: + re_version = re.compile("([^<]+)".encode('utf-8')) + m = re_version.search(fin.read()) + if m: + try: + return tuple(map(int, m.group(1).split(b'.'))) + except Exception: + return (0, 0, 0) + + return (0, 0, 0) + + return (0, 0, 0) diff --git a/test/Docbook/rootname/slideshtml/slideshtml.py b/test/Docbook/rootname/slideshtml/slideshtml.py index 2d8500e..daa5d8d 100644 --- a/test/Docbook/rootname/slideshtml/slideshtml.py +++ b/test/Docbook/rootname/slideshtml/slideshtml.py @@ -46,16 +46,11 @@ test.dir_fixture('image') # Normal invocation test.run(stderr=None) test.must_not_be_empty(test.workpath('manual.html')) -test.must_not_be_empty(test.workpath('toc.html')) -test.must_not_be_empty(test.workpath('foil01.html')) -test.must_not_be_empty(test.workpath('foilgroup01.html')) +test.must_contain(test.workpath('manual.html'), 'sfForming') # Cleanup test.run(arguments='-c') test.must_not_exist(test.workpath('manual.html')) -test.must_not_exist(test.workpath('toc.html')) -test.must_not_exist(test.workpath('foil01.html')) -test.must_not_exist(test.workpath('foilgroup01.html')) test.pass_test() -- cgit v0.12