From 917afa48a975454fc8280176a729df38ebcde02d Mon Sep 17 00:00:00 2001 From: Dirk Baechle Date: Sun, 21 Jun 2020 15:53:50 +0200 Subject: Fixed Docbook Tool and updated its tests. --- SCons/Tool/docbook/__init__.py | 19 +- SCons/Tool/docbook/__init__.xml | 4 +- doc/SConscript | 2 +- test/Docbook/basedir/htmlchunked/htmlchunked.py | 10 +- .../Docbook/basedir/htmlchunked/htmlchunked_cmd.py | 2 +- test/Docbook/basedir/htmlhelp/htmlhelp.py | 14 +- test/Docbook/basedir/htmlhelp/htmlhelp_cmd.py | 6 +- .../basedir/slideshtml/image/SConstruct.cmd | 1 + test/Docbook/basedir/slideshtml/image/virt.xml | 2 +- test/Docbook/basedir/slideshtml/slideshtml.py | 19 +- test/Docbook/basedir/slideshtml/slideshtml_cmd.py | 13 +- test/Docbook/basic/epub/epub.py | 16 +- test/Docbook/basic/epub/epub_cmd.py | 8 +- test/Docbook/basic/html/html.py | 10 +- test/Docbook/basic/html/html_cmd.py | 2 +- test/Docbook/basic/htmlchunked/htmlchunked.py | 10 +- test/Docbook/basic/htmlchunked/htmlchunked_cmd.py | 2 +- test/Docbook/basic/htmlhelp/htmlhelp.py | 14 +- test/Docbook/basic/htmlhelp/htmlhelp_cmd.py | 6 +- test/Docbook/basic/man/man.py | 12 +- test/Docbook/basic/man/man_cmd.py | 4 +- test/Docbook/basic/pdf/image/SConstruct | 3 + test/Docbook/basic/pdf/image/SConstruct.cmd | 7 + test/Docbook/basic/pdf/image/manual.xml | 388 +++++++++++++++++++++ test/Docbook/basic/pdf/pdf.py | 60 ++++ test/Docbook/basic/pdf/pdf_cmd.py | 60 ++++ test/Docbook/basic/slideshtml/image/SConstruct.cmd | 1 + test/Docbook/basic/slideshtml/image/virt.xml | 2 +- test/Docbook/basic/slideshtml/slideshtml.py | 19 +- test/Docbook/basic/slideshtml/slideshtml_cmd.py | 13 +- test/Docbook/basic/slidespdf/image/SConstruct | 3 + test/Docbook/basic/slidespdf/image/SConstruct.cmd | 4 + test/Docbook/basic/slidespdf/image/virt.xml | 33 ++ test/Docbook/basic/slidespdf/slidespdf.py | 66 ++++ test/Docbook/basic/slidespdf/slidespdf_cmd.py | 63 ++++ test/Docbook/basic/xinclude/xinclude.py | 10 +- test/Docbook/basic/xslt/image/SConstruct | 9 + test/Docbook/basic/xslt/image/in.xml | 77 ++++ test/Docbook/basic/xslt/image/to_docbook.xslt | 102 ++++++ test/Docbook/basic/xslt/xslt.py | 57 +++ test/Docbook/dependencies/xinclude/xinclude.py | 12 +- test/Docbook/rootname/htmlchunked/htmlchunked.py | 10 +- test/Docbook/rootname/htmlhelp/htmlhelp.py | 14 +- test/Docbook/rootname/slideshtml/image/virt.xml | 2 +- test/Docbook/rootname/slideshtml/slideshtml.py | 19 +- testing/framework/TestCommon.py | 19 + testing/framework/TestCommonTests.py | 52 +++ 47 files changed, 1113 insertions(+), 168 deletions(-) create mode 100644 test/Docbook/basic/pdf/image/SConstruct create mode 100644 test/Docbook/basic/pdf/image/SConstruct.cmd create mode 100644 test/Docbook/basic/pdf/image/manual.xml create mode 100644 test/Docbook/basic/pdf/pdf.py create mode 100644 test/Docbook/basic/pdf/pdf_cmd.py create mode 100644 test/Docbook/basic/slidespdf/image/SConstruct create mode 100644 test/Docbook/basic/slidespdf/image/SConstruct.cmd create mode 100644 test/Docbook/basic/slidespdf/image/virt.xml create mode 100644 test/Docbook/basic/slidespdf/slidespdf.py create mode 100644 test/Docbook/basic/slidespdf/slidespdf_cmd.py create mode 100644 test/Docbook/basic/xslt/image/SConstruct create mode 100644 test/Docbook/basic/xslt/image/in.xml create mode 100644 test/Docbook/basic/xslt/image/to_docbook.xslt create mode 100644 test/Docbook/basic/xslt/xslt.py diff --git a/SCons/Tool/docbook/__init__.py b/SCons/Tool/docbook/__init__.py index 504c853..c5261a2 100644 --- a/SCons/Tool/docbook/__init__.py +++ b/SCons/Tool/docbook/__init__.py @@ -307,9 +307,10 @@ def __build_lxml(target, source, env): return None -def __build_lxml_manpage(target, source, env): +def __build_lxml_noresult(target, source, env): """ - Specialized XSLT builder for manpages, using the lxml module. + Specialized XSLT builder for transformations without a direct result where the Docbook + stylesheet itself creates the target file, using the lxml module. """ from lxml import etree @@ -355,8 +356,8 @@ __lxml_builder = SCons.Builder.Builder( source_scanner = docbook_xml_scanner, emitter = __emit_xsl_basedir) -__lxml_manpage_builder = SCons.Builder.Builder( - action = __build_lxml_manpage, +__lxml_noresult_builder = SCons.Builder.Builder( + action = __build_lxml_noresult, src_suffix = '.xml', source_scanner = docbook_xml_scanner, emitter = __emit_xsl_basedir) @@ -449,7 +450,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_builder, __xsltproc_builder) + __builder = __select_builder(__lxml_noresult_builder, __xsltproc_builder) # Create targets result = [] @@ -518,7 +519,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_builder, __xsltproc_builder) + __builder = __select_builder(__lxml_noresult_builder, __xsltproc_builder) # Detect base dir base_dir = kw.get('base_dir', '') @@ -553,7 +554,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_builder, __xsltproc_builder) + __builder = __select_builder(__lxml_noresult_builder, __xsltproc_builder) # Detect base dir base_dir = kw.get('base_dir', '') @@ -606,7 +607,7 @@ def DocbookMan(env, target, source=None, *args, **kw): __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_MAN', ['manpages','docbook.xsl']) # Setup builder - __builder = __select_builder(__lxml_manpage_builder, __xsltproc_builder) + __builder = __select_builder(__lxml_noresult_builder, __xsltproc_builder) # Create targets result = [] @@ -702,7 +703,7 @@ def DocbookSlidesHtml(env, target, source=None, *args, **kw): __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT_XSL_SLIDESHTML', ['slides','html','plain.xsl']) # Setup builder - __builder = __select_builder(__lxml_builder, __xsltproc_builder) + __builder = __select_builder(__lxml_noresult_builder, __xsltproc_builder) # Detect base dir base_dir = kw.get('base_dir', '') diff --git a/SCons/Tool/docbook/__init__.xml b/SCons/Tool/docbook/__init__.xml index 0835440..4c079b7 100644 --- a/SCons/Tool/docbook/__init__.xml +++ b/SCons/Tool/docbook/__init__.xml @@ -254,7 +254,7 @@ The path to the external executable xsltproc (or saxon, xalan), if one of them is installed. Note, that this is only used as last fallback for XSL transformations, if -no libxml2 or lxml Python binding can be imported in the current system. +no lxml Python binding can be imported in the current system. @@ -264,7 +264,7 @@ no libxml2 or lxml Python binding can be imported in the current system. The path to the external executable xmllint, if it's installed. Note, that this is only used as last fallback for resolving -XIncludes, if no libxml2 or lxml Python binding can be imported +XIncludes, if no lxml Python binding can be imported in the current system. diff --git a/doc/SConscript b/doc/SConscript index 4ab4200..46fb5ff 100644 --- a/doc/SConscript +++ b/doc/SConscript @@ -44,7 +44,7 @@ try: except ImportError as exc: print("doc: SConsDoc failed to import, the error was:") print(" ImportError: %s" % exc) - print(" Please make sure that python-libxml2 or python-lxml is installed.") + print(" Please make sure that python-lxml is installed.") skip_doc = True fop = whereis('fop') diff --git a/test/Docbook/basedir/htmlchunked/htmlchunked.py b/test/Docbook/basedir/htmlchunked/htmlchunked.py index f97555b..893761c 100644 --- a/test/Docbook/basedir/htmlchunked/htmlchunked.py +++ b/test/Docbook/basedir/htmlchunked/htmlchunked.py @@ -37,19 +37,15 @@ if not (sys.platform.startswith('linux') and test.skip_test('Wrong OS or no stylesheets installed, skipping test.\n') try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('output/index.html')) +test.must_not_be_empty(test.workpath('output/index.html')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/basedir/htmlchunked/htmlchunked_cmd.py b/test/Docbook/basedir/htmlchunked/htmlchunked_cmd.py index b507eb1..3ad6369 100644 --- a/test/Docbook/basedir/htmlchunked/htmlchunked_cmd.py +++ b/test/Docbook/basedir/htmlchunked/htmlchunked_cmd.py @@ -42,7 +42,7 @@ test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd'], stderr=None) -test.must_exist(test.workpath('output/index.html')) +test.must_not_be_empty(test.workpath('output/index.html')) # Cleanup test.run(arguments=['-f','SConstruct.cmd','-c']) diff --git a/test/Docbook/basedir/htmlhelp/htmlhelp.py b/test/Docbook/basedir/htmlhelp/htmlhelp.py index 17aba09..7fbc875 100644 --- a/test/Docbook/basedir/htmlhelp/htmlhelp.py +++ b/test/Docbook/basedir/htmlhelp/htmlhelp.py @@ -37,21 +37,17 @@ if not (sys.platform.startswith('linux') and test.skip_test('Wrong OS or no stylesheets installed, skipping test.\n') try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('output/index.html')) -test.must_exist(test.workpath('htmlhelp.hhp')) -test.must_exist(test.workpath('toc.hhc')) +test.must_not_be_empty(test.workpath('output/index.html')) +test.must_not_be_empty(test.workpath('htmlhelp.hhp')) +test.must_not_be_empty(test.workpath('toc.hhc')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/basedir/htmlhelp/htmlhelp_cmd.py b/test/Docbook/basedir/htmlhelp/htmlhelp_cmd.py index a0f5e8a..2b004c6 100644 --- a/test/Docbook/basedir/htmlhelp/htmlhelp_cmd.py +++ b/test/Docbook/basedir/htmlhelp/htmlhelp_cmd.py @@ -42,9 +42,9 @@ test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd'], stderr=None) -test.must_exist(test.workpath('output/index.html')) -test.must_exist(test.workpath('htmlhelp.hhp')) -test.must_exist(test.workpath('toc.hhc')) +test.must_not_be_empty(test.workpath('output/index.html')) +test.must_not_be_empty(test.workpath('htmlhelp.hhp')) +test.must_not_be_empty(test.workpath('toc.hhc')) # Cleanup test.run(arguments=['-f','SConstruct.cmd','-c']) diff --git a/test/Docbook/basedir/slideshtml/image/SConstruct.cmd b/test/Docbook/basedir/slideshtml/image/SConstruct.cmd index 297aeb5..d5b73f9 100644 --- a/test/Docbook/basedir/slideshtml/image/SConstruct.cmd +++ b/test/Docbook/basedir/slideshtml/image/SConstruct.cmd @@ -1,3 +1,4 @@ env = Environment(DOCBOOK_PREFER_XSLTPROC=1, tools=['docbook']) +env.Append(DOCBOOK_XSLTPROCFLAGS=['--novalid', '--nonet']) env.DocbookSlidesHtml('virt', xsl='slides.xsl', base_dir='output/') diff --git a/test/Docbook/basedir/slideshtml/image/virt.xml b/test/Docbook/basedir/slideshtml/image/virt.xml index aec1fd7..9cdf778 100644 --- a/test/Docbook/basedir/slideshtml/image/virt.xml +++ b/test/Docbook/basedir/slideshtml/image/virt.xml @@ -1,6 +1,6 @@ +"http://docbook.sourceforge.net/release/slides/3.3.1/schema/dtd/slides.dtd"> Virtuelles Kopieren diff --git a/test/Docbook/basedir/slideshtml/slideshtml.py b/test/Docbook/basedir/slideshtml/slideshtml.py index a89edcd..de3cd83 100644 --- a/test/Docbook/basedir/slideshtml/slideshtml.py +++ b/test/Docbook/basedir/slideshtml/slideshtml.py @@ -33,27 +33,22 @@ import TestSCons test = TestSCons.TestSCons() if not (sys.platform.startswith('linux') and - os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides') and - os.path.isdir('/usr/share/xml/docbook/custom/slides/3.3.1')): + os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides')): test.skip_test('Wrong OS or no "slides" stylesheets installed, skipping test.\n') try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('output/index.html')) -test.must_exist(test.workpath('output/toc.html')) -test.must_exist(test.workpath('output/foil01.html')) -test.must_exist(test.workpath('output/foilgroup01.html')) +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')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/basedir/slideshtml/slideshtml_cmd.py b/test/Docbook/basedir/slideshtml/slideshtml_cmd.py index 51ed6e4..5d2556d 100644 --- a/test/Docbook/basedir/slideshtml/slideshtml_cmd.py +++ b/test/Docbook/basedir/slideshtml/slideshtml_cmd.py @@ -35,21 +35,20 @@ test = TestSCons.TestSCons() xsltproc = test.where_is('xsltproc') if not (xsltproc and - os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides') and - os.path.isdir('/usr/share/xml/docbook/custom/slides/3.3.1')): + os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides')): test.skip_test('No xsltproc or no "slides" stylesheets installed, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd'], stderr=None) -test.must_exist(test.workpath('output/index.html')) -test.must_exist(test.workpath('output/toc.html')) -test.must_exist(test.workpath('output/foil01.html')) -test.must_exist(test.workpath('output/foilgroup01.html')) +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')) # Cleanup -test.run(arguments=['-f','SConstruct.cmd','-c']) +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')) diff --git a/test/Docbook/basic/epub/epub.py b/test/Docbook/basic/epub/epub.py index 0a317b6..e2b37a1 100644 --- a/test/Docbook/basic/epub/epub.py +++ b/test/Docbook/basic/epub/epub.py @@ -31,22 +31,18 @@ import TestSCons test = TestSCons.TestSCons() try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('manual.epub')) -test.must_exist(test.workpath('OEBPS','toc.ncx')) -test.must_exist(test.workpath('OEBPS','content.opf')) -test.must_exist(test.workpath('META-INF','container.xml')) +test.must_not_be_empty(test.workpath('manual.epub')) +test.must_not_be_empty(test.workpath('OEBPS','toc.ncx')) +test.must_not_be_empty(test.workpath('OEBPS','content.opf')) +test.must_not_be_empty(test.workpath('META-INF','container.xml')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/basic/epub/epub_cmd.py b/test/Docbook/basic/epub/epub_cmd.py index 285d940..e8affe2 100644 --- a/test/Docbook/basic/epub/epub_cmd.py +++ b/test/Docbook/basic/epub/epub_cmd.py @@ -38,10 +38,10 @@ test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd','DOCBOOK_XSLTPROC=%s'%xsltproc], stderr=None) -test.must_exist(test.workpath('manual.epub')) -test.must_exist(test.workpath('OEBPS','toc.ncx')) -test.must_exist(test.workpath('OEBPS','content.opf')) -test.must_exist(test.workpath('META-INF','container.xml')) +test.must_not_be_empty(test.workpath('manual.epub')) +test.must_not_be_empty(test.workpath('OEBPS','toc.ncx')) +test.must_not_be_empty(test.workpath('OEBPS','content.opf')) +test.must_not_be_empty(test.workpath('META-INF','container.xml')) # Cleanup test.run(arguments=['-f','SConstruct.cmd','-c','DOCBOOK_XSLTPROC=%s'%xsltproc]) diff --git a/test/Docbook/basic/html/html.py b/test/Docbook/basic/html/html.py index acf38a3..d6a3114 100644 --- a/test/Docbook/basic/html/html.py +++ b/test/Docbook/basic/html/html.py @@ -31,19 +31,15 @@ import TestSCons test = TestSCons.TestSCons() try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run() -test.must_exist(test.workpath('manual.html')) +test.must_not_be_empty(test.workpath('manual.html')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/basic/html/html_cmd.py b/test/Docbook/basic/html/html_cmd.py index cfc71b0..122d8bc 100644 --- a/test/Docbook/basic/html/html_cmd.py +++ b/test/Docbook/basic/html/html_cmd.py @@ -39,7 +39,7 @@ test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd','DOCBOOK_XSLTPROC=%s'%xsltproc]) -test.must_exist(test.workpath('manual.html')) +test.must_not_be_empty(test.workpath('manual.html')) # Cleanup test.run(arguments=['-f','SConstruct.cmd','-c','DOCBOOK_XSLTPROC=%s'%xsltproc]) diff --git a/test/Docbook/basic/htmlchunked/htmlchunked.py b/test/Docbook/basic/htmlchunked/htmlchunked.py index 74b8c7a..71f6265 100644 --- a/test/Docbook/basic/htmlchunked/htmlchunked.py +++ b/test/Docbook/basic/htmlchunked/htmlchunked.py @@ -31,19 +31,15 @@ import TestSCons test = TestSCons.TestSCons() try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('index.html')) +test.must_not_be_empty(test.workpath('index.html')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/basic/htmlchunked/htmlchunked_cmd.py b/test/Docbook/basic/htmlchunked/htmlchunked_cmd.py index b194b70..6b79102 100644 --- a/test/Docbook/basic/htmlchunked/htmlchunked_cmd.py +++ b/test/Docbook/basic/htmlchunked/htmlchunked_cmd.py @@ -40,7 +40,7 @@ test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd','DOCBOOK_XSLTPROC=%s'%xsltproc], stderr=None) -test.must_exist(test.workpath('index.html')) +test.must_not_be_empty(test.workpath('index.html')) # Cleanup test.run(arguments=['-f','SConstruct.cmd','-c','DOCBOOK_XSLTPROC=%s'%xsltproc]) diff --git a/test/Docbook/basic/htmlhelp/htmlhelp.py b/test/Docbook/basic/htmlhelp/htmlhelp.py index 080ec60..37c4879 100644 --- a/test/Docbook/basic/htmlhelp/htmlhelp.py +++ b/test/Docbook/basic/htmlhelp/htmlhelp.py @@ -31,21 +31,17 @@ import TestSCons test = TestSCons.TestSCons() try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('index.html')) -test.must_exist(test.workpath('htmlhelp.hhp')) -test.must_exist(test.workpath('toc.hhc')) +test.must_not_be_empty(test.workpath('index.html')) +test.must_not_be_empty(test.workpath('htmlhelp.hhp')) +test.must_not_be_empty(test.workpath('toc.hhc')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/basic/htmlhelp/htmlhelp_cmd.py b/test/Docbook/basic/htmlhelp/htmlhelp_cmd.py index 541ef75..6d3fd10 100644 --- a/test/Docbook/basic/htmlhelp/htmlhelp_cmd.py +++ b/test/Docbook/basic/htmlhelp/htmlhelp_cmd.py @@ -39,9 +39,9 @@ test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd','DOCBOOK_XSLTPROC=%s'%xsltproc], stderr=None) -test.must_exist(test.workpath('index.html')) -test.must_exist(test.workpath('htmlhelp.hhp')) -test.must_exist(test.workpath('toc.hhc')) +test.must_not_be_empty(test.workpath('index.html')) +test.must_not_be_empty(test.workpath('htmlhelp.hhp')) +test.must_not_be_empty(test.workpath('toc.hhc')) # Cleanup test.run(arguments=['-f','SConstruct.cmd','-c','DOCBOOK_XSLTPROC=%s'%xsltproc]) diff --git a/test/Docbook/basic/man/man.py b/test/Docbook/basic/man/man.py index d9b16b3..d8cd716 100644 --- a/test/Docbook/basic/man/man.py +++ b/test/Docbook/basic/man/man.py @@ -31,20 +31,16 @@ import TestSCons test = TestSCons.TestSCons() try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('refdb.8')) -test.must_exist(test.workpath('refdb.sh.8')) +test.must_not_be_empty(test.workpath('refdb.8')) +test.must_not_be_empty(test.workpath('refdb.sh.8')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/basic/man/man_cmd.py b/test/Docbook/basic/man/man_cmd.py index ecfc9bd..88aebb8 100644 --- a/test/Docbook/basic/man/man_cmd.py +++ b/test/Docbook/basic/man/man_cmd.py @@ -39,8 +39,8 @@ test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd','DOCBOOK_XSLTPROC=%s'%xsltproc], stderr=None) -test.must_exist(test.workpath('refdb.8')) -test.must_exist(test.workpath('refdb.sh.8')) +test.must_not_be_empty(test.workpath('refdb.8')) +test.must_not_be_empty(test.workpath('refdb.sh.8')) # Cleanup test.run(arguments=['-f','SConstruct.cmd','-c','DOCBOOK_XSLTPROC=%s'%xsltproc]) diff --git a/test/Docbook/basic/pdf/image/SConstruct b/test/Docbook/basic/pdf/image/SConstruct new file mode 100644 index 0000000..01b2c7f --- /dev/null +++ b/test/Docbook/basic/pdf/image/SConstruct @@ -0,0 +1,3 @@ +env = Environment(tools=['docbook']) +env.DocbookPdf('manual') + diff --git a/test/Docbook/basic/pdf/image/SConstruct.cmd b/test/Docbook/basic/pdf/image/SConstruct.cmd new file mode 100644 index 0000000..db1ed18 --- /dev/null +++ b/test/Docbook/basic/pdf/image/SConstruct.cmd @@ -0,0 +1,7 @@ +env = Environment(DOCBOOK_PREFER_XSLTPROC=1, tools=['docbook']) +DOCBOOK_XSLTPROC = ARGUMENTS.get('DOCBOOK_XSLTPROC', "") +if DOCBOOK_XSLTPROC: + env['DOCBOOK_XSLTPROC'] = DOCBOOK_XSLTPROC + +env.DocbookPdf('manual') + diff --git a/test/Docbook/basic/pdf/image/manual.xml b/test/Docbook/basic/pdf/image/manual.xml new file mode 100644 index 0000000..067c76e --- /dev/null +++ b/test/Docbook/basic/pdf/image/manual.xml @@ -0,0 +1,388 @@ + + + +
+ The SCons qt4 tool + + + + Dirk Baechle + + + 2010-12-06 + + +
+ Basics + + This tool can be used to compile Qt projects, designed for versions + 4.x.y and higher. It is not usable for Qt3 and older versions, since some + of the helper tools (moc, uic) + behave different. + +
+ Install + + Installing it, requires you to copy (or, even better: checkout) + the contents of the package's qt4 folder to + + + + /path_to_your_project/site_scons/site_tools/qt4, + if you need the Qt4 Tool in one project only, or + + + + ~/.scons/site_scons/site_tools/qt4, + for a system-wide installation under your current login. + + + + For more infos about this, please refer to + + + + the SCons User's Guide, chap. 17.7 "Where to put your custom + Builders and Tools" and + + + + the SCons Tools Wiki page at https://github.com/SCons/scons/wiki/ToolsIndex. + + +
+ +
+ How to activate + + For activating the tool "qt4", you have to add its name to the + Environment constructor, like this + + env = Environment(tools=['default','qt4']) + + + On its startup, the Qt4 tool tries to read the variable + QT4DIR from the current Environment and + os.environ. If it is not set, the value of + QTDIR (in Environment/os.environ) + is used as a fallback. + + So, you either have to explicitly give the path of your Qt4 + installation to the Environment with + + env['QT4DIR'] = '/usr/local/Trolltech/Qt-4.2.3' + + + or set the QT4DIR as environment variable in + your shell. +
+ +
+ Requirements + + Under Linux, "qt4" uses the system tool + pkg-config for automatically setting the required + compile and link flags of the single Qt4 modules (like QtCore, + QtGui,...). This means that + + + + you should have pkg-config installed, + and + + + + you additionally have to set + PKG_CONFIG_PATH in your shell environment, such + that it points to $QT4DIR/lib/pkgconfig (or + $QT4DIR/lib for some older versions). + + + + Based on these two environment variables + (QT4DIR and PKG_CONFIG_PATH), the + "qt4" tool initializes all QT4_* construction + variables listed in the Reference manual. This happens when the tool is + "detected" during Environment construction. As a consequence, the setup + of the tool gets a two-stage process, if you want to override the values + provided by your current shell settings: + + # Stage 1: create plain environment +qtEnv = Environment() +# Set new vars +qtEnv['QT4DIR'] = '/usr/local/Trolltech/Qt-4.2.3 +qtEnv['ENV']['PKG_CONFIG_PATH'] = '/usr/local/Trolltech/Qt-4.2.3/lib/pkgconfig' +# Stage 2: add qt4 tool +qtEnv.Tool('qt4') + +
+
+ +
+ Suggested boilerplate + + Based on the requirements above, we suggest a simple ready-to-go + setup as follows: + + SConstruct + + # Detect Qt version +qtdir = detectLatestQtDir() + +# Create base environment +baseEnv = Environment() +#...further customization of base env + +# Clone Qt environment +qtEnv = baseEnv.Clone() +# Set QT4DIR and PKG_CONFIG_PATH +qtEnv['ENV']['PKG_CONFIG_PATH'] = os.path.join(qtdir, 'lib/pkgconfig') +qtEnv['QT4DIR'] = qtdir +# Add qt4 tool +qtEnv.Tool('qt4') +#...further customization of qt env + +# Export environments +Export('baseEnv qtEnv') + +# Your other stuff... +# ...including the call to your SConscripts + + + In a SConscript + + # Get the Qt4 environment +Import('qtEnv') +# Clone it +env = qtEnv.clone() +# Patch it +env.Append(CCFLAGS=['-m32']) # or whatever +# Use it +env.StaticLibrary('foo', Glob('*.cpp')) + + + The detection of the Qt directory could be as simple as directly + assigning a fixed path + + def detectLatestQtDir(): + return "/usr/local/qt4.3.2" + + + or a little more sophisticated + + # Tries to detect the path to the installation of Qt with +# the highest version number +def detectLatestQtDir(): + if sys.platform.startswith("linux"): + # Simple check: inspect only '/usr/local/Trolltech' + paths = glob.glob('/usr/local/Trolltech/*') + if len(paths): + paths.sort() + return paths[-1] + else: + return "" + else: + # Simple check: inspect only 'C:\Qt' + paths = glob.glob('C:\\Qt\\*') + if len(paths): + paths.sort() + return paths[-1] + else: + return os.environ.get("QTDIR","") + +
+ +
+ A first project + + The following SConscript is for a simple project with some cxx + files, using the QtCore, QtGui and QtNetwork modules: + + Import('qtEnv') +env = qtEnv.Clone() +env.EnableQt4Modules([ + 'QtGui', + 'QtCore', + 'QtNetwork' + ]) +# Add your CCFLAGS and CPPPATHs to env here... + +env.Program('foo', Glob('*.cpp')) + +
+ +
+ MOC it up + + For the basic support of automocing, nothing needs to be done by the + user. The tool usually detects the Q_OBJECT macro and + calls the moc executable + accordingly. + + If you don't want this, you can switch off the automocing by + a + + env['QT4_AUTOSCAN'] = 0 + + + in your SConscript file. Then, you have to moc your files + explicitly, using the Moc4 builder. + + You can also switch to an extended automoc strategy with + + env['QT4_AUTOSCAN_STRATEGY'] = 1 + + + Please read the description of the + QT4_AUTOSCAN_STRATEGY variable in the Reference manual + for details. + + For debugging purposes, you can set the variable + QT4_DEBUG with + + env['QT4_DEBUG'] = 1 + + + which outputs a lot of messages during automocing. +
+ +
+ Forms (.ui) + + The header files with setup code for your GUI classes, are not + compiled automatically from your .ui files. You always + have to call the Uic4 builder explicitly like + + env.Uic4(Glob('*.ui')) +env.Program('foo', Glob('*.cpp')) + +
+ +
+ Resource files (.qrc) + + Resource files are not built automatically, you always have to add + the names of the .qrc files to the source list for your + program or library: + + env.Program('foo', Glob('*.cpp')+Glob('*.qrc')) + + + For each of the Resource input files, its prefix defines the name of + the resulting resource. An appropriate + -name option is added to the call of the + rcc executable by default. + + You can also call the Qrc4 builder explicitly as + + qrccc = env.Qrc4('foo') # ['foo.qrc'] -> ['qrc_foo.cc'] + + + or (overriding the default suffix) + + qrccc = env.Qrc4('myprefix_foo.cxx','foo.qrc') # -> ['qrc_myprefix_foo.cxx'] + + + and then add the resulting cxx file to the sources of your + Program/Library: + + env.Program('foo', Glob('*.cpp') + qrccc) + +
+ +
+ Translation files + + The update of the .ts files and the conversion to + binary .qm files is not done automatically. You have to + call the corresponding builders on your own. + + Example for updating a translation file: + + env.Ts4('foo.ts','.') # -> ['foo.ts'] + + + By default, the .ts files are treated as + precious targets. This means that they are not + removed prior to a rebuild, but simply get updated. Additionally, they do + not get cleaned on a scons -c. If you + want to delete the translation files on the + -c SCons command, you can set the + variable QT4_CLEAN_TS like this + + env['QT4_CLEAN_TS']=1 + + + Example for releasing a translation file, i.e. compiling it to a + .qm binary file: + + env.Qm4('foo') # ['foo.ts'] -> ['foo.qm'] + + + or (overriding the output prefix) + + env.Qm4('myprefix','foo') # ['foo.ts'] -> ['myprefix.qm'] + + + As an extension both, the Ts4() and Qm4 builder, support the + definition of multiple targets. So, calling + + env.Ts4(['app_en','app_de'], Glob('*.cpp')) + + + and + + env.Qm4(['app','copy'], Glob('*.ts')) + + + should work fine. + + Finally, two short notes about the support of directories for the + Ts4() builder. You can pass an arbitrary mix of cxx files and subdirs to + it, as in + + env.Ts4('app_en',['sub1','appwindow.cpp','main.cpp'])) + + + where sub1 is a folder that gets scanned + recursively for cxx files by lupdate. But like this, + you lose all dependency information for the subdir, i.e. if a file inside + the folder changes, the .ts file is not updated automatically! In this + case you should tell SCons to always update the target: + + ts = env.Ts4('app_en',['sub1','appwindow.cpp','main.cpp']) +env.AlwaysBuild(ts) + + + Last note: specifying the current folder + . as input to Ts4() and storing the + resulting .ts file in the same directory, leads to a dependency cycle! You + then have to store the .ts and .qm files outside of the current folder, or + use Glob('*.cpp')) instead. +
+
diff --git a/test/Docbook/basic/pdf/pdf.py b/test/Docbook/basic/pdf/pdf.py new file mode 100644 index 0000000..1268fde --- /dev/null +++ b/test/Docbook/basic/pdf/pdf.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# Copyright (c) 2001-2010 The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +""" +Test the PDF builder. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +fop = test.where_is('fop') +if not fop: + test.skip_test('No fop executable found, skipping test.\n') + +try: + import lxml +except: + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') + +test.dir_fixture('image') + +# Normal invocation +test.run(stderr=None) +test.must_not_be_empty(test.workpath('manual.fo')) +test.must_not_be_empty(test.workpath('manual.pdf')) + +# Cleanup +test.run(arguments='-c') +test.must_not_exist(test.workpath('manual.fo')) +test.must_not_exist(test.workpath('manual.pdf')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Docbook/basic/pdf/pdf_cmd.py b/test/Docbook/basic/pdf/pdf_cmd.py new file mode 100644 index 0000000..59dc4b3 --- /dev/null +++ b/test/Docbook/basic/pdf/pdf_cmd.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# Copyright (c) 2001-2010 The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +""" +Test the PDF builder while using +the xsltproc executable, if it exists. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +fop = test.where_is('fop') +if not fop: + test.skip_test('No fop executable found, skipping test.\n') + +xsltproc = test.where_is('xsltproc') +if not xsltproc: + test.skip_test('No xsltproc executable found, skipping test.\n') + +test.dir_fixture('image') + +# Normal invocation +test.run(arguments=['-f','SConstruct.cmd','DOCBOOK_XSLTPROC=%s'%xsltproc], stderr=None) +test.must_not_be_empty(test.workpath('manual.fo')) +test.must_not_be_empty(test.workpath('manual.pdf')) + +# Cleanup +test.run(arguments=['-f','SConstruct.cmd','-c','DOCBOOK_XSLTPROC=%s'%xsltproc]) +test.must_not_exist(test.workpath('manual.fo')) +test.must_not_exist(test.workpath('manual.pdf')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Docbook/basic/slideshtml/image/SConstruct.cmd b/test/Docbook/basic/slideshtml/image/SConstruct.cmd index 133cb11..ad5668c 100644 --- a/test/Docbook/basic/slideshtml/image/SConstruct.cmd +++ b/test/Docbook/basic/slideshtml/image/SConstruct.cmd @@ -1,3 +1,4 @@ env = Environment(DOCBOOK_PREFER_XSLTPROC=1, tools=['docbook']) +env.Append(DOCBOOK_XSLTPROCFLAGS=['--novalid', '--nonet']) env.DocbookSlidesHtml('virt') diff --git a/test/Docbook/basic/slideshtml/image/virt.xml b/test/Docbook/basic/slideshtml/image/virt.xml index aec1fd7..9cdf778 100644 --- a/test/Docbook/basic/slideshtml/image/virt.xml +++ b/test/Docbook/basic/slideshtml/image/virt.xml @@ -1,6 +1,6 @@ +"http://docbook.sourceforge.net/release/slides/3.3.1/schema/dtd/slides.dtd"> Virtuelles Kopieren diff --git a/test/Docbook/basic/slideshtml/slideshtml.py b/test/Docbook/basic/slideshtml/slideshtml.py index 8251b3e..ae9200f 100644 --- a/test/Docbook/basic/slideshtml/slideshtml.py +++ b/test/Docbook/basic/slideshtml/slideshtml.py @@ -33,27 +33,22 @@ import TestSCons test = TestSCons.TestSCons() if not (sys.platform.startswith('linux') and - os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides') and - os.path.isdir('/usr/share/xml/docbook/custom/slides/3.3.1')): + os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides')): test.skip_test('Wrong OS or no "slides" stylesheets installed, skipping test.\n') try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('index.html')) -test.must_exist(test.workpath('toc.html')) -test.must_exist(test.workpath('foil01.html')) -test.must_exist(test.workpath('foilgroup01.html')) +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')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/basic/slideshtml/slideshtml_cmd.py b/test/Docbook/basic/slideshtml/slideshtml_cmd.py index ce5c30b..c51f831 100644 --- a/test/Docbook/basic/slideshtml/slideshtml_cmd.py +++ b/test/Docbook/basic/slideshtml/slideshtml_cmd.py @@ -35,21 +35,20 @@ test = TestSCons.TestSCons() xsltproc = test.where_is('xsltproc') if not (xsltproc and - os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides') and - os.path.isdir('/usr/share/xml/docbook/custom/slides/3.3.1')): + os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides')): test.skip_test('No xsltproc executable or no "slides" stylesheets installed, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(arguments=['-f','SConstruct.cmd'], stderr=None) -test.must_exist(test.workpath('index.html')) -test.must_exist(test.workpath('toc.html')) -test.must_exist(test.workpath('foil01.html')) -test.must_exist(test.workpath('foilgroup01.html')) +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')) # Cleanup -test.run(arguments=['-f','SConstruct.cmd','-c']) +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')) diff --git a/test/Docbook/basic/slidespdf/image/SConstruct b/test/Docbook/basic/slidespdf/image/SConstruct new file mode 100644 index 0000000..e103f02 --- /dev/null +++ b/test/Docbook/basic/slidespdf/image/SConstruct @@ -0,0 +1,3 @@ +env = Environment(tools=['docbook']) +env.DocbookSlidesPdf('virt') + diff --git a/test/Docbook/basic/slidespdf/image/SConstruct.cmd b/test/Docbook/basic/slidespdf/image/SConstruct.cmd new file mode 100644 index 0000000..2000713 --- /dev/null +++ b/test/Docbook/basic/slidespdf/image/SConstruct.cmd @@ -0,0 +1,4 @@ +env = Environment(DOCBOOK_PREFER_XSLTPROC=1, tools=['docbook']) +env.Append(DOCBOOK_XSLTPROCFLAGS=['--novalid', '--nonet']) +env.DocbookSlidesPdf('virt') + diff --git a/test/Docbook/basic/slidespdf/image/virt.xml b/test/Docbook/basic/slidespdf/image/virt.xml new file mode 100644 index 0000000..9cdf778 --- /dev/null +++ b/test/Docbook/basic/slidespdf/image/virt.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/slidespdf/slidespdf.py b/test/Docbook/basic/slidespdf/slidespdf.py new file mode 100644 index 0000000..9e8f603 --- /dev/null +++ b/test/Docbook/basic/slidespdf/slidespdf.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# +# Copyright (c) 2001-2010 The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +""" +Test the Slides PDF builder. +""" + +import os +import sys +import TestSCons + +test = TestSCons.TestSCons() + +if not (sys.platform.startswith('linux') and + os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides')): + test.skip_test('Wrong OS or no "slides" stylesheets installed, skipping test.\n') + +fop = test.where_is('fop') +if not fop: + test.skip_test('No fop executable found, skipping test.\n') + +try: + import lxml +except: + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') + +test.dir_fixture('image') + +# Normal invocation +test.run(stderr=None) +test.must_not_be_empty(test.workpath('virt.fo')) +test.must_not_be_empty(test.workpath('virt.pdf')) + +# Cleanup +test.run(arguments='-c') +test.must_not_exist(test.workpath('virt.fo')) +test.must_not_exist(test.workpath('virt.pdf')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Docbook/basic/slidespdf/slidespdf_cmd.py b/test/Docbook/basic/slidespdf/slidespdf_cmd.py new file mode 100644 index 0000000..211e7b5 --- /dev/null +++ b/test/Docbook/basic/slidespdf/slidespdf_cmd.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# +# Copyright (c) 2001-2010 The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +""" +Test the Slides PDF builder while using +the xsltproc executable, if it exists. +""" + +import os +import sys +import TestSCons + +test = TestSCons.TestSCons() + +xsltproc = test.where_is('xsltproc') +if not (xsltproc and + os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides')): + test.skip_test('No xsltproc executable or no "slides" stylesheets installed, skipping test.\n') + +fop = test.where_is('fop') +if not fop: + test.skip_test('No fop executable found, skipping test.\n') + +test.dir_fixture('image') + +# Normal invocation +test.run(arguments=['-f','SConstruct.cmd'], stderr=None) +test.must_not_be_empty(test.workpath('virt.fo')) +test.must_not_be_empty(test.workpath('virt.pdf')) + +# Cleanup +test.run(arguments=['-f','SConstruct.cmd','-c'], stderr=None) +test.must_not_exist(test.workpath('virt.fo')) +test.must_not_exist(test.workpath('virt.pdf')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Docbook/basic/xinclude/xinclude.py b/test/Docbook/basic/xinclude/xinclude.py index 9b22c13..9074f0c 100644 --- a/test/Docbook/basic/xinclude/xinclude.py +++ b/test/Docbook/basic/xinclude/xinclude.py @@ -31,19 +31,15 @@ import TestSCons test = TestSCons.TestSCons() try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run() -test.must_exist(test.workpath('manual_xi.xml')) +test.must_not_be_empty(test.workpath('manual_xi.xml')) test.must_contain(test.workpath('manual_xi.xml'),'This is an included text.', mode='r') diff --git a/test/Docbook/basic/xslt/image/SConstruct b/test/Docbook/basic/xslt/image/SConstruct new file mode 100644 index 0000000..3e8ac4a --- /dev/null +++ b/test/Docbook/basic/xslt/image/SConstruct @@ -0,0 +1,9 @@ +import os + +env = Environment(tools=['docbook']) + +# +# Create document +# +env.DocbookXslt('out.xml', 'in.xml', + xsl='./to_docbook.xslt') diff --git a/test/Docbook/basic/xslt/image/in.xml b/test/Docbook/basic/xslt/image/in.xml new file mode 100644 index 0000000..4c1c41b --- /dev/null +++ b/test/Docbook/basic/xslt/image/in.xml @@ -0,0 +1,77 @@ + + + SCons 2.3.5 + User Guide + + + Steven + Knight + + + Steven Knight and the SCons Development Team + + 2004 - 2020 + + + 2004 - 2020 + The SCons Foundation + + + + +
+ + SCons User's Guide Copyright (c) 2004-2019 Steven Knight + +
+ + +
+ + version 2.3.5 + +
+ + + +Builders + +... + +
+Test + +... +
+ +
+ + +Construction Variables + + +In this appendix... + + + + + + ASCOMSTR + + +The string displayed when an object file +is generated from an assembly-language source file. +If this is not set, then $ASCOM (the command line) is displayed. + + + +env = Environment(ASCOMSTR = "Assembling $TARGET") + + + + + + + +
+ diff --git a/test/Docbook/basic/xslt/image/to_docbook.xslt b/test/Docbook/basic/xslt/image/to_docbook.xslt new file mode 100644 index 0000000..0b39c28 --- /dev/null +++ b/test/Docbook/basic/xslt/image/to_docbook.xslt @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Docbook/basic/xslt/xslt.py b/test/Docbook/basic/xslt/xslt.py new file mode 100644 index 0000000..0185423 --- /dev/null +++ b/test/Docbook/basic/xslt/xslt.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# +# Copyright (c) 2001-2010 The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +""" +Test the Xslt builder. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +try: + import lxml +except: + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') + +test.dir_fixture('image') + +# Normal invocation +test.run() +test.must_not_be_empty(test.workpath('out.xml')) +test.must_contain(test.workpath('out.xml'),'', mode='r') +test.must_not_contain(test.workpath('out.xml'),'', mode='r') + + +# Cleanup +test.run(arguments='-c') +test.must_not_exist(test.workpath('out.xml')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Docbook/dependencies/xinclude/xinclude.py b/test/Docbook/dependencies/xinclude/xinclude.py index c3d9e25..15c9d6a 100644 --- a/test/Docbook/dependencies/xinclude/xinclude.py +++ b/test/Docbook/dependencies/xinclude/xinclude.py @@ -31,19 +31,15 @@ import TestSCons test = TestSCons.TestSCons() try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run() -test.must_exist(test.workpath('manual_xi.xml')) +test.must_not_be_empty(test.workpath('manual_xi.xml')) test.must_contain(test.workpath('manual_xi.xml'),'This is an included text.', mode='r') # Change included file @@ -54,7 +50,7 @@ test.not_up_to_date(options='-n', arguments='.') # The new file should contain the changes test.run() -test.must_exist(test.workpath('manual_xi.xml')) +test.must_not_be_empty(test.workpath('manual_xi.xml')) test.must_contain(test.workpath('manual_xi.xml'),'This is another text.') test.pass_test() diff --git a/test/Docbook/rootname/htmlchunked/htmlchunked.py b/test/Docbook/rootname/htmlchunked/htmlchunked.py index 65b50ef..cb2bb86 100644 --- a/test/Docbook/rootname/htmlchunked/htmlchunked.py +++ b/test/Docbook/rootname/htmlchunked/htmlchunked.py @@ -37,19 +37,15 @@ if not (sys.platform.startswith('linux') and test.skip_test('Wrong OS or no stylesheets installed, skipping test.\n') try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('manual.html')) +test.must_not_be_empty(test.workpath('manual.html')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/rootname/htmlhelp/htmlhelp.py b/test/Docbook/rootname/htmlhelp/htmlhelp.py index 9d0b076..45f9d7a 100644 --- a/test/Docbook/rootname/htmlhelp/htmlhelp.py +++ b/test/Docbook/rootname/htmlhelp/htmlhelp.py @@ -37,21 +37,17 @@ if not (sys.platform.startswith('linux') and test.skip_test('Wrong OS or no stylesheets installed, skipping test.\n') try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('manual.html')) -test.must_exist(test.workpath('htmlhelp.hhp')) -test.must_exist(test.workpath('toc.hhc')) +test.must_not_be_empty(test.workpath('manual.html')) +test.must_not_be_empty(test.workpath('htmlhelp.hhp')) +test.must_not_be_empty(test.workpath('toc.hhc')) # Cleanup test.run(arguments='-c') diff --git a/test/Docbook/rootname/slideshtml/image/virt.xml b/test/Docbook/rootname/slideshtml/image/virt.xml index aec1fd7..9cdf778 100644 --- a/test/Docbook/rootname/slideshtml/image/virt.xml +++ b/test/Docbook/rootname/slideshtml/image/virt.xml @@ -1,6 +1,6 @@ +"http://docbook.sourceforge.net/release/slides/3.3.1/schema/dtd/slides.dtd"> Virtuelles Kopieren diff --git a/test/Docbook/rootname/slideshtml/slideshtml.py b/test/Docbook/rootname/slideshtml/slideshtml.py index 399764b..3220522 100644 --- a/test/Docbook/rootname/slideshtml/slideshtml.py +++ b/test/Docbook/rootname/slideshtml/slideshtml.py @@ -33,27 +33,22 @@ import TestSCons test = TestSCons.TestSCons() if not (sys.platform.startswith('linux') and - os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides') and - os.path.isdir('/usr/share/xml/docbook/custom/slides/3.3.1')): + os.path.isdir('/usr/share/xml/docbook/stylesheet/docbook-xsl/slides')): test.skip_test('Wrong OS or no "slides" stylesheets installed, skipping test.\n') try: - import libxml2 - import libxslt + import lxml except: - try: - import lxml - except: - test.skip_test('Cannot find installed Python binding for libxml2 or lxml, skipping test.\n') + test.skip_test('Cannot find installed Python binding for lxml, skipping test.\n') test.dir_fixture('image') # Normal invocation test.run(stderr=None) -test.must_exist(test.workpath('manual.html')) -test.must_exist(test.workpath('toc.html')) -test.must_exist(test.workpath('foil01.html')) -test.must_exist(test.workpath('foilgroup01.html')) +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')) # Cleanup test.run(arguments='-c') diff --git a/testing/framework/TestCommon.py b/testing/framework/TestCommon.py index 9c4d116..35bf365 100644 --- a/testing/framework/TestCommon.py +++ b/testing/framework/TestCommon.py @@ -56,6 +56,8 @@ provided by the TestCommon class: test.must_not_exist('file1', ['file2', ...]) + test.must_not_be_empty('file') + test.run(options = "options to be prepended to arguments", stdout = "expected standard output from the program", stderr = "expected error output from the program", @@ -568,6 +570,23 @@ class TestCommon(TestCmd): print("Unexpected files exist: `%s'" % "', `".join(existing)) self.fail_test(existing) + def must_not_be_empty(self, file): + """Ensures that the specified file exists, and that it is not empty. + Exits FAILED if the file doesn't exist or is empty. + """ + if not (os.path.exists(file) or os.path.islink(file)): + print("File doesn't exist: `%s'" % file) + self.fail_test(file) + + try: + fsize = os.path.getsize(file) + except OSError: + fsize = 0 + + if fsize == 0: + print("File is empty: `%s'" % file) + self.fail_test(file) + def must_not_be_writable(self, *files): """Ensures that the specified file(s) exist and are not writable. An individual file can be specified as a list of directory names, diff --git a/testing/framework/TestCommonTests.py b/testing/framework/TestCommonTests.py index 01e9fe1..6c9e92d 100644 --- a/testing/framework/TestCommonTests.py +++ b/testing/framework/TestCommonTests.py @@ -1784,6 +1784,57 @@ class must_not_exist_any_of_TestCase(TestCommonTestCase): stderr = run_env.stderr() assert stderr == "PASSED\n", stderr +class must_not_be_empty_TestCase(TestCommonTestCase): + def test_failure(self): + """Test must_not_be_empty(): failure""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.write('file1', "") + tc.must_not_be_empty('file1') + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "File is empty: `file1'\n", stdout + stderr = run_env.stderr() + assert stderr.find("FAILED") != -1, stderr + + def test_success(self): + """Test must_not_be_empty(): success""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.write('file1', "file1\\n") + tc.must_not_be_empty('file1') + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "", stdout + stderr = run_env.stderr() + assert stderr == "PASSED\n", stderr + + def test_file_doesnt_exist(self): + """Test must_not_be_empty(): failure""" + run_env = self.run_env + + script = lstrip("""\ + from TestCommon import TestCommon + tc = TestCommon(workdir='') + tc.must_not_be_empty('file1') + tc.pass_test() + """) + run_env.run(program=sys.executable, stdin=script) + stdout = run_env.stdout() + assert stdout == "File doesn't exist: `file1'\n", stdout + stderr = run_env.stderr() + assert stderr.find("FAILED") != -1, stderr + class run_TestCase(TestCommonTestCase): def test_argument_handling(self): """Test run(): argument handling""" @@ -2372,6 +2423,7 @@ if __name__ == "__main__": must_not_contain_lines_TestCase, must_not_exist_TestCase, must_not_exist_any_of_TestCase, + must_not_be_empty_TestCase, run_TestCase, start_TestCase, skip_test_TestCase, -- cgit v0.12