From 8209788c5d6a2554317a13416bb953b6c3f572ab Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Thu, 6 Jan 2005 01:39:03 +0000 Subject: More command-line customizability: , , , , , , . --- doc/man/scons.1 | 33 ++++++- src/CHANGES.txt | 20 ++-- src/engine/SCons/Tool/Perforce.py | 8 +- src/engine/SCons/Tool/dmd.py | 19 +++- src/engine/SCons/Tool/dvipdf.py | 5 +- src/engine/SCons/Tool/dvips.py | 5 +- src/engine/SCons/Tool/gs.py | 5 +- src/engine/SCons/Tool/m4.py | 4 +- src/engine/SCons/Tool/swig.py | 7 +- test/DVIPDF.py | 165 -------------------------------- test/DVIPDF/DVIPDF.py | 165 ++++++++++++++++++++++++++++++++ test/DVIPDF/DVIPDFCOM.py | 63 +++++++++++++ test/DVIPDF/DVIPDFCOMSTR.py | 67 +++++++++++++ test/DVIPDF/DVIPDFFLAGS.py | 171 +++++++++++++++++++++++++++++++++ test/DVIPDFFLAGS.py | 171 --------------------------------- test/DVIPS.py | 178 ---------------------------------- test/DVIPS/DVIPS.py | 178 ++++++++++++++++++++++++++++++++++ test/DVIPS/DVIPSFLAGS.py | 185 ++++++++++++++++++++++++++++++++++++ test/DVIPS/PSCOM.py | 63 +++++++++++++ test/DVIPS/PSCOMSTR.py | 67 +++++++++++++ test/DVIPSFLAGS.py | 185 ------------------------------------ test/GS.py | 117 ----------------------- test/Ghostscript/GS.py | 117 +++++++++++++++++++++++ test/Ghostscript/GSCOM.py | 63 +++++++++++++ test/Ghostscript/GSCOMSTR.py | 67 +++++++++++++ test/M4.py | 106 --------------------- test/M4/M4.py | 106 +++++++++++++++++++++ test/M4/M4COM.py | 63 +++++++++++++ test/M4/M4COMSTR.py | 67 +++++++++++++ test/Perforce.py | 190 ------------------------------------- test/Perforce/P4COM.py | 121 ++++++++++++++++++++++++ test/Perforce/P4COMSTR.py | 122 ++++++++++++++++++++++++ test/Perforce/Perforce.py | 190 +++++++++++++++++++++++++++++++++++++ test/SWIG.py | 194 -------------------------------------- test/SWIG/SWIG.py | 194 ++++++++++++++++++++++++++++++++++++++ test/SWIG/SWIGCOM.py | 66 +++++++++++++ test/SWIG/SWIGCOMSTR.py | 71 ++++++++++++++ 37 files changed, 2290 insertions(+), 1328 deletions(-) delete mode 100644 test/DVIPDF.py create mode 100644 test/DVIPDF/DVIPDF.py create mode 100644 test/DVIPDF/DVIPDFCOM.py create mode 100644 test/DVIPDF/DVIPDFCOMSTR.py create mode 100644 test/DVIPDF/DVIPDFFLAGS.py delete mode 100644 test/DVIPDFFLAGS.py delete mode 100644 test/DVIPS.py create mode 100644 test/DVIPS/DVIPS.py create mode 100644 test/DVIPS/DVIPSFLAGS.py create mode 100644 test/DVIPS/PSCOM.py create mode 100644 test/DVIPS/PSCOMSTR.py delete mode 100644 test/DVIPSFLAGS.py delete mode 100644 test/GS.py create mode 100644 test/Ghostscript/GS.py create mode 100644 test/Ghostscript/GSCOM.py create mode 100644 test/Ghostscript/GSCOMSTR.py delete mode 100644 test/M4.py create mode 100644 test/M4/M4.py create mode 100644 test/M4/M4COM.py create mode 100644 test/M4/M4COMSTR.py delete mode 100644 test/Perforce.py create mode 100644 test/Perforce/P4COM.py create mode 100644 test/Perforce/P4COMSTR.py create mode 100644 test/Perforce/Perforce.py delete mode 100644 test/SWIG.py create mode 100644 test/SWIG/SWIG.py create mode 100644 test/SWIG/SWIGCOM.py create mode 100644 test/SWIG/SWIGCOMSTR.py diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 38a3822..f195c62 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -4918,6 +4918,11 @@ General options passed to the TeX DVI file to PDF file converter. .IP DVIPDFCOM The command line used to convert TeX DVI files into a PDF file. +.IP DVIPDFCOMSTR +The string displayed when a TeX DVI file +is converted into a PDF file. +If this is not set, then $DVIPDFCOM (the command line) is displayed. + .IP DVIPS The TeX DVI file to PostScript converter. @@ -5477,6 +5482,12 @@ when converting PostScript to PDF files. .IP GSCOM The Ghostscript command line used to convert PostScript to PDF files. +.IP GSCOMSTR +The string displayed when +Ghostscript is used to convert +a PostScript file to a PDF file. +If this is not set, then $GSCOM (the command line) is displayed. + .IP IDLSUFFIXES The list of suffixes of files that will be scanned for IDL implicit dependencies @@ -5838,7 +5849,12 @@ The M4 macro preprocessor. General options passed to the M4 macro preprocessor. .IP M4COM -The command line used to pass files through the macro preprocessor. +The command line used to pass files through the M4 macro preprocessor. + +.IP M4COMSTR +The string displayed when +a file is passed through the M4 macro preprocessor. +If this is not set, then $M4COM (the command line) is displayed. .IP MAXLINELENGTH The maximum number of characters allowed on an external command line. @@ -6032,6 +6048,11 @@ The Perforce executable. The command line used to fetch source files from Perforce. +.IP P4COMSTR +The string displayed when +fetching a source file from Perforce. +If this is not set, then $P4COM (the command line) is displayed. + .IP P4FLAGS General options that are passed to Perforce. @@ -6143,6 +6164,11 @@ The suffix used for executable file names. .IP PSCOM The command line used to convert TeX DVI files into a PostScript file. +.IP PSCOMSTR +The string displayed when a TeX DVI file +is converted into a PostScript file. +If this is not set, then $PSCOM (the command line) is displayed. + .IP PSPREFIX The prefix used for PostScript file names. @@ -6753,6 +6779,11 @@ construction variable. The command line used to call the scripting language wrapper and interface generator. +.IP SWIGCOMSTR +The string displayed when calling +the scripting language wrapper and interface generator. +If this is not set, then $SWIGCOM (the command line) is displayed. + .IP SWIGCXXFILESUFFIX The suffix that will be used for intermediate C++ source files generated by diff --git a/src/CHANGES.txt b/src/CHANGES.txt index ff2dd71..c2801bd 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -135,15 +135,17 @@ RELEASE 0.97 - XXX - Fix expansion of env.Command() overrides within target and source file names. - - Support easier customization of what's displayed by various - default actions by adding lots of new construction variables: - $ARCOMSTR, $ASCOMSTR, $ASPPCOMSTR, $BIBTEXCOMSTR, $BITKEEPERCOMSTR, - $CCCOMSTR, $CVSCOMSTR, $CXXCOMSTR, $F77COMSTR, $F90COMSTR, $F95COMSTR, - $FORTRANCOMSTR, $JARCOMSTR, $JAVACCOMSTR, $JAVAHCOMSTR, $LATEXCOMSTR, - $LEXCOMSTR, $LINKCOMSTR, $PDFLATEXCOMSTR, $PDFTEXCOMSTR, $RCSCOMSTR, - $RMICCOMSTR, $SCCSCOMSTR, $SHCCCOMSTR, $SHCXXCOMSTR, $SHF77COMSTR, - $SHF90COMSTR, $SHF95COMSTR, $SHFORTRANCOMSTR, $SHLINKCOMSTR, - $TARCOMSTR, $TEXCOMSTR, $YACCCOMSTR and $ZIPCOMSTR. + - Support easier customization of what's displayed by various default + actions by adding lots of new construction variables: $ARCOMSTR, + $ASCOMSTR, $ASPPCOMSTR, $BIBTEXCOMSTR, $BITKEEPERCOMSTR, $CCCOMSTR, + $CVSCOMSTR, $CXXCOMSTR, $DCOMSTR, $DVIPDFCOMSTR, $F77COMSTR, + $F90COMSTR, $F95COMSTR, $FORTRANCOMSTR, $GSCOMSTR, $JARCOMSTR, + $JAVACCOMSTR, $JAVAHCOMSTR, $LATEXCOMSTR, $LEXCOMSTR, $LINKCOMSTR, + $M4COMSTR, $P4COMSTR, $PDFLATEXCOMSTR, $PDFTEXCOMSTR, $PSCOMSTR, + $RCSCOMSTR, $RMICCOMSTR, $SCCSCOMSTR, $SHCCCOMSTR, $SHCXXCOMSTR, + $SHF77COMSTR, $SHF90COMSTR, $SHF95COMSTR, $SHFORTRANCOMSTR, + $SHLINKCOMSTR, $SWIGCOMSTR, $TARCOMSTR, $TEXCOMSTR, $YACCCOMSTR + and $ZIPCOMSTR. - Add an optional "map" keyword argument to ListOption() that takes a dictionary to map user-specified values to legal values from the list diff --git a/src/engine/SCons/Tool/Perforce.py b/src/engine/SCons/Tool/Perforce.py index 0c6796c..22c75e9 100644 --- a/src/engine/SCons/Tool/Perforce.py +++ b/src/engine/SCons/Tool/Perforce.py @@ -35,6 +35,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os +import SCons.Action import SCons.Builder import SCons.Node.FS import SCons.Util @@ -42,18 +43,21 @@ import SCons.Util # This function should maybe be moved to SCons.Util? from SCons.Tool.PharLapCommon import addPathIfNotExists + + # Variables that we want to import from the base OS environment. _import_env = [ 'P4PORT', 'P4CLIENT', 'P4USER', 'USER', 'USERNAME', 'P4PASSWD', 'P4CHARSET', 'P4LANGUAGE', 'SYSTEMROOT' ] +PerforceAction = SCons.Action.Action('$P4COM', '$P4COMSTR') + def generate(env): """Add a Builder factory function and construction variables for Perforce to an Environment.""" def PerforceFactory(env=env): """ """ - return SCons.Builder.Builder(action = '$P4COM', - env = env) + return SCons.Builder.Builder(action = PerforceAction, env = env) #setattr(env, 'Perforce', PerforceFactory) env.Perforce = PerforceFactory diff --git a/src/engine/SCons/Tool/dmd.py b/src/engine/SCons/Tool/dmd.py index 5d773c3..914129c 100644 --- a/src/engine/SCons/Tool/dmd.py +++ b/src/engine/SCons/Tool/dmd.py @@ -58,10 +58,11 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os import string -import SCons.Tool -import SCons.Scanner.D +import SCons.Action import SCons.Builder import SCons.Defaults +import SCons.Scanner.D +import SCons.Tool # Adapted from c++.py def isD(source): @@ -85,8 +86,10 @@ def generate(env): static_obj, shared_obj = SCons.Tool.createObjBuilders(env) - static_obj.add_action('.d', '$DCOM') - shared_obj.add_action('.d', '$DCOM') + DAction = SCons.Action.Action('$DCOM', '$DCOMSTR') + + static_obj.add_action('.d', DAction) + shared_obj.add_action('.d', DAction) static_obj.add_emitter('.d', SCons.Defaults.StaticObjectEmitter) shared_obj.add_emitter('.d', SCons.Defaults.SharedObjectEmitter) @@ -152,6 +155,10 @@ def generate(env): def _smartLink(source, target, env, for_signature, defaultLinker=linkcom): if isD(source): + # XXX I'm not sure how to add a $DLINKCOMSTR variable + # so that it works with this _smartLink() logic, + # and I don't have a D compiler/linker to try it out, + # so we'll leave it alone for now. return '$DLINKCOM' else: return defaultLinker @@ -164,6 +171,10 @@ def generate(env): def _smartLib(source, target, env, for_signature, defaultLib=arcom): if isD(source): + # XXX I'm not sure how to add a $DLIBCOMSTR variable + # so that it works with this _smartLib() logic, and + # I don't have a D compiler/archiver to try it out, + # so we'll leave it alone for now. return '$DLIBCOM' else: return defaultLib diff --git a/src/engine/SCons/Tool/dvipdf.py b/src/engine/SCons/Tool/dvipdf.py index 8c51ac0..1ffb655 100644 --- a/src/engine/SCons/Tool/dvipdf.py +++ b/src/engine/SCons/Tool/dvipdf.py @@ -33,9 +33,12 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import SCons.Action import SCons.Defaults import SCons.Util +PDFAction = SCons.Action.Action('$DVIPDFCOM', '$DVIPDFCOMSTR') + def generate(env): """Add Builders and construction variables for dvipdf to an Environment.""" try: @@ -43,7 +46,7 @@ def generate(env): except KeyError: bld = SCons.Defaults.PDF() env['BUILDERS']['PDF'] = bld - bld.add_action('.dvi', '$PDFCOM') + bld.add_action('.dvi', PDFAction) env['DVIPDF'] = 'dvipdf' env['DVIPDFFLAGS'] = SCons.Util.CLVar('') diff --git a/src/engine/SCons/Tool/dvips.py b/src/engine/SCons/Tool/dvips.py index d70d78d..d2debf0 100644 --- a/src/engine/SCons/Tool/dvips.py +++ b/src/engine/SCons/Tool/dvips.py @@ -34,10 +34,13 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import SCons.Action +import SCons.Builder import SCons.Defaults import SCons.Util -PostScript = SCons.Builder.Builder(action = '$PSCOM', +PSAction = SCons.Action.Action('$PSCOM', '$PSCOMSTR') + +PostScript = SCons.Builder.Builder(action = PSAction, prefix = '$PSPREFIX', suffix = '$PSSUFFIX', src_suffix = '.dvi', diff --git a/src/engine/SCons/Tool/gs.py b/src/engine/SCons/Tool/gs.py index 2666189..7df110a 100644 --- a/src/engine/SCons/Tool/gs.py +++ b/src/engine/SCons/Tool/gs.py @@ -33,6 +33,7 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import SCons.Action import SCons.Defaults import SCons.Platform import SCons.Util @@ -47,6 +48,8 @@ elif platform == 'win32': else: gs = 'gs' +GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR') + def generate(env): """Add Builders and construction variables for Ghostscript to an Environment.""" @@ -56,7 +59,7 @@ def generate(env): bld = SCons.Defaults.PDF() env['BUILDERS']['PDF'] = bld - bld.add_action('.ps', '$GSCOM') + bld.add_action('.ps', GhostscriptAction) env['GS'] = gs env['GSFLAGS'] = SCons.Util.CLVar('-dNOPAUSE -dBATCH -sDEVICE=pdfwrite') diff --git a/src/engine/SCons/Tool/m4.py b/src/engine/SCons/Tool/m4.py index 3fd2d66..06757bf 100644 --- a/src/engine/SCons/Tool/m4.py +++ b/src/engine/SCons/Tool/m4.py @@ -33,12 +33,14 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import SCons.Action import SCons.Builder import SCons.Util def generate(env): """Add Builders and construction variables for m4 to an Environment.""" - bld = SCons.Builder.Builder(action = '$M4COM', src_suffix = '.m4') + M4Action = SCons.Action.Action('$M4COM', '$M4COMSTR') + bld = SCons.Builder.Builder(action = M4Action, src_suffix = '.m4') env['BUILDERS']['M4'] = bld diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py index 66e6011..449e3aa 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -33,10 +33,13 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import SCons.Action import SCons.Defaults import SCons.Tool import SCons.Util +SwigAction = SCons.Action.Action('$SWIGCOM', '$SWIGCOMSTR') + def swigSuffixEmitter(env, source): if '-c++' in SCons.Util.CLVar(env.subst("$SWIGFLAGS")): return '$SWIGCXXFILESUFFIX' @@ -50,8 +53,8 @@ def generate(env): c_file.suffix['.i'] = swigSuffixEmitter cxx_file.suffix['.i'] = swigSuffixEmitter - c_file.add_action('.i', '$SWIGCOM') - cxx_file.add_action('.i', '$SWIGCOM') + c_file.add_action('.i', SwigAction) + cxx_file.add_action('.i', SwigAction) env['SWIG'] = 'swig' env['SWIGFLAGS'] = SCons.Util.CLVar('') diff --git a/test/DVIPDF.py b/test/DVIPDF.py deleted file mode 100644 index a140c3a..0000000 --- a/test/DVIPDF.py +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import os.path -import string -import sys -import TestSCons - -python = TestSCons.python - -test = TestSCons.TestSCons() - - - -test.write('mytex.py', r""" -import os -import sys -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.dvi', 'wb') -for l in infile.readlines(): - if l[:4] != '#tex': - out_file.write(l) -sys.exit(0) -""") - -test.write('mylatex.py', r""" -import os -import sys -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.dvi', 'wb') -for l in infile.readlines(): - if l[:6] != '#latex': - out_file.write(l) -sys.exit(0) -""") - -test.write('mydvipdf.py', r""" -import os -import sys -infile = open(sys.argv[1], 'rb') -out_file = open(sys.argv[2], 'wb') -for l in infile.readlines(): - if l[:7] != '#dvipdf': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(TEX = r'%s mytex.py', - LATEX = r'%s mylatex.py', - DVIPDF = r'%s mydvipdf.py', - tools=['latex', 'tex', 'dvipdf']) -dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') -env.DVI(target = 'test2.dvi', source = 'test2.tex') -env.PDF(target = 'test1.pdf', source = dvi) -env.PDF(target = 'test2.pdf', source = 'test2.dvi') -""" % (python, python, python)) - -test.write('test1.tex', r"""This is a .dvi test. -#tex -#dvipdf -""") - -test.write('test2.tex', r"""This is a .tex test. -#tex -#dvipdf -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1.pdf') != "This is a .dvi test.\n") - -test.fail_test(test.read('test2.pdf') != "This is a .tex test.\n") - - - -dvipdf = test.where_is('dvipdf') -tex = test.where_is('tex') - -if dvipdf and tex: - - test.write("wrapper.py", """import os -import string -import sys -cmd = string.join(sys.argv[1:], " ") -open('%s', 'ab').write("%%s\\n" %% cmd) -os.system(cmd) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -import os -foo = Environment(ENV = { 'PATH' : os.environ['PATH'] }) -dvipdf = foo.Dictionary('DVIPDF') -bar = Environment(ENV = { 'PATH' : os.environ['PATH'] }, - DVIPDF = r'%s wrapper.py ' + dvipdf) -foo.PDF(target = 'foo.pdf', - source = foo.DVI(target = 'foo.dvi', source = 'foo.tex')) -bar.PDF(target = 'bar.pdf', - source = bar.DVI(target = 'bar.dvi', source = 'bar.tex')) -foo.PDF(target = 'xxx.pdf', source = 'xxx.tex') -""" % python) - - tex = r""" -This is the %s TeX file. -\end -""" - - latex = r""" -\documentclass{letter} -\begin{document} -This is the %s LaTeX file. -\end{document} -""" - - test.write('foo.tex', tex % 'foo.tex') - - test.write('xxx.tex', tex % 'xxx.tex') - - test.write('bar.tex', tex % 'bar.tex') - - test.run(arguments = 'foo.pdf', stderr = None) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) - - test.run(arguments = 'xxx.pdf', stderr = None) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.fail_test(os.path.exists(test.workpath('xxx.dvi'))) - - test.run(arguments = 'bar.pdf', stderr = None) - - test.fail_test(test.read('wrapper.out') != "dvipdf bar.dvi bar.pdf\n") - - test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) - -test.pass_test() diff --git a/test/DVIPDF/DVIPDF.py b/test/DVIPDF/DVIPDF.py new file mode 100644 index 0000000..a140c3a --- /dev/null +++ b/test/DVIPDF/DVIPDF.py @@ -0,0 +1,165 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import os.path +import string +import sys +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mytex.py', r""" +import os +import sys +base_name = os.path.splitext(sys.argv[1])[0] +infile = open(sys.argv[1], 'rb') +out_file = open(base_name+'.dvi', 'wb') +for l in infile.readlines(): + if l[:4] != '#tex': + out_file.write(l) +sys.exit(0) +""") + +test.write('mylatex.py', r""" +import os +import sys +base_name = os.path.splitext(sys.argv[1])[0] +infile = open(sys.argv[1], 'rb') +out_file = open(base_name+'.dvi', 'wb') +for l in infile.readlines(): + if l[:6] != '#latex': + out_file.write(l) +sys.exit(0) +""") + +test.write('mydvipdf.py', r""" +import os +import sys +infile = open(sys.argv[1], 'rb') +out_file = open(sys.argv[2], 'wb') +for l in infile.readlines(): + if l[:7] != '#dvipdf': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TEX = r'%s mytex.py', + LATEX = r'%s mylatex.py', + DVIPDF = r'%s mydvipdf.py', + tools=['latex', 'tex', 'dvipdf']) +dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') +env.DVI(target = 'test2.dvi', source = 'test2.tex') +env.PDF(target = 'test1.pdf', source = dvi) +env.PDF(target = 'test2.pdf', source = 'test2.dvi') +""" % (python, python, python)) + +test.write('test1.tex', r"""This is a .dvi test. +#tex +#dvipdf +""") + +test.write('test2.tex', r"""This is a .tex test. +#tex +#dvipdf +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(test.read('test1.pdf') != "This is a .dvi test.\n") + +test.fail_test(test.read('test2.pdf') != "This is a .tex test.\n") + + + +dvipdf = test.where_is('dvipdf') +tex = test.where_is('tex') + +if dvipdf and tex: + + test.write("wrapper.py", """import os +import string +import sys +cmd = string.join(sys.argv[1:], " ") +open('%s', 'ab').write("%%s\\n" %% cmd) +os.system(cmd) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + + test.write('SConstruct', """ +import os +foo = Environment(ENV = { 'PATH' : os.environ['PATH'] }) +dvipdf = foo.Dictionary('DVIPDF') +bar = Environment(ENV = { 'PATH' : os.environ['PATH'] }, + DVIPDF = r'%s wrapper.py ' + dvipdf) +foo.PDF(target = 'foo.pdf', + source = foo.DVI(target = 'foo.dvi', source = 'foo.tex')) +bar.PDF(target = 'bar.pdf', + source = bar.DVI(target = 'bar.dvi', source = 'bar.tex')) +foo.PDF(target = 'xxx.pdf', source = 'xxx.tex') +""" % python) + + tex = r""" +This is the %s TeX file. +\end +""" + + latex = r""" +\documentclass{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + test.write('foo.tex', tex % 'foo.tex') + + test.write('xxx.tex', tex % 'xxx.tex') + + test.write('bar.tex', tex % 'bar.tex') + + test.run(arguments = 'foo.pdf', stderr = None) + + test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + + test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) + + test.run(arguments = 'xxx.pdf', stderr = None) + + test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + + test.fail_test(os.path.exists(test.workpath('xxx.dvi'))) + + test.run(arguments = 'bar.pdf', stderr = None) + + test.fail_test(test.read('wrapper.out') != "dvipdf bar.dvi bar.pdf\n") + + test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) + +test.pass_test() diff --git a/test/DVIPDF/DVIPDFCOM.py b/test/DVIPDF/DVIPDFCOM.py new file mode 100644 index 0000000..61d5ce7 --- /dev/null +++ b/test/DVIPDF/DVIPDFCOM.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to configure the $DVIPDFCOM construction variable. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mypdf.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*pdf*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'dvipdf'], + DVIPDFCOM = r'%s mypdf.py $TARGET $SOURCES') +env.PDF(target = 'aaa', source = 'aaa.dvi') +""" % python) + +test.write('aaa.dvi', "aaa.dvi\n/*pdf*/\n") + +test.run() + +test.must_match('aaa.pdf', "aaa.dvi\n") + + + +test.pass_test() diff --git a/test/DVIPDF/DVIPDFCOMSTR.py b/test/DVIPDF/DVIPDFCOMSTR.py new file mode 100644 index 0000000..6e57adb --- /dev/null +++ b/test/DVIPDF/DVIPDFCOMSTR.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that the $DVIPDFCOMSTR construction variable allows you to customize +the displayed string when is called. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mypdf.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*pdf*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'dvipdf'], + DVIPDFCOM = r'%s mypdf.py $TARGET $SOURCES', + DVIPDFCOMSTR = 'DVIPDFing $TARGET from $SOURCE') +env.PDF(target = 'aaa', source = 'aaa.dvi') +""" % python) + +test.write('aaa.dvi', "aaa.dvi\n/*pdf*/\n") + +test.run(stdout = test.wrap_stdout("""\ +DVIPDFing aaa.pdf from aaa.dvi +""")) + +test.must_match('aaa.pdf', "aaa.dvi\n") + + + +test.pass_test() diff --git a/test/DVIPDF/DVIPDFFLAGS.py b/test/DVIPDF/DVIPDFFLAGS.py new file mode 100644 index 0000000..e9bd8ba --- /dev/null +++ b/test/DVIPDF/DVIPDFFLAGS.py @@ -0,0 +1,171 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import os.path +import string +import sys +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mytex.py', r""" +import os +import sys +base_name = os.path.splitext(sys.argv[1])[0] +infile = open(sys.argv[1], 'rb') +out_file = open(base_name+'.dvi', 'wb') +for l in infile.readlines(): + if l[:4] != '#tex': + out_file.write(l) +sys.exit(0) +""") + +test.write('mylatex.py', r""" +import os +import sys +base_name = os.path.splitext(sys.argv[1])[0] +infile = open(sys.argv[1], 'rb') +out_file = open(base_name+'.dvi', 'wb') +for l in infile.readlines(): + if l[:6] != '#latex': + out_file.write(l) +sys.exit(0) +""") + +test.write('mydvipdf.py', r""" +import getopt +import os +import sys +cmd_opts, args = getopt.getopt(sys.argv[1:], 'x', []) +opt_string = '' +for opt, arg in cmd_opts: + opt_string = opt_string + ' ' + opt +infile = open(args[0], 'rb') +out_file = open(args[1], 'wb') +out_file.write(opt_string + "\n") +for l in infile.readlines(): + if l[:7] != '#dvipdf': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TEX = r'%s mytex.py', + LATEX = r'%s mylatex.py', + DVIPDF = r'%s mydvipdf.py', DVIPDFFLAGS = '-x', + tools = ['tex', 'latex', 'dvipdf']) +dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') +env.DVI(target = 'test2.dvi', source = 'test2.tex') +env.PDF(target = 'test1.pdf', source = dvi) +env.PDF(target = 'test2.pdf', source = 'test2.dvi') +""" % (python, python, python)) + +test.write('test1.tex', r"""This is a .dvi test. +#tex +#dvipdf +""") + +test.write('test2.tex', r"""This is a .tex test. +#tex +#dvipdf +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(test.read('test1.pdf') != " -x\nThis is a .dvi test.\n") + +test.fail_test(test.read('test2.pdf') != " -x\nThis is a .tex test.\n") + + + +dvipdf = test.where_is('dvipdf') +tex = test.where_is('tex') + +if dvipdf and tex: + + test.write("wrapper.py", """import os +import string +import sys +cmd = string.join(sys.argv[1:], " ") +open('%s', 'ab').write("%%s\\n" %% cmd) +os.system(cmd) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + + test.write('SConstruct', """ +import os +ENV = {'PATH' : os.environ['PATH']} +foo = Environment(DVIPDFFLAGS = '-N', ENV = ENV) +dvipdf = foo.Dictionary('DVIPDF') +bar = Environment(DVIPDF = r'%s wrapper.py ' + dvipdf, ENV = ENV) +foo.PDF(target = 'foo.pdf', + source = foo.DVI(target = 'foo.dvi', source = 'foo.tex')) +bar.PDF(target = 'bar.pdf', + source = bar.DVI(target = 'bar.dvi', source = 'bar.tex')) +foo.PDF(target = 'xxx.pdf', source = 'xxx.tex') +""" % python) + + tex = r""" +This is the %s TeX file. +\end +""" + + latex = r""" +\documentclass{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + test.write('foo.tex', tex % 'foo.tex') + + test.write('xxx.tex', tex % 'xxx.tex') + + test.write('bar.tex', tex % 'bar.tex') + + test.run(arguments = 'foo.pdf', stderr = None) + + test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + + test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) + + test.run(arguments = 'xxx.pdf', stderr = None) + + test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + + test.fail_test(os.path.exists(test.workpath('xxx.dvi'))) + + test.run(arguments = 'bar.pdf', stderr = None) + + test.fail_test(test.read('wrapper.out') != "dvipdf bar.dvi bar.pdf\n") + + test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) + +test.pass_test() diff --git a/test/DVIPDFFLAGS.py b/test/DVIPDFFLAGS.py deleted file mode 100644 index e9bd8ba..0000000 --- a/test/DVIPDFFLAGS.py +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import os.path -import string -import sys -import TestSCons - -python = TestSCons.python - -test = TestSCons.TestSCons() - - - -test.write('mytex.py', r""" -import os -import sys -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.dvi', 'wb') -for l in infile.readlines(): - if l[:4] != '#tex': - out_file.write(l) -sys.exit(0) -""") - -test.write('mylatex.py', r""" -import os -import sys -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.dvi', 'wb') -for l in infile.readlines(): - if l[:6] != '#latex': - out_file.write(l) -sys.exit(0) -""") - -test.write('mydvipdf.py', r""" -import getopt -import os -import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 'x', []) -opt_string = '' -for opt, arg in cmd_opts: - opt_string = opt_string + ' ' + opt -infile = open(args[0], 'rb') -out_file = open(args[1], 'wb') -out_file.write(opt_string + "\n") -for l in infile.readlines(): - if l[:7] != '#dvipdf': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(TEX = r'%s mytex.py', - LATEX = r'%s mylatex.py', - DVIPDF = r'%s mydvipdf.py', DVIPDFFLAGS = '-x', - tools = ['tex', 'latex', 'dvipdf']) -dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') -env.DVI(target = 'test2.dvi', source = 'test2.tex') -env.PDF(target = 'test1.pdf', source = dvi) -env.PDF(target = 'test2.pdf', source = 'test2.dvi') -""" % (python, python, python)) - -test.write('test1.tex', r"""This is a .dvi test. -#tex -#dvipdf -""") - -test.write('test2.tex', r"""This is a .tex test. -#tex -#dvipdf -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1.pdf') != " -x\nThis is a .dvi test.\n") - -test.fail_test(test.read('test2.pdf') != " -x\nThis is a .tex test.\n") - - - -dvipdf = test.where_is('dvipdf') -tex = test.where_is('tex') - -if dvipdf and tex: - - test.write("wrapper.py", """import os -import string -import sys -cmd = string.join(sys.argv[1:], " ") -open('%s', 'ab').write("%%s\\n" %% cmd) -os.system(cmd) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -import os -ENV = {'PATH' : os.environ['PATH']} -foo = Environment(DVIPDFFLAGS = '-N', ENV = ENV) -dvipdf = foo.Dictionary('DVIPDF') -bar = Environment(DVIPDF = r'%s wrapper.py ' + dvipdf, ENV = ENV) -foo.PDF(target = 'foo.pdf', - source = foo.DVI(target = 'foo.dvi', source = 'foo.tex')) -bar.PDF(target = 'bar.pdf', - source = bar.DVI(target = 'bar.dvi', source = 'bar.tex')) -foo.PDF(target = 'xxx.pdf', source = 'xxx.tex') -""" % python) - - tex = r""" -This is the %s TeX file. -\end -""" - - latex = r""" -\documentclass{letter} -\begin{document} -This is the %s LaTeX file. -\end{document} -""" - - test.write('foo.tex', tex % 'foo.tex') - - test.write('xxx.tex', tex % 'xxx.tex') - - test.write('bar.tex', tex % 'bar.tex') - - test.run(arguments = 'foo.pdf', stderr = None) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) - - test.run(arguments = 'xxx.pdf', stderr = None) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.fail_test(os.path.exists(test.workpath('xxx.dvi'))) - - test.run(arguments = 'bar.pdf', stderr = None) - - test.fail_test(test.read('wrapper.out') != "dvipdf bar.dvi bar.pdf\n") - - test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) - -test.pass_test() diff --git a/test/DVIPS.py b/test/DVIPS.py deleted file mode 100644 index 2ae856a..0000000 --- a/test/DVIPS.py +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import os.path -import string -import sys -import TestSCons - -python = TestSCons.python - -test = TestSCons.TestSCons() - - - -test.write('mytex.py', r""" -import os -import sys -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.dvi', 'wb') -for l in infile.readlines(): - if l[:4] != '#tex': - out_file.write(l) -sys.exit(0) -""") - -test.write('mylatex.py', r""" -import os -import sys -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.dvi', 'wb') -for l in infile.readlines(): - if l[:6] != '#latex': - out_file.write(l) -sys.exit(0) -""") - -test.write('mydvips.py', r""" -import os -import sys -infile = open(sys.argv[3], 'rb') -out_file = open(sys.argv[2], 'wb') -for l in infile.readlines(): - if l[:6] != '#dvips': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(TEX = r'%s mytex.py', - LATEX = r'%s mylatex.py', - DVIPS = r'%s mydvips.py', - tools=['tex', 'latex', 'dvips']) -dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') -env.PostScript(target = 'test1.ps', source = dvi) -env.PostScript(target = 'test2.ps', source = 'test2.tex') -env.PostScript(target = 'test3.ps', source = 'test3.ltx') -env.PostScript(target = 'test4.ps', source = 'test4.latex') -""" % (python, python, python)) - -test.write('test1.tex', r"""This is a .dvi test. -#tex -#dvips -""") - -test.write('test2.tex', r"""This is a .tex test. -#tex -#dvips -""") - -test.write('test3.ltx', r"""This is a .ltx test. -#latex -#dvips -""") - -test.write('test4.latex', r"""This is a .latex test. -#latex -#dvips -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1.ps') != "This is a .dvi test.\n") - -test.fail_test(test.read('test2.ps') != "This is a .tex test.\n") - -test.fail_test(test.read('test3.ps') != "This is a .ltx test.\n") - -test.fail_test(test.read('test4.ps') != "This is a .latex test.\n") - - - -dvips = test.where_is('dvips') - -if dvips: - - test.write("wrapper.py", """import os -import string -import sys -cmd = string.join(sys.argv[1:], " ") -open('%s', 'ab').write("%%s\\n" %% cmd) -os.system(cmd) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -import os -ENV = { 'PATH' : os.environ['PATH'] } -foo = Environment(ENV = ENV) -dvips = foo.Dictionary('DVIPS') -bar = Environment(ENV = ENV, DVIPS = r'%s wrapper.py ' + dvips) -foo.PostScript(target = 'foo.ps', source = 'foo.tex') -bar.PostScript(target = 'bar1', source = 'bar1.tex') -bar.PostScript(target = 'bar2', source = 'bar2.ltx') -bar.PostScript(target = 'bar3', source = 'bar3.latex') -""" % python) - - tex = r""" -This is the %s TeX file. -\end -""" - - latex = r""" -\documentclass{letter} -\begin{document} -This is the %s LaTeX file. -\end{document} -""" - - test.write('foo.tex', tex % 'foo.tex') - test.write('bar1.tex', tex % 'bar1.tex') - test.write('bar2.ltx', latex % 'bar2.ltx') - test.write('bar3.latex', latex % 'bar3.latex') - - test.run(arguments = 'foo.dvi', stderr = None) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.fail_test(not os.path.exists(test.workpath('foo.dvi'))) - - test.run(arguments = 'bar1.ps bar2.ps bar3.ps', stderr = None) - - expect = """dvips -o bar1.ps bar1.dvi -dvips -o bar2.ps bar2.dvi -dvips -o bar3.ps bar3.dvi -""" - - test.fail_test(test.read('wrapper.out') != expect) - - test.fail_test(not os.path.exists(test.workpath('bar1.ps'))) - test.fail_test(not os.path.exists(test.workpath('bar2.ps'))) - test.fail_test(not os.path.exists(test.workpath('bar3.ps'))) - -test.pass_test() diff --git a/test/DVIPS/DVIPS.py b/test/DVIPS/DVIPS.py new file mode 100644 index 0000000..2ae856a --- /dev/null +++ b/test/DVIPS/DVIPS.py @@ -0,0 +1,178 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import os.path +import string +import sys +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mytex.py', r""" +import os +import sys +base_name = os.path.splitext(sys.argv[1])[0] +infile = open(sys.argv[1], 'rb') +out_file = open(base_name+'.dvi', 'wb') +for l in infile.readlines(): + if l[:4] != '#tex': + out_file.write(l) +sys.exit(0) +""") + +test.write('mylatex.py', r""" +import os +import sys +base_name = os.path.splitext(sys.argv[1])[0] +infile = open(sys.argv[1], 'rb') +out_file = open(base_name+'.dvi', 'wb') +for l in infile.readlines(): + if l[:6] != '#latex': + out_file.write(l) +sys.exit(0) +""") + +test.write('mydvips.py', r""" +import os +import sys +infile = open(sys.argv[3], 'rb') +out_file = open(sys.argv[2], 'wb') +for l in infile.readlines(): + if l[:6] != '#dvips': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TEX = r'%s mytex.py', + LATEX = r'%s mylatex.py', + DVIPS = r'%s mydvips.py', + tools=['tex', 'latex', 'dvips']) +dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') +env.PostScript(target = 'test1.ps', source = dvi) +env.PostScript(target = 'test2.ps', source = 'test2.tex') +env.PostScript(target = 'test3.ps', source = 'test3.ltx') +env.PostScript(target = 'test4.ps', source = 'test4.latex') +""" % (python, python, python)) + +test.write('test1.tex', r"""This is a .dvi test. +#tex +#dvips +""") + +test.write('test2.tex', r"""This is a .tex test. +#tex +#dvips +""") + +test.write('test3.ltx', r"""This is a .ltx test. +#latex +#dvips +""") + +test.write('test4.latex', r"""This is a .latex test. +#latex +#dvips +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(test.read('test1.ps') != "This is a .dvi test.\n") + +test.fail_test(test.read('test2.ps') != "This is a .tex test.\n") + +test.fail_test(test.read('test3.ps') != "This is a .ltx test.\n") + +test.fail_test(test.read('test4.ps') != "This is a .latex test.\n") + + + +dvips = test.where_is('dvips') + +if dvips: + + test.write("wrapper.py", """import os +import string +import sys +cmd = string.join(sys.argv[1:], " ") +open('%s', 'ab').write("%%s\\n" %% cmd) +os.system(cmd) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + + test.write('SConstruct', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV) +dvips = foo.Dictionary('DVIPS') +bar = Environment(ENV = ENV, DVIPS = r'%s wrapper.py ' + dvips) +foo.PostScript(target = 'foo.ps', source = 'foo.tex') +bar.PostScript(target = 'bar1', source = 'bar1.tex') +bar.PostScript(target = 'bar2', source = 'bar2.ltx') +bar.PostScript(target = 'bar3', source = 'bar3.latex') +""" % python) + + tex = r""" +This is the %s TeX file. +\end +""" + + latex = r""" +\documentclass{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + test.write('foo.tex', tex % 'foo.tex') + test.write('bar1.tex', tex % 'bar1.tex') + test.write('bar2.ltx', latex % 'bar2.ltx') + test.write('bar3.latex', latex % 'bar3.latex') + + test.run(arguments = 'foo.dvi', stderr = None) + + test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + + test.fail_test(not os.path.exists(test.workpath('foo.dvi'))) + + test.run(arguments = 'bar1.ps bar2.ps bar3.ps', stderr = None) + + expect = """dvips -o bar1.ps bar1.dvi +dvips -o bar2.ps bar2.dvi +dvips -o bar3.ps bar3.dvi +""" + + test.fail_test(test.read('wrapper.out') != expect) + + test.fail_test(not os.path.exists(test.workpath('bar1.ps'))) + test.fail_test(not os.path.exists(test.workpath('bar2.ps'))) + test.fail_test(not os.path.exists(test.workpath('bar3.ps'))) + +test.pass_test() diff --git a/test/DVIPS/DVIPSFLAGS.py b/test/DVIPS/DVIPSFLAGS.py new file mode 100644 index 0000000..82e57c5 --- /dev/null +++ b/test/DVIPS/DVIPSFLAGS.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import os.path +import string +import sys +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mytex.py', r""" +import os +import sys +base_name = os.path.splitext(sys.argv[1])[0] +infile = open(sys.argv[1], 'rb') +out_file = open(base_name+'.dvi', 'wb') +for l in infile.readlines(): + if l[:4] != '#tex': + out_file.write(l) +sys.exit(0) +""") + +test.write('mylatex.py', r""" +import os +import sys +base_name = os.path.splitext(sys.argv[1])[0] +infile = open(sys.argv[1], 'rb') +out_file = open(base_name+'.dvi', 'wb') +for l in infile.readlines(): + if l[:6] != '#latex': + out_file.write(l) +sys.exit(0) +""") + +test.write('mydvips.py', r""" +import getopt +import os +import sys +cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:x', []) +opt_string = '' +for opt, arg in cmd_opts: + if opt == '-o': outfile = arg + else: opt_string = opt_string + ' ' + opt +infile = open(args[0], 'rb') +out_file = open(outfile, 'wb') +out_file.write(opt_string + "\n") +for l in infile.readlines(): + if l[:6] != '#dvips': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TEX = r'%s mytex.py', + LATEX = r'%s mylatex.py', + DVIPS = r'%s mydvips.py', DVIPSFLAGS = '-x', + tools=['tex', 'latex', 'dvips']) +dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') +env.PostScript(target = 'test1.ps', source = dvi) +env.PostScript(target = 'test2.ps', source = 'test2.tex') +env.PostScript(target = 'test3.ps', source = 'test3.ltx') +env.PostScript(target = 'test4.ps', source = 'test4.latex') +""" % (python, python, python)) + +test.write('test1.tex', r"""This is a .dvi test. +#tex +#dvips +""") + +test.write('test2.tex', r"""This is a .tex test. +#tex +#dvips +""") + +test.write('test3.ltx', r"""This is a .ltx test. +#latex +#dvips +""") + +test.write('test4.latex', r"""This is a .latex test. +#latex +#dvips +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(test.read('test1.ps') != " -x\nThis is a .dvi test.\n") + +test.fail_test(test.read('test2.ps') != " -x\nThis is a .tex test.\n") + +test.fail_test(test.read('test3.ps') != " -x\nThis is a .ltx test.\n") + +test.fail_test(test.read('test4.ps') != " -x\nThis is a .latex test.\n") + + + +dvips = test.where_is('dvips') + +if dvips: + + test.write("wrapper.py", """import os +import string +import sys +cmd = string.join(sys.argv[1:], " ") +open('%s', 'ab').write("%%s\\n" %% cmd) +os.system(cmd) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + + test.write('SConstruct', """ +import os +ENV = {'PATH' : os.environ['PATH']} +foo = Environment(ENV = ENV, DVIPSFLAGS = '-N') +dvips = foo.Dictionary('DVIPS') +bar = Environment(ENV = ENV,DVIPS = r'%s wrapper.py ' + dvips) +foo.PostScript(target = 'foo.ps', source = 'foo.tex') +bar.PostScript(target = 'bar1', source = 'bar1.tex') +bar.PostScript(target = 'bar2', source = 'bar2.ltx') +bar.PostScript(target = 'bar3', source = 'bar3.latex') +""" % python) + + tex = r""" +This is the %s TeX file. +\end +""" + + latex = r""" +\documentclass{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + test.write('foo.tex', tex % 'foo.tex') + test.write('bar1.tex', tex % 'bar1.tex') + test.write('bar2.ltx', latex % 'bar2.ltx') + test.write('bar3.latex', latex % 'bar3.latex') + + test.run(arguments = 'foo.dvi', stderr = None) + + test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + + test.fail_test(not os.path.exists(test.workpath('foo.dvi'))) + + test.run(arguments = 'bar1.ps bar2.ps bar3.ps', stderr = None) + + expect = """dvips -o bar1.ps bar1.dvi +dvips -o bar2.ps bar2.dvi +dvips -o bar3.ps bar3.dvi +""" + + test.fail_test(test.read('wrapper.out') != expect) + + test.fail_test(not os.path.exists(test.workpath('bar1.ps'))) + test.fail_test(not os.path.exists(test.workpath('bar2.ps'))) + test.fail_test(not os.path.exists(test.workpath('bar3.ps'))) + +test.pass_test() diff --git a/test/DVIPS/PSCOM.py b/test/DVIPS/PSCOM.py new file mode 100644 index 0000000..65e66a2 --- /dev/null +++ b/test/DVIPS/PSCOM.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to configure the $PSCOM construction variable. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myps.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*ps*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'dvips'], + PSCOM = r'%s myps.py $TARGET $SOURCES') +env.PostScript(target = 'aaa', source = 'aaa.dvi') +""" % python) + +test.write('aaa.dvi', "aaa.dvi\n/*ps*/\n") + +test.run() + +test.must_match('aaa.ps', "aaa.dvi\n") + + + +test.pass_test() diff --git a/test/DVIPS/PSCOMSTR.py b/test/DVIPS/PSCOMSTR.py new file mode 100644 index 0000000..9a565a4 --- /dev/null +++ b/test/DVIPS/PSCOMSTR.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that the $PSCOMSTR construction variable allows you to customize +the displayed string when is called. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myps.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*ps*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'dvips'], + PSCOM = r'%s myps.py $TARGET $SOURCES', + PSCOMSTR = 'PostScripting $TARGET from $SOURCE') +env.PostScript(target = 'aaa', source = 'aaa.dvi') +""" % python) + +test.write('aaa.dvi', "aaa.dvi\n/*ps*/\n") + +test.run(stdout = test.wrap_stdout("""\ +PostScripting aaa.ps from aaa.dvi +""")) + +test.must_match('aaa.ps', "aaa.dvi\n") + + + +test.pass_test() diff --git a/test/DVIPSFLAGS.py b/test/DVIPSFLAGS.py deleted file mode 100644 index 82e57c5..0000000 --- a/test/DVIPSFLAGS.py +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import os.path -import string -import sys -import TestSCons - -python = TestSCons.python - -test = TestSCons.TestSCons() - - - -test.write('mytex.py', r""" -import os -import sys -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.dvi', 'wb') -for l in infile.readlines(): - if l[:4] != '#tex': - out_file.write(l) -sys.exit(0) -""") - -test.write('mylatex.py', r""" -import os -import sys -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.dvi', 'wb') -for l in infile.readlines(): - if l[:6] != '#latex': - out_file.write(l) -sys.exit(0) -""") - -test.write('mydvips.py', r""" -import getopt -import os -import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 'o:x', []) -opt_string = '' -for opt, arg in cmd_opts: - if opt == '-o': outfile = arg - else: opt_string = opt_string + ' ' + opt -infile = open(args[0], 'rb') -out_file = open(outfile, 'wb') -out_file.write(opt_string + "\n") -for l in infile.readlines(): - if l[:6] != '#dvips': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(TEX = r'%s mytex.py', - LATEX = r'%s mylatex.py', - DVIPS = r'%s mydvips.py', DVIPSFLAGS = '-x', - tools=['tex', 'latex', 'dvips']) -dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex') -env.PostScript(target = 'test1.ps', source = dvi) -env.PostScript(target = 'test2.ps', source = 'test2.tex') -env.PostScript(target = 'test3.ps', source = 'test3.ltx') -env.PostScript(target = 'test4.ps', source = 'test4.latex') -""" % (python, python, python)) - -test.write('test1.tex', r"""This is a .dvi test. -#tex -#dvips -""") - -test.write('test2.tex', r"""This is a .tex test. -#tex -#dvips -""") - -test.write('test3.ltx', r"""This is a .ltx test. -#latex -#dvips -""") - -test.write('test4.latex', r"""This is a .latex test. -#latex -#dvips -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1.ps') != " -x\nThis is a .dvi test.\n") - -test.fail_test(test.read('test2.ps') != " -x\nThis is a .tex test.\n") - -test.fail_test(test.read('test3.ps') != " -x\nThis is a .ltx test.\n") - -test.fail_test(test.read('test4.ps') != " -x\nThis is a .latex test.\n") - - - -dvips = test.where_is('dvips') - -if dvips: - - test.write("wrapper.py", """import os -import string -import sys -cmd = string.join(sys.argv[1:], " ") -open('%s', 'ab').write("%%s\\n" %% cmd) -os.system(cmd) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -import os -ENV = {'PATH' : os.environ['PATH']} -foo = Environment(ENV = ENV, DVIPSFLAGS = '-N') -dvips = foo.Dictionary('DVIPS') -bar = Environment(ENV = ENV,DVIPS = r'%s wrapper.py ' + dvips) -foo.PostScript(target = 'foo.ps', source = 'foo.tex') -bar.PostScript(target = 'bar1', source = 'bar1.tex') -bar.PostScript(target = 'bar2', source = 'bar2.ltx') -bar.PostScript(target = 'bar3', source = 'bar3.latex') -""" % python) - - tex = r""" -This is the %s TeX file. -\end -""" - - latex = r""" -\documentclass{letter} -\begin{document} -This is the %s LaTeX file. -\end{document} -""" - - test.write('foo.tex', tex % 'foo.tex') - test.write('bar1.tex', tex % 'bar1.tex') - test.write('bar2.ltx', latex % 'bar2.ltx') - test.write('bar3.latex', latex % 'bar3.latex') - - test.run(arguments = 'foo.dvi', stderr = None) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.fail_test(not os.path.exists(test.workpath('foo.dvi'))) - - test.run(arguments = 'bar1.ps bar2.ps bar3.ps', stderr = None) - - expect = """dvips -o bar1.ps bar1.dvi -dvips -o bar2.ps bar2.dvi -dvips -o bar3.ps bar3.dvi -""" - - test.fail_test(test.read('wrapper.out') != expect) - - test.fail_test(not os.path.exists(test.workpath('bar1.ps'))) - test.fail_test(not os.path.exists(test.workpath('bar2.ps'))) - test.fail_test(not os.path.exists(test.workpath('bar3.ps'))) - -test.pass_test() diff --git a/test/GS.py b/test/GS.py deleted file mode 100644 index a836cf6..0000000 --- a/test/GS.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import os.path -import string -import sys -import TestSCons - -python = TestSCons.python - -test = TestSCons.TestSCons() - - - -test.write('mygs.py', r""" -import os -import sys -outfile = open(sys.argv[1], 'wb') -infile = open(sys.argv[2], 'rb') -for l in infile.readlines(): - if l[:3] != '#ps': - outfile.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(GS = r'%s mygs.py', - GSCOM = r'$GS $TARGET $SOURCE', - tools=['gs']) -env.PDF(target = 'test1.pdf', source = 'test1.ps') -""" % (python)) - -test.write('test1.ps', r"""This is a .ps test. -#ps -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1.pdf') != "This is a .ps test.\n") - - - -if sys.platform == 'win32': - gs_executable = 'gswin32c' -elif sys.platform == 'os2': - gs_executable = 'gsos2' -else: - gs_executable = 'gs' -gs = test.where_is(gs_executable) - -if gs: - - test.write("wrapper.py", """\ -import os -import string -import sys -cmd = string.join(sys.argv[1:], " ") -open('%s', 'ab').write("%%s\\n" %% cmd) -os.system(cmd) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """\ -import os -foo = Environment(ENV = { 'PATH' : os.environ['PATH'] }) -gs = foo.Dictionary('GS') -bar = Environment(ENV = { 'PATH' : os.environ['PATH'] }, - GS = r'%s wrapper.py ' + gs) -foo.PDF(target = 'foo.pdf', source = 'foo.ps') -bar.PDF(target = 'bar.pdf', source = 'bar.ps') -""" % python) - - input = """\ -%!PS-Adobe -100 100 moveto /Times-Roman findfont 24 scalefont (Hello, world!) show showpage -""" - - test.write('foo.ps', input) - - test.write('bar.ps', input) - - test.run(arguments = 'foo.pdf', stderr = None) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) - - test.run(arguments = 'bar.pdf', stderr = None) - - test.fail_test(test.read('wrapper.out') != "%s -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=bar.pdf bar.ps\n" % gs_executable) - - test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) - -test.pass_test() diff --git a/test/Ghostscript/GS.py b/test/Ghostscript/GS.py new file mode 100644 index 0000000..a836cf6 --- /dev/null +++ b/test/Ghostscript/GS.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import os.path +import string +import sys +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mygs.py', r""" +import os +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in infile.readlines(): + if l[:3] != '#ps': + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(GS = r'%s mygs.py', + GSCOM = r'$GS $TARGET $SOURCE', + tools=['gs']) +env.PDF(target = 'test1.pdf', source = 'test1.ps') +""" % (python)) + +test.write('test1.ps', r"""This is a .ps test. +#ps +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(test.read('test1.pdf') != "This is a .ps test.\n") + + + +if sys.platform == 'win32': + gs_executable = 'gswin32c' +elif sys.platform == 'os2': + gs_executable = 'gsos2' +else: + gs_executable = 'gs' +gs = test.where_is(gs_executable) + +if gs: + + test.write("wrapper.py", """\ +import os +import string +import sys +cmd = string.join(sys.argv[1:], " ") +open('%s', 'ab').write("%%s\\n" %% cmd) +os.system(cmd) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + + test.write('SConstruct', """\ +import os +foo = Environment(ENV = { 'PATH' : os.environ['PATH'] }) +gs = foo.Dictionary('GS') +bar = Environment(ENV = { 'PATH' : os.environ['PATH'] }, + GS = r'%s wrapper.py ' + gs) +foo.PDF(target = 'foo.pdf', source = 'foo.ps') +bar.PDF(target = 'bar.pdf', source = 'bar.ps') +""" % python) + + input = """\ +%!PS-Adobe +100 100 moveto /Times-Roman findfont 24 scalefont (Hello, world!) show showpage +""" + + test.write('foo.ps', input) + + test.write('bar.ps', input) + + test.run(arguments = 'foo.pdf', stderr = None) + + test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + + test.fail_test(not os.path.exists(test.workpath('foo.pdf'))) + + test.run(arguments = 'bar.pdf', stderr = None) + + test.fail_test(test.read('wrapper.out') != "%s -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=bar.pdf bar.ps\n" % gs_executable) + + test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) + +test.pass_test() diff --git a/test/Ghostscript/GSCOM.py b/test/Ghostscript/GSCOM.py new file mode 100644 index 0000000..acd46f2 --- /dev/null +++ b/test/Ghostscript/GSCOM.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to configure the $GSCOM construction variable. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mygs.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*gs*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'gs'], + GSCOM = r'%s mygs.py $TARGET $SOURCES') +env.PDF(target = 'aaa', source = 'aaa.ps') +""" % python) + +test.write('aaa.ps', "aaa.ps\n/*gs*/\n") + +test.run(arguments = '.') + +test.must_match('aaa.pdf', "aaa.ps\n") + + + +test.pass_test() diff --git a/test/Ghostscript/GSCOMSTR.py b/test/Ghostscript/GSCOMSTR.py new file mode 100644 index 0000000..9f7aee8 --- /dev/null +++ b/test/Ghostscript/GSCOMSTR.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that the $GSCOMSTR construction variable allows you to customize +the displayed string when Ghostscript is called. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mygs.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*gs*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'gs'], + GSCOM = r'%s mygs.py $TARGET $SOURCES', + GSCOMSTR = 'GSing $TARGET from $SOURCE') +env.PDF(target = 'aaa', source = 'aaa.ps') +""" % python) + +test.write('aaa.ps', "aaa.ps\n/*gs*/\n") + +test.run(stdout = test.wrap_stdout("""\ +GSing aaa.pdf from aaa.ps +""")) + +test.must_match('aaa.pdf', "aaa.ps\n") + + + +test.pass_test() diff --git a/test/M4.py b/test/M4.py deleted file mode 100644 index bf56e74..0000000 --- a/test/M4.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test that $M4 and $M4FLAGS work as expected. -""" - -import os -import os.path -import string -import sys -import TestSCons - -python = TestSCons.python - -test = TestSCons.TestSCons() - - - -test.write('mym4.py', """ -import string -import sys -contents = sys.stdin.read() -sys.stdout.write(string.replace(contents, 'M4', 'mym4.py')) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(M4 = r'%s mym4.py', tools=['default', 'm4']) -env.M4(target = 'aaa.x', source = 'aaa.x.m4') -""" % python) - -test.write('aaa.x.m4', """\ -line 1 -M4 -line 3 -""") - -test.run() - -test.fail_test(test.read(test.workpath('aaa.x'), 'r') != "line 1\nmym4.py\nline 3\n") - - - -m4 = test.where_is('m4') - -if m4: - - test.write("wrapper.py", -"""import os -import string -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(string.join(sys.argv[1:], " ")) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -foo = Environment(M4=r'%(m4)s', M4FLAGS='-DFFF=fff') -m4 = foo.Dictionary('M4') -bar = Environment(M4 = r'%(python)s wrapper.py ' + m4, M4FLAGS='-DBBB=bbb') -foo.M4(target = 'foo.x', source = 'foo.x.m4') -bar.M4(target = 'bar', source = 'bar.m4') -""" % locals()) - - test.write('foo.x.m4', "line 1\n" - "FFF\n" - "line 3\n") - - test.write('bar.m4', "line 1\n" - "BBB\n" - "line 3\n") - - test.run(arguments = '.') - - test.up_to_date(arguments = '.') - - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") - - test.fail_test(test.read('foo.x', 'r') != "line 1\nfff\nline 3\n") - - test.fail_test(test.read('bar', 'r') != "line 1\nbbb\nline 3\n") - -test.pass_test() diff --git a/test/M4/M4.py b/test/M4/M4.py new file mode 100644 index 0000000..bf56e74 --- /dev/null +++ b/test/M4/M4.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that $M4 and $M4FLAGS work as expected. +""" + +import os +import os.path +import string +import sys +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mym4.py', """ +import string +import sys +contents = sys.stdin.read() +sys.stdout.write(string.replace(contents, 'M4', 'mym4.py')) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(M4 = r'%s mym4.py', tools=['default', 'm4']) +env.M4(target = 'aaa.x', source = 'aaa.x.m4') +""" % python) + +test.write('aaa.x.m4', """\ +line 1 +M4 +line 3 +""") + +test.run() + +test.fail_test(test.read(test.workpath('aaa.x'), 'r') != "line 1\nmym4.py\nline 3\n") + + + +m4 = test.where_is('m4') + +if m4: + + test.write("wrapper.py", +"""import os +import string +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(string.join(sys.argv[1:], " ")) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + + test.write('SConstruct', """ +foo = Environment(M4=r'%(m4)s', M4FLAGS='-DFFF=fff') +m4 = foo.Dictionary('M4') +bar = Environment(M4 = r'%(python)s wrapper.py ' + m4, M4FLAGS='-DBBB=bbb') +foo.M4(target = 'foo.x', source = 'foo.x.m4') +bar.M4(target = 'bar', source = 'bar.m4') +""" % locals()) + + test.write('foo.x.m4', "line 1\n" + "FFF\n" + "line 3\n") + + test.write('bar.m4', "line 1\n" + "BBB\n" + "line 3\n") + + test.run(arguments = '.') + + test.up_to_date(arguments = '.') + + test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + + test.fail_test(test.read('foo.x', 'r') != "line 1\nfff\nline 3\n") + + test.fail_test(test.read('bar', 'r') != "line 1\nbbb\nline 3\n") + +test.pass_test() diff --git a/test/M4/M4COM.py b/test/M4/M4COM.py new file mode 100644 index 0000000..d1c53b4 --- /dev/null +++ b/test/M4/M4COM.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to configure the $M4COM construction variable. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mym4.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*m4*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'm4'], + M4COM = r'%s mym4.py $TARGET $SOURCES') +env.M4(target = 'aaa.out', source = 'aaa.in') +""" % python) + +test.write('aaa.in', "aaa.in\n/*m4*/\n") + +test.run(arguments = '.') + +test.must_match('aaa.out', "aaa.in\n") + + + +test.pass_test() diff --git a/test/M4/M4COMSTR.py b/test/M4/M4COMSTR.py new file mode 100644 index 0000000..0e14495 --- /dev/null +++ b/test/M4/M4COMSTR.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that the $M4COMSTR construction variable allows you to customize +the displayed string when m4 is called. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('mym4.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*m4*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'm4'], + M4COM = r'%s mym4.py $TARGET $SOURCES', + M4COMSTR = 'M4ing $TARGET from $SOURCE') +env.M4(target = 'aaa.out', source = 'aaa.in') +""" % python) + +test.write('aaa.in', "aaa.in\n/*m4*/\n") + +test.run(stdout = test.wrap_stdout("""\ +M4ing aaa.out from aaa.in +""")) + +test.must_match('aaa.out', "aaa.in\n") + + + +test.pass_test() diff --git a/test/Perforce.py b/test/Perforce.py deleted file mode 100644 index 5808b23..0000000 --- a/test/Perforce.py +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -""" -Test fetching source files from Perforce. - -This test requires that a Perforce server be running on the test system -on port 1666, as well as that of course a client must be present. -""" - -import os -import socket -import string - -import TestSCons - -test = TestSCons.TestSCons() - -p4 = test.where_is('p4') -if not p4: - print "Could not find Perforce, skipping test(s)." - test.pass_test(1) - -user = os.environ.get('USER') -if not user: - user = os.environ.get('USERNAME') -if not user: - user = os.environ.get('P4USER') - -host = socket.gethostname() - -# clean out everything -try: - test.run(program=p4, arguments='-p 1666 obliterate -y //testme/...') - test.run(program=p4, arguments='-p 1666 depot -d testme') -except TestSCons.TestFailed: - pass # it's okay if this fails...it will fail if the depot is clear already. - -# Set up a perforce depot for testing. -test.write("depotspec","""# A Perforce Depot Specification. -Depot: testme - -Owner: %s - -Date: 2003/02/19 17:21:41 - -Description: - A test depot. - -Type: local - -Address: subdir - -Map: testme/... -""" % user) - -test.run(program=p4, arguments='-p 1666 depot -i < depotspec') - -# Now set up 2 clients, one to check in some files, and one to -# do the building. -clientspec = """# A Perforce Client Specification. -Client: %s - -Owner: %s - -Host: %s - -Description: - Created by ccrain. - -Root: %s - -Options: noallwrite noclobber nocompress unlocked nomodtime normdir - -LineEnd: local - -View: - %s //%s/... -""" - -clientspec1 = clientspec % ("testclient1", user, host, test.workpath('import'), - "//testme/foo/...", "testclient1") -clientspec2 = clientspec % ("testclient2", user, host, test.workpath('work'), - "//testme/...", "testclient2") -test.write("testclient1", clientspec1) -test.write("testclient2", clientspec2) - -test.subdir('import', ['import', 'sub'], 'work') - -test.run(program=p4, arguments = '-p 1666 client -i < testclient1') -test.run(program=p4, arguments = '-p 1666 client -i < testclient2') - -test.write(['import', 'aaa.in'], "import/aaa.in\n") -test.write(['import', 'bbb.in'], "import/bbb.in\n") -test.write(['import', 'ccc.in'], "import/ccc.in\n") - -test.write(['import', 'sub', 'SConscript'], """ -Import("env") -env.Cat('ddd.out', 'ddd.in') -env.Cat('eee.out', 'eee.in') -env.Cat('fff.out', 'fff.in') -env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) -""") - -test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n") -test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n") -test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n") - -# Perforce uses the PWD environment variable in preference to the actual cwd -os.environ["PWD"] = test.workpath('import') -paths = map(os.path.normpath, [ 'sub/ddd.in', 'sub/eee.in', 'sub/fff.in', 'sub/SConscript' ]) -args = '-p 1666 -c testclient1 add -t binary *.in %s' % string.join(paths) -test.run(program=p4, chdir='import', arguments=args) - -test.write('changespec', """ -Change: new - -Client: testclient1 - -User: %s - -Status: new - -Description: - A test check in - -Files: - //testme/foo/aaa.in # add - //testme/foo/bbb.in # add - //testme/foo/ccc.in # add - //testme/foo/sub/SConscript # add - //testme/foo/sub/ddd.in # add - //testme/foo/sub/eee.in # add - //testme/foo/sub/fff.in # add -""" % user) - -test.run(program=p4, arguments='-p 1666 -c testclient1 submit -i < changespec') - -test.write(['work', 'SConstruct'], """ -def cat(env, source, target): - target = str(target[0]) - source = map(str, source) - f = open(target, "wb") - for src in source: - f.write(open(src, "rb").read()) - f.close() -env = Environment(BUILDERS={'Cat':Builder(action=cat)}, - P4FLAGS='-p 1666 -c testclient2') -env.Cat('aaa.out', 'foo/aaa.in') -env.Cat('bbb.out', 'foo/bbb.in') -env.Cat('ccc.out', 'foo/ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -env.SourceCode('.', env.Perforce()) -SConscript('foo/sub/SConscript', 'env') -""") - -test.subdir(['work', 'foo']) -test.write(['work', 'foo', 'bbb.in'], "work/foo/bbb.in\n") - -test.subdir(['work', 'foo', 'sub']) -test.write(['work', 'foo', 'sub', 'eee.in'], "work/foo/sub/eee.in\n") - -test.run(chdir = 'work', arguments = '.') -test.fail_test(test.read(['work', 'all']) != "import/aaa.in\nwork/foo/bbb.in\nimport/ccc.in\n") -test.fail_test(test.read(['work', 'foo', 'sub', 'all']) != "import/sub/ddd.in\nwork/foo/sub/eee.in\nimport/sub/fff.in\n") - -test.pass_test() diff --git a/test/Perforce/P4COM.py b/test/Perforce/P4COM.py new file mode 100644 index 0000000..c33254a --- /dev/null +++ b/test/Perforce/P4COM.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test setting the $P4COM variable. +""" + +import os.path + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +test.subdir('Perforce', ['Perforce', 'sub'], 'sub') + +sub_Perforce = os.path.join('sub', 'Perforce') +sub_SConscript = os.path.join('sub', 'SConscript') +sub_all = os.path.join('sub', 'all') +sub_ddd_in = os.path.join('sub', 'ddd.in') +sub_ddd_out = os.path.join('sub', 'ddd.out') +sub_eee_in = os.path.join('sub', 'eee.in') +sub_eee_out = os.path.join('sub', 'eee.out') +sub_fff_in = os.path.join('sub', 'fff.in') +sub_fff_out = os.path.join('sub', 'fff.out') + +test.write('my-p4.py', """ +import shutil +import sys +for f in sys.argv[1:]: + shutil.copy('Perforce/'+f, f) +""") + +test.write('SConstruct', """ +def cat(env, source, target): + target = str(target[0]) + source = map(str, source) + f = open(target, "wb") + for src in source: + f.write(open(src, "rb").read()) + f.close() +env = Environment(TOOLS = ['default', 'Perforce'], + BUILDERS={'Cat':Builder(action=cat)}, + P4COM='%(python)s my-p4.py $TARGET') +env.Cat('aaa.out', 'aaa.in') +env.Cat('bbb.out', 'bbb.in') +env.Cat('ccc.out', 'ccc.in') +env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +env.SourceCode('.', env.Perforce()) +SConscript('sub/SConscript', "env") +""" % locals()) + +test.write(['Perforce', 'sub', 'SConscript'], """\ +Import("env") +env.Cat('ddd.out', 'ddd.in') +env.Cat('eee.out', 'eee.in') +env.Cat('fff.out', 'fff.in') +env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) +""") + +test.write(['Perforce', 'aaa.in'], "Perforce/aaa.in\n") +test.write('bbb.in', "checked-out bbb.in\n") +test.write(['Perforce', 'ccc.in'], "Perforce/ccc.in\n") + +test.write(['Perforce', 'sub', 'ddd.in'], "Perforce/sub/ddd.in\n") +test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") +test.write(['Perforce', 'sub', 'fff.in'], "Perforce/sub/fff.in\n") + +test.run(arguments = '.', + stdout = test.wrap_stdout(read_str = """\ +%(python)s my-p4.py %(sub_SConscript)s +""" % locals(), + build_str = """\ +%(python)s my-p4.py aaa.in +cat(["aaa.out"], ["aaa.in"]) +cat(["bbb.out"], ["bbb.in"]) +%(python)s my-p4.py ccc.in +cat(["ccc.out"], ["ccc.in"]) +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +%(python)s my-p4.py %(sub_ddd_in)s +cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) +cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) +%(python)s my-p4.py %(sub_fff_in)s +cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) +cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) +""" % locals())) + +test.must_match('all', + "Perforce/aaa.in\nchecked-out bbb.in\nPerforce/ccc.in\n") + +test.must_match(['sub', 'all'], + "Perforce/sub/ddd.in\nchecked-out sub/eee.in\nPerforce/sub/fff.in\n") + + + +# +test.pass_test() diff --git a/test/Perforce/P4COMSTR.py b/test/Perforce/P4COMSTR.py new file mode 100644 index 0000000..d9a3bc0 --- /dev/null +++ b/test/Perforce/P4COMSTR.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test setting the $P4COMSTR variable. +""" + +import os.path + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +test.subdir('Perforce', ['Perforce', 'sub'], 'sub') + +sub_Perforce = os.path.join('sub', 'Perforce') +sub_SConscript = os.path.join('sub', 'SConscript') +sub_all = os.path.join('sub', 'all') +sub_ddd_in = os.path.join('sub', 'ddd.in') +sub_ddd_out = os.path.join('sub', 'ddd.out') +sub_eee_in = os.path.join('sub', 'eee.in') +sub_eee_out = os.path.join('sub', 'eee.out') +sub_fff_in = os.path.join('sub', 'fff.in') +sub_fff_out = os.path.join('sub', 'fff.out') + +test.write('my-p4.py', """ +import shutil +import sys +for f in sys.argv[1:]: + shutil.copy('Perforce/'+f, f) +""") + +test.write('SConstruct', """ +def cat(env, source, target): + target = str(target[0]) + source = map(str, source) + f = open(target, "wb") + for src in source: + f.write(open(src, "rb").read()) + f.close() +env = Environment(TOOLS = ['default', 'Perforce'], + BUILDERS={'Cat':Builder(action=cat)}, + P4COM='%(python)s my-p4.py $TARGET', + P4COMSTR='Checking out $TARGET from our fake Perforce') +env.Cat('aaa.out', 'aaa.in') +env.Cat('bbb.out', 'bbb.in') +env.Cat('ccc.out', 'ccc.in') +env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +env.SourceCode('.', env.Perforce()) +SConscript('sub/SConscript', "env") +""" % locals()) + +test.write(['Perforce', 'sub', 'SConscript'], """\ +Import("env") +env.Cat('ddd.out', 'ddd.in') +env.Cat('eee.out', 'eee.in') +env.Cat('fff.out', 'fff.in') +env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) +""") + +test.write(['Perforce', 'aaa.in'], "Perforce/aaa.in\n") +test.write('bbb.in', "checked-out bbb.in\n") +test.write(['Perforce', 'ccc.in'], "Perforce/ccc.in\n") + +test.write(['Perforce', 'sub', 'ddd.in'], "Perforce/sub/ddd.in\n") +test.write(['sub', 'eee.in'], "checked-out sub/eee.in\n") +test.write(['Perforce', 'sub', 'fff.in'], "Perforce/sub/fff.in\n") + +test.run(arguments = '.', + stdout = test.wrap_stdout(read_str = """\ +Checking out %(sub_SConscript)s from our fake Perforce +""" % locals(), + build_str = """\ +Checking out aaa.in from our fake Perforce +cat(["aaa.out"], ["aaa.in"]) +cat(["bbb.out"], ["bbb.in"]) +Checking out ccc.in from our fake Perforce +cat(["ccc.out"], ["ccc.in"]) +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +Checking out %(sub_ddd_in)s from our fake Perforce +cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"]) +cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"]) +Checking out %(sub_fff_in)s from our fake Perforce +cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"]) +cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"]) +""" % locals())) + +test.must_match('all', + "Perforce/aaa.in\nchecked-out bbb.in\nPerforce/ccc.in\n") + +test.must_match(['sub', 'all'], + "Perforce/sub/ddd.in\nchecked-out sub/eee.in\nPerforce/sub/fff.in\n") + + + +# +test.pass_test() diff --git a/test/Perforce/Perforce.py b/test/Perforce/Perforce.py new file mode 100644 index 0000000..5808b23 --- /dev/null +++ b/test/Perforce/Perforce.py @@ -0,0 +1,190 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test fetching source files from Perforce. + +This test requires that a Perforce server be running on the test system +on port 1666, as well as that of course a client must be present. +""" + +import os +import socket +import string + +import TestSCons + +test = TestSCons.TestSCons() + +p4 = test.where_is('p4') +if not p4: + print "Could not find Perforce, skipping test(s)." + test.pass_test(1) + +user = os.environ.get('USER') +if not user: + user = os.environ.get('USERNAME') +if not user: + user = os.environ.get('P4USER') + +host = socket.gethostname() + +# clean out everything +try: + test.run(program=p4, arguments='-p 1666 obliterate -y //testme/...') + test.run(program=p4, arguments='-p 1666 depot -d testme') +except TestSCons.TestFailed: + pass # it's okay if this fails...it will fail if the depot is clear already. + +# Set up a perforce depot for testing. +test.write("depotspec","""# A Perforce Depot Specification. +Depot: testme + +Owner: %s + +Date: 2003/02/19 17:21:41 + +Description: + A test depot. + +Type: local + +Address: subdir + +Map: testme/... +""" % user) + +test.run(program=p4, arguments='-p 1666 depot -i < depotspec') + +# Now set up 2 clients, one to check in some files, and one to +# do the building. +clientspec = """# A Perforce Client Specification. +Client: %s + +Owner: %s + +Host: %s + +Description: + Created by ccrain. + +Root: %s + +Options: noallwrite noclobber nocompress unlocked nomodtime normdir + +LineEnd: local + +View: + %s //%s/... +""" + +clientspec1 = clientspec % ("testclient1", user, host, test.workpath('import'), + "//testme/foo/...", "testclient1") +clientspec2 = clientspec % ("testclient2", user, host, test.workpath('work'), + "//testme/...", "testclient2") +test.write("testclient1", clientspec1) +test.write("testclient2", clientspec2) + +test.subdir('import', ['import', 'sub'], 'work') + +test.run(program=p4, arguments = '-p 1666 client -i < testclient1') +test.run(program=p4, arguments = '-p 1666 client -i < testclient2') + +test.write(['import', 'aaa.in'], "import/aaa.in\n") +test.write(['import', 'bbb.in'], "import/bbb.in\n") +test.write(['import', 'ccc.in'], "import/ccc.in\n") + +test.write(['import', 'sub', 'SConscript'], """ +Import("env") +env.Cat('ddd.out', 'ddd.in') +env.Cat('eee.out', 'eee.in') +env.Cat('fff.out', 'fff.in') +env.Cat('all', ['ddd.out', 'eee.out', 'fff.out']) +""") + +test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n") +test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n") +test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n") + +# Perforce uses the PWD environment variable in preference to the actual cwd +os.environ["PWD"] = test.workpath('import') +paths = map(os.path.normpath, [ 'sub/ddd.in', 'sub/eee.in', 'sub/fff.in', 'sub/SConscript' ]) +args = '-p 1666 -c testclient1 add -t binary *.in %s' % string.join(paths) +test.run(program=p4, chdir='import', arguments=args) + +test.write('changespec', """ +Change: new + +Client: testclient1 + +User: %s + +Status: new + +Description: + A test check in + +Files: + //testme/foo/aaa.in # add + //testme/foo/bbb.in # add + //testme/foo/ccc.in # add + //testme/foo/sub/SConscript # add + //testme/foo/sub/ddd.in # add + //testme/foo/sub/eee.in # add + //testme/foo/sub/fff.in # add +""" % user) + +test.run(program=p4, arguments='-p 1666 -c testclient1 submit -i < changespec') + +test.write(['work', 'SConstruct'], """ +def cat(env, source, target): + target = str(target[0]) + source = map(str, source) + f = open(target, "wb") + for src in source: + f.write(open(src, "rb").read()) + f.close() +env = Environment(BUILDERS={'Cat':Builder(action=cat)}, + P4FLAGS='-p 1666 -c testclient2') +env.Cat('aaa.out', 'foo/aaa.in') +env.Cat('bbb.out', 'foo/bbb.in') +env.Cat('ccc.out', 'foo/ccc.in') +env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +env.SourceCode('.', env.Perforce()) +SConscript('foo/sub/SConscript', 'env') +""") + +test.subdir(['work', 'foo']) +test.write(['work', 'foo', 'bbb.in'], "work/foo/bbb.in\n") + +test.subdir(['work', 'foo', 'sub']) +test.write(['work', 'foo', 'sub', 'eee.in'], "work/foo/sub/eee.in\n") + +test.run(chdir = 'work', arguments = '.') +test.fail_test(test.read(['work', 'all']) != "import/aaa.in\nwork/foo/bbb.in\nimport/ccc.in\n") +test.fail_test(test.read(['work', 'foo', 'sub', 'all']) != "import/sub/ddd.in\nwork/foo/sub/eee.in\nimport/sub/fff.in\n") + +test.pass_test() diff --git a/test/SWIG.py b/test/SWIG.py deleted file mode 100644 index 2a0ee32..0000000 --- a/test/SWIG.py +++ /dev/null @@ -1,194 +0,0 @@ -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# 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. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import os -import string -import sys -import TestSCons - -python = TestSCons.python -_exe = TestSCons._exe -_obj = TestSCons._obj -_dll = TestSCons._dll - -test = TestSCons.TestSCons() - - - -test.write('myswig.py', r""" -import getopt -import sys -opts, args = getopt.getopt(sys.argv[1:], 'c:o:') -for opt, arg in opts: - if opt == '-c': pass - elif opt == '-o': out = arg -infile = open(args[0], 'rb') -outfile = open(out, 'wb') -for l in infile.readlines(): - if l[:4] != 'swig': - outfile.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(tools=['default', 'swig'], SWIG = r'%s myswig.py') -env.Program(target = 'test1', source = 'test1.i') -env.CFile(target = 'test2', source = 'test2.i') -env.Copy(SWIGFLAGS = '-c++').Program(target = 'test3', source = 'test3.i') -""" % (python)) - -test.write('test1.i', r""" -int -main(int argc, char *argv[]) { - argv[argc++] = "--"; - printf("test1.i\n"); - exit (0); -} -swig -""") - -test.write('test2.i', r"""test2.i -swig -""") - -test.write('test3.i', r""" -#include -#include -int -main(int argc, char *argv[]) { - argv[argc++] = "--"; - printf("test3.i\n"); - exit (0); -} -swig -""") - -test.run(arguments = '.', stderr = None) - -test.run(program = test.workpath('test1' + _exe), stdout = "test1.i\n") -test.fail_test(not os.path.exists(test.workpath('test1_wrap.c'))) -test.fail_test(not os.path.exists(test.workpath('test1_wrap' + _obj))) - -test.fail_test(test.read('test2_wrap.c') != "test2.i\n") - -test.run(program = test.workpath('test3' + _exe), stdout = "test3.i\n") -test.fail_test(not os.path.exists(test.workpath('test3_wrap.cc'))) -test.fail_test(not os.path.exists(test.workpath('test3_wrap' + _obj))) - - - -swig = test.where_is('swig') - -if swig: - - version = sys.version[:3] # see also sys.prefix documentation - - test.write("wrapper.py", -"""import os -import string -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(string.join(sys.argv[1:], " ")) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -foo = Environment(SWIGFLAGS='-python', - CPPPATH='%s/include/python%s/', - SHCCFLAGS='', - SHOBJSUFFIX='.o', - SHLIBPREFIX='') -swig = foo.Dictionary('SWIG') -bar = foo.Copy(SWIG = r'%s wrapper.py ' + swig) -foo.SharedLibrary(target = 'foo', source = ['foo.c', 'foo.i']) -bar.SharedLibrary(target = 'bar', source = ['bar.c', 'bar.i']) -""" % (sys.prefix, version, python)) - - test.write("foo.c", """\ -char * -foo_string() -{ - return "This is foo.c!"; -} -""") - - test.write("foo.i", """\ -%module foo -%{ -/* Put header files here (optional) */ -%} - -extern char *foo_string(); -""") - - test.write("bar.c", """\ -char * -bar_string() -{ - return "This is bar.c!"; -} -""") - - test.write("bar.i", """\ -%module bar -%{ -/* Put header files here (optional) */ -%} - -extern char *bar_string(); -""") - - test.run(arguments = 'foo' + _dll) - - test.fail_test(os.path.exists(test.workpath('wrapper.out'))) - - test.run(program = python, stdin = """\ -import foo -print foo.foo_string() -""", stdout="""\ -This is foo.c! -""") - - test.up_to_date(arguments = 'foo' + _dll) - - test.run(arguments = 'bar' + _dll) - - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") - - test.run(program = python, stdin = """\ -import foo -import bar -print foo.foo_string() -print bar.bar_string() -""", stdout="""\ -This is foo.c! -This is bar.c! -""") - - test.up_to_date(arguments = '.') - - - -test.pass_test() diff --git a/test/SWIG/SWIG.py b/test/SWIG/SWIG.py new file mode 100644 index 0000000..2a0ee32 --- /dev/null +++ b/test/SWIG/SWIG.py @@ -0,0 +1,194 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python +_exe = TestSCons._exe +_obj = TestSCons._obj +_dll = TestSCons._dll + +test = TestSCons.TestSCons() + + + +test.write('myswig.py', r""" +import getopt +import sys +opts, args = getopt.getopt(sys.argv[1:], 'c:o:') +for opt, arg in opts: + if opt == '-c': pass + elif opt == '-o': out = arg +infile = open(args[0], 'rb') +outfile = open(out, 'wb') +for l in infile.readlines(): + if l[:4] != 'swig': + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'swig'], SWIG = r'%s myswig.py') +env.Program(target = 'test1', source = 'test1.i') +env.CFile(target = 'test2', source = 'test2.i') +env.Copy(SWIGFLAGS = '-c++').Program(target = 'test3', source = 'test3.i') +""" % (python)) + +test.write('test1.i', r""" +int +main(int argc, char *argv[]) { + argv[argc++] = "--"; + printf("test1.i\n"); + exit (0); +} +swig +""") + +test.write('test2.i', r"""test2.i +swig +""") + +test.write('test3.i', r""" +#include +#include +int +main(int argc, char *argv[]) { + argv[argc++] = "--"; + printf("test3.i\n"); + exit (0); +} +swig +""") + +test.run(arguments = '.', stderr = None) + +test.run(program = test.workpath('test1' + _exe), stdout = "test1.i\n") +test.fail_test(not os.path.exists(test.workpath('test1_wrap.c'))) +test.fail_test(not os.path.exists(test.workpath('test1_wrap' + _obj))) + +test.fail_test(test.read('test2_wrap.c') != "test2.i\n") + +test.run(program = test.workpath('test3' + _exe), stdout = "test3.i\n") +test.fail_test(not os.path.exists(test.workpath('test3_wrap.cc'))) +test.fail_test(not os.path.exists(test.workpath('test3_wrap' + _obj))) + + + +swig = test.where_is('swig') + +if swig: + + version = sys.version[:3] # see also sys.prefix documentation + + test.write("wrapper.py", +"""import os +import string +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(string.join(sys.argv[1:], " ")) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + + test.write('SConstruct', """ +foo = Environment(SWIGFLAGS='-python', + CPPPATH='%s/include/python%s/', + SHCCFLAGS='', + SHOBJSUFFIX='.o', + SHLIBPREFIX='') +swig = foo.Dictionary('SWIG') +bar = foo.Copy(SWIG = r'%s wrapper.py ' + swig) +foo.SharedLibrary(target = 'foo', source = ['foo.c', 'foo.i']) +bar.SharedLibrary(target = 'bar', source = ['bar.c', 'bar.i']) +""" % (sys.prefix, version, python)) + + test.write("foo.c", """\ +char * +foo_string() +{ + return "This is foo.c!"; +} +""") + + test.write("foo.i", """\ +%module foo +%{ +/* Put header files here (optional) */ +%} + +extern char *foo_string(); +""") + + test.write("bar.c", """\ +char * +bar_string() +{ + return "This is bar.c!"; +} +""") + + test.write("bar.i", """\ +%module bar +%{ +/* Put header files here (optional) */ +%} + +extern char *bar_string(); +""") + + test.run(arguments = 'foo' + _dll) + + test.fail_test(os.path.exists(test.workpath('wrapper.out'))) + + test.run(program = python, stdin = """\ +import foo +print foo.foo_string() +""", stdout="""\ +This is foo.c! +""") + + test.up_to_date(arguments = 'foo' + _dll) + + test.run(arguments = 'bar' + _dll) + + test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + + test.run(program = python, stdin = """\ +import foo +import bar +print foo.foo_string() +print bar.bar_string() +""", stdout="""\ +This is foo.c! +This is bar.c! +""") + + test.up_to_date(arguments = '.') + + + +test.pass_test() diff --git a/test/SWIG/SWIGCOM.py b/test/SWIG/SWIGCOM.py new file mode 100644 index 0000000..22e217a --- /dev/null +++ b/test/SWIG/SWIGCOM.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the ability to configure the $SWIGCOM construction variable. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myswig.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*swig*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'swig'], + SWIGCOM = r'%s myswig.py $TARGET $SOURCES') +env.CFile(target = 'aaa', source = 'aaa.i') +env.CXXFile(target = 'bbb', source = 'bbb.i', SWIGFLAGS='-c++') +""" % python) + +test.write('aaa.i', "aaa.i\n/*swig*/\n") +test.write('bbb.i', "bbb.i\n/*swig*/\n") + +test.run(arguments = '.') + +test.must_match('aaa_wrap.c', "aaa.i\n") +test.must_match('bbb_wrap.cc', "bbb.i\n") + + + +test.pass_test() diff --git a/test/SWIG/SWIGCOMSTR.py b/test/SWIG/SWIGCOMSTR.py new file mode 100644 index 0000000..3ffcdbf --- /dev/null +++ b/test/SWIG/SWIGCOMSTR.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test that the $SWIGCOMSTR construction variable allows you to customize +the displayed string when swig is called. +""" + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + + + +test.write('myswig.py', """ +import sys +outfile = open(sys.argv[1], 'wb') +for f in sys.argv[2:]: + infile = open(f, 'rb') + for l in filter(lambda l: l != '/*swig*/\\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(tools=['default', 'swig'], + SWIGCOM = r'%s myswig.py $TARGET $SOURCES', + SWIGCOMSTR = 'Swigging $TARGET from $SOURCE') +env.CFile(target = 'aaa', source = 'aaa.i') +env.CXXFile(target = 'bbb', source = 'bbb.i', SWIGFLAGS='-c++') +""" % python) + +test.write('aaa.i', "aaa.i\n/*swig*/\n") +test.write('bbb.i', "bbb.i\n/*swig*/\n") + +test.run(stdout = test.wrap_stdout("""\ +Swigging aaa_wrap.c from aaa.i +Swigging bbb_wrap.cc from bbb.i +""")) + +test.must_match('aaa_wrap.c', "aaa.i\n") +test.must_match('bbb_wrap.cc', "bbb.i\n") + + + +test.pass_test() -- cgit v0.12