From abcf29987d2baa25d51716f888015aaa9d104d36 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 3 Dec 2004 04:09:35 +0000 Subject: More command-line customizability: , , , , . --- doc/man/scons.1 | 28 +++++++ src/CHANGES.txt | 13 +-- src/engine/SCons/Tool/latex.py | 2 +- src/engine/SCons/Tool/pdflatex.py | 2 +- src/engine/SCons/Tool/pdftex.py | 5 +- src/engine/SCons/Tool/tex.py | 29 ++++--- test/LATEX.py | 117 --------------------------- test/LATEXFLAGS.py | 123 ---------------------------- test/PDFLATEX.py | 117 --------------------------- test/PDFLATEXFLAGS.py | 123 ---------------------------- test/PDFTEX.py | 108 ------------------------- test/PDFTEXFLAGS.py | 114 -------------------------- test/TEX.py | 164 -------------------------------------- test/TEX/LATEX.py | 117 +++++++++++++++++++++++++++ test/TEX/LATEXCOM.py | 69 ++++++++++++++++ test/TEX/LATEXCOMSTR.py | 73 +++++++++++++++++ test/TEX/LATEXFLAGS.py | 123 ++++++++++++++++++++++++++++ test/TEX/PDFLATEX.py | 117 +++++++++++++++++++++++++++ test/TEX/PDFLATEXCOM.py | 69 ++++++++++++++++ test/TEX/PDFLATEXCOMSTR.py | 74 +++++++++++++++++ test/TEX/PDFLATEXFLAGS.py | 123 ++++++++++++++++++++++++++++ test/TEX/PDFTEX.py | 108 +++++++++++++++++++++++++ test/TEX/PDFTEXCOM.py | 69 ++++++++++++++++ test/TEX/PDFTEXCOMSTR.py | 74 +++++++++++++++++ test/TEX/PDFTEXFLAGS.py | 114 ++++++++++++++++++++++++++ test/TEX/TEX.py | 164 ++++++++++++++++++++++++++++++++++++++ test/TEX/TEXCOM.py | 69 ++++++++++++++++ test/TEX/TEXCOMSTR.py | 73 +++++++++++++++++ test/TEX/TEXFLAGS.py | 114 ++++++++++++++++++++++++++ test/TEXFLAGS.py | 114 -------------------------- 30 files changed, 1609 insertions(+), 1000 deletions(-) delete mode 100644 test/LATEX.py delete mode 100644 test/LATEXFLAGS.py delete mode 100644 test/PDFLATEX.py delete mode 100644 test/PDFLATEXFLAGS.py delete mode 100644 test/PDFTEX.py delete mode 100644 test/PDFTEXFLAGS.py delete mode 100644 test/TEX.py create mode 100644 test/TEX/LATEX.py create mode 100644 test/TEX/LATEXCOM.py create mode 100644 test/TEX/LATEXCOMSTR.py create mode 100644 test/TEX/LATEXFLAGS.py create mode 100644 test/TEX/PDFLATEX.py create mode 100644 test/TEX/PDFLATEXCOM.py create mode 100644 test/TEX/PDFLATEXCOMSTR.py create mode 100644 test/TEX/PDFLATEXFLAGS.py create mode 100644 test/TEX/PDFTEX.py create mode 100644 test/TEX/PDFTEXCOM.py create mode 100644 test/TEX/PDFTEXCOMSTR.py create mode 100644 test/TEX/PDFTEXFLAGS.py create mode 100644 test/TEX/TEX.py create mode 100644 test/TEX/TEXCOM.py create mode 100644 test/TEX/TEXCOMSTR.py create mode 100644 test/TEX/TEXFLAGS.py delete mode 100644 test/TEXFLAGS.py diff --git a/doc/man/scons.1 b/doc/man/scons.1 index f620a9f..f83fc96 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -4503,6 +4503,16 @@ The command line used to call the bibliography generator for the TeX formatter and typesetter and the LaTeX structured formatter and typesetter. +.IP BIBTEXCOMSTR +The string displayed when generating a bibliography +for TeX or LaTeX. +If this is not set, then $BIBTEXCOM (the command line) is displayed. + +.ES +env = Environment(BIBTEXCOMSTR = "Generating bibliography $TARGET") +.EE + + .IP BIBTEXFLAGS General options passed to the bibliography generator for the TeX formatter and typesetter and the LaTeX structured formatter and typesetter. @@ -5584,6 +5594,15 @@ The LaTeX structured formatter and typesetter. .IP LATEXCOM The command line used to call the LaTeX structured formatter and typesetter. +.IP LATEXCOMSTR +The string displayed when calling +the LaTeX structured formatter and typesetter. +If this is not set, then $LATEXCOM (the command line) is displayed. + +.ES +env = Environment(LATEXCOMSTR = "Building $TARGET from LaTeX input $SOURCES") +.EE + .IP LATEXFLAGS General options passed to the LaTeX structured formatter and typesetter. @@ -6764,6 +6783,15 @@ The TeX formatter and typesetter. .IP TEXCOM The command line used to call the TeX formatter and typesetter. +.IP TEXCOMSTR +The string displayed when calling +the TeX formatter and typesetter. +If this is not set, then $TEXCOM (the command line) is displayed. + +.ES +env = Environment(TEXCOMSTR = "Building $TARGET from TeX input $SOURCES") +.EE + .IP TEXFLAGS General options passed to the TeX formatter and typesetter. diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 40d8454..ebfc13c 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -130,14 +130,15 @@ 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 new construction variables: $ARCOMSTR, $ASCOMSTR, - $ASPPCOMSTR, $BITKEEPERCOMSTR, $CCCOMSTR, $CVSCOMSTR, $CXXCOMSTR, - $F77COMSTR, $F90COMSTR, $F95COMSTR, $FORTRANCOMSTR, $JARCOMSTR, - $JAVACCOMSTR, $JAVAHCOMSTR, $LEXCOMSTR, $LINKCOMSTR, $RCSCOMSTR, + - 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, $YACCCOMSTR and $ZIPCOMSTR. + $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/latex.py b/src/engine/SCons/Tool/latex.py index 7bbec6f..f182b35 100644 --- a/src/engine/SCons/Tool/latex.py +++ b/src/engine/SCons/Tool/latex.py @@ -37,7 +37,7 @@ import SCons.Action import SCons.Defaults import SCons.Util -LaTeXAction = SCons.Action.Action('$LATEXCOM') +LaTeXAction = SCons.Action.Action('$LATEXCOM', '$LATEXCOMSTR') def generate(env): """Add Builders and construction variables for LaTeX to an Environment.""" diff --git a/src/engine/SCons/Tool/pdflatex.py b/src/engine/SCons/Tool/pdflatex.py index b1a559a..57c6e2d 100644 --- a/src/engine/SCons/Tool/pdflatex.py +++ b/src/engine/SCons/Tool/pdflatex.py @@ -37,7 +37,7 @@ import SCons.Action import SCons.Defaults import SCons.Util -PDFLaTeXAction = SCons.Action.Action('$PDFLATEXCOM') +PDFLaTeXAction = SCons.Action.Action('$PDFLATEXCOM', '$PDFLATEXCOMSTR') def generate(env): """Add Builders and construction variables for pdflatex to an Environment.""" diff --git a/src/engine/SCons/Tool/pdftex.py b/src/engine/SCons/Tool/pdftex.py index 3d2add0..366151e 100644 --- a/src/engine/SCons/Tool/pdftex.py +++ b/src/engine/SCons/Tool/pdftex.py @@ -33,9 +33,12 @@ selection method. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import SCons.Action import SCons.Defaults import SCons.Util +PDFTeXAction = SCons.Action.Action('$PDFTEXCOM', '$PDFTEXCOMSTR') + def generate(env): """Add Builders and construction variables for pdftex to an Environment.""" try: @@ -44,7 +47,7 @@ def generate(env): bld = SCons.Defaults.PDF() env['BUILDERS']['PDF'] = bld - bld.add_action('.tex', '$PDFTEXCOM') + bld.add_action('.tex', PDFTeXAction) env['PDFTEX'] = 'pdftex' env['PDFTEXFLAGS'] = SCons.Util.CLVar('') diff --git a/src/engine/SCons/Tool/tex.py b/src/engine/SCons/Tool/tex.py index b9257ea..db2664a 100644 --- a/src/engine/SCons/Tool/tex.py +++ b/src/engine/SCons/Tool/tex.py @@ -45,14 +45,14 @@ import SCons.Util # Define an action to build a generic tex file. This is sufficient for all # tex files. -TeXAction = SCons.Action.CommandAction("$TEXCOM") +TeXAction = SCons.Action.Action("$TEXCOM", "$TEXCOMSTR") # Define an action to build a latex file. This action might be needed more # than once if we are dealing with labels and bibtex -LaTeXAction = SCons.Action.CommandAction("$LATEXCOM") +LaTeXAction = SCons.Action.Action("$LATEXCOM", "$LATEXCOMSTR") # Define an action to run BibTeX on a file. -BibTeXAction = SCons.Action.CommandAction("$BIBTEXCOM") +BibTeXAction = SCons.Action.Action("$BIBTEXCOM", "$BIBTEXCOMSTR") def LaTeXAuxAction(target = None, source= None, env=None): """A builder for LaTeX files that checks the output in the aux file @@ -74,22 +74,29 @@ def LaTeXAuxAction(target = None, source= None, env=None): LaTeXAction(target,source,env) return 0 -def TeXLaTeXAction(target = None, source= None, env=None): +LaTeX_re = re.compile("\\\\document(style|class)") + +def is_LaTeX(flist): + # Scan a file list to decide if it's TeX- or LaTeX-flavored. + for f in flist: + content = f.get_contents() + if LaTeX_re.search(content): + return 1 + return 0 + +def TeXLaTeXFunction(target = None, source= None, env=None): """A builder for TeX and LaTeX that scans the source file to decide the "flavor" of the source and then executes the appropriate program.""" - LaTeXFile = None - for src in source: - content = src.get_contents() - if re.search("\\\\document(style|class)",content): - LaTeXFile = 1 - break - if LaTeXFile: + if is_LaTeX(source): LaTeXAuxAction(target,source,env) else: TeXAction(target,source,env) return 0 +TeXLaTeXAction = SCons.Action.Action(TeXLaTeXFunction, + strfunction=None) + def generate(env): """Add Builders and construction variables for TeX to an Environment.""" try: diff --git a/test/LATEX.py b/test/LATEX.py deleted file mode 100644 index 4ed080f..0000000 --- a/test/LATEX.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('mylatex.py', r""" -import sys -import os -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[0] != '\\': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(LATEX = r'%s mylatex.py', tools=['latex']) -env.DVI(target = 'test1.dvi', source = 'test1.ltx') -env.DVI(target = 'test2.dvi', source = 'test2.latex') -""" % python) - -test.write('test1.ltx', r"""This is a .ltx test. -\end -""") - -test.write('test2.latex', r"""This is a .latex test. -\end -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1.dvi') != "This is a .ltx test.\n") - -test.fail_test(test.read('test2.dvi') != "This is a .latex test.\n") - - - -latex = test.where_is('latex') - -if latex: - - 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', """ -import os -ENV = { 'PATH' : os.environ['PATH'] } -foo = Environment(ENV = ENV) -latex = foo.Dictionary('LATEX') -bar = Environment(ENV = ENV, LATEX = r'%s wrapper.py ' + latex) -foo.DVI(target = 'foo.dvi', source = 'foo.ltx') -bar.DVI(target = 'bar', source = 'bar.latex') -""" % python) - - latex = r""" -\documentclass{letter} -\begin{document} -This is the %s LaTeX file. -\end{document} -""" - - test.write('foo.ltx', latex % 'foo.ltx') - - test.write('bar.latex', latex % 'bar.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 = 'bar.dvi', stderr = None) - - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") - - test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) - -test.pass_test() diff --git a/test/LATEXFLAGS.py b/test/LATEXFLAGS.py deleted file mode 100644 index badf85e..0000000 --- a/test/LATEXFLAGS.py +++ /dev/null @@ -1,123 +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('mylatex.py', r""" -import getopt -import os -import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 'tx', []) -opt_string = '' -for opt, arg in cmd_opts: - opt_string = opt_string + ' ' + opt -base_name = os.path.splitext(args[0])[0] -infile = open(args[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') -out_file.write(opt_string + "\n") -for l in infile.readlines(): - if l[0] != '\\': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(LATEX = r'%s mylatex.py', LATEXFLAGS = '-x', tools=['latex']) -env.DVI(target = 'test1.dvi', source = 'test1.ltx') -env.Copy(LATEXFLAGS = '-t').DVI(target = 'test2.dvi', source = 'test2.latex') -""" % python) - -test.write('test1.ltx', r"""This is a .ltx test. -\end -""") - -test.write('test2.latex', r"""This is a .latex test. -\end -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(test.read('test1.dvi') != " -x\nThis is a .ltx test.\n") - -test.fail_test(test.read('test2.dvi') != " -t\nThis is a .latex test.\n") - - - -latex = test.where_is('latex') - -if latex: - - 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', """ -import os -ENV = { 'PATH' : os.environ['PATH'] } -foo = Environment(ENV = ENV, LATEXFLAGS = '--output-comment Commentary') -latex = foo.Dictionary('LATEX') -bar = Environment(ENV = ENV, LATEX = r'%s wrapper.py ' + latex) -foo.DVI(target = 'foo.dvi', source = 'foo.ltx') -bar.DVI(target = 'bar', source = 'bar.latex') -""" % python) - - latex = r""" -\documentclass{letter} -\begin{document} -This is the %s LaTeX file. -\end{document} -""" - - test.write('foo.ltx', latex % 'foo.ltx') - - test.write('bar.latex', latex % 'bar.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 = 'bar.dvi', stderr = None) - - test.fail_test(test.read('wrapper.out') != "wrapper.py\n") - - test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) - -test.pass_test() diff --git a/test/PDFLATEX.py b/test/PDFLATEX.py deleted file mode 100644 index 4c6f84d..0000000 --- a/test/PDFLATEX.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('mypdflatex.py', r""" -import sys -import os -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.pdf', 'wb') -for l in infile.readlines(): - if l[0] != '\\': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(PDFLATEX = r'%s mypdflatex.py', tools=['pdflatex']) -env.PDF(target = 'test1.pdf', source = 'test1.ltx') -env.PDF(target = 'test2.pdf', source = 'test2.latex') -""" % python) - -test.write('test1.ltx', r"""This is a .ltx test. -\end -""") - -test.write('test2.latex', r"""This is a .latex test. -\end -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(not os.path.exists(test.workpath('test1.pdf'))) - -test.fail_test(not os.path.exists(test.workpath('test2.pdf'))) - - - -pdflatex = test.where_is('pdflatex') - -if pdflatex: - - 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', """ -import os -ENV = { 'PATH' : os.environ['PATH'] } -foo = Environment(ENV = ENV) -pdflatex = foo.Dictionary('PDFLATEX') -bar = Environment(ENV = ENV, PDFLATEX = r'%s wrapper.py ' + pdflatex) -foo.PDF(target = 'foo.pdf', source = 'foo.ltx') -bar.PDF(target = 'bar', source = 'bar.latex') -""" % python) - - latex = r""" -\documentclass{letter} -\begin{document} -This is the %s LaTeX file. -\end{document} -""" - - test.write('foo.ltx', latex % 'foo.ltx') - - test.write('bar.latex', latex % 'bar.latex') - - 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') != "wrapper.py\n") - - test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) - -test.pass_test() diff --git a/test/PDFLATEXFLAGS.py b/test/PDFLATEXFLAGS.py deleted file mode 100644 index 880d6d0..0000000 --- a/test/PDFLATEXFLAGS.py +++ /dev/null @@ -1,123 +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('mypdflatex.py', r""" -import getopt -import os -import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 'tx', []) -opt_string = '' -for opt, arg in cmd_opts: - opt_string = opt_string + ' ' + opt -base_name = os.path.splitext(args[0])[0] -infile = open(args[0], 'rb') -out_file = open(base_name+'.pdf', 'wb') -out_file.write(opt_string + "\n") -for l in infile.readlines(): - if l[0] != '\\': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(PDFLATEX = r'%s mypdflatex.py', PDFLATEXFLAGS = '-x', tools=['pdflatex']) -env.PDF(target = 'test1.pdf', source = 'test1.ltx') -env.Copy(PDFLATEXFLAGS = '-t').PDF(target = 'test2.pdf', source = 'test2.latex') -""" % python) - -test.write('test1.ltx', r"""This is a .ltx test. -\end -""") - -test.write('test2.latex', r"""This is a .latex test. -\end -""") - -test.run(arguments = '.', stderr = None) - -test.fail_test(not os.path.exists(test.workpath('test1.pdf'))) - -test.fail_test(not os.path.exists(test.workpath('test2.pdf'))) - - - -pdflatex = test.where_is('pdflatex') - -if pdflatex: - - 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', """ -import os -ENV = { 'PATH' : os.environ['PATH'] } -foo = Environment(ENV = ENV, PDFLATEXFLAGS = '--output-comment Commentary') -pdflatex = foo.Dictionary('PDFLATEX') -bar = Environment(ENV = ENV, PDFLATEX = r'%s wrapper.py ' + pdflatex) -foo.PDF(target = 'foo.pdf', source = 'foo.ltx') -bar.PDF(target = 'bar', source = 'bar.latex') -""" % python) - - latex = r""" -\documentclass{letter} -\begin{document} -This is the %s LaTeX file. -\end{document} -""" - - test.write('foo.ltx', latex % 'foo.ltx') - - test.write('bar.latex', latex % 'bar.latex') - - 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') != "wrapper.py\n") - - test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) - -test.pass_test() diff --git a/test/PDFTEX.py b/test/PDFTEX.py deleted file mode 100644 index 2015c33..0000000 --- a/test/PDFTEX.py +++ /dev/null @@ -1,108 +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('mypdftex.py', r""" -import sys -import os -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') -out_file = open(base_name+'.pdf', 'wb') -for l in infile.readlines(): - if l[0] != '\\': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(PDFTEX = r'%s mypdftex.py', tools=['pdftex']) -env.PDF(target = 'test.pdf', source = 'test.tex') -""" % python) - -test.write('test.tex', r"""This is a test. -\end -""") - -test.run(arguments = 'test.pdf', stderr = None) - -test.fail_test(not os.path.exists(test.workpath('test.pdf'))) - - - -pdftex = test.where_is('pdftex') - -if pdftex: - - 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', """ -import os -ENV = { 'PATH' : os.environ['PATH'] } -foo = Environment(ENV = ENV) -pdftex = foo.Dictionary('PDFTEX') -bar = Environment(ENV = ENV, PDFTEX = r'%s wrapper.py ' + pdftex) -foo.PDF(target = 'foo.pdf', source = 'foo.tex') -bar.PDF(target = 'bar', source = 'bar.tex') -""" % python) - - tex = r""" -This is the %s TeX file. -\end -""" - - test.write('foo.tex', tex % 'foo.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 = 'bar.pdf', stderr = None) - - test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) - - test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) - -test.pass_test() diff --git a/test/PDFTEXFLAGS.py b/test/PDFTEXFLAGS.py deleted file mode 100644 index fb1fbf0..0000000 --- a/test/PDFTEXFLAGS.py +++ /dev/null @@ -1,114 +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('mypdftex.py', r""" -import getopt -import os -import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 'tx', []) -opt_string = '' -for opt, arg in cmd_opts: - opt_string = opt_string + ' ' + opt -base_name = os.path.splitext(args[0])[0] -infile = open(args[0], 'rb') -out_file = open(base_name+'.pdf', 'wb') -out_file.write(opt_string + "\n") -for l in infile.readlines(): - if l[0] != '\\': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(PDFTEX = r'%s mypdftex.py', PDFTEXFLAGS = '-x', tools=['pdftex']) -env.PDF(target = 'test.pdf', source = 'test.tex') -""" % python) - -test.write('test.tex', r"""This is a test. -\end -""") - -test.run(arguments = 'test.pdf', stderr = None) - -test.fail_test(not os.path.exists(test.workpath('test.pdf'))) - - - -pdftex = test.where_is('pdftex') - -if pdftex: - - 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', """ -import os -ENV = { 'PATH' : os.environ['PATH'] } -foo = Environment(ENV = ENV, PDFTEXFLAGS = '--output-comment Commentary') -pdftex = foo.Dictionary('PDFTEX') -bar = Environment(ENV = ENV, PDFTEX = r'%s wrapper.py ' + pdftex) -foo.PDF(target = 'foo.pdf', source = 'foo.tex') -bar.PDF(target = 'bar', source = 'bar.tex') -""" % python) - - tex = r""" -This is the %s TeX file. -\end -""" - - test.write('foo.tex', tex % 'foo.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 = 'bar.pdf', stderr = None) - - test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) - - test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) - -test.pass_test() diff --git a/test/TEX.py b/test/TEX.py deleted file mode 100644 index a2e69fa..0000000 --- a/test/TEX.py +++ /dev/null @@ -1,164 +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 sys -import os -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[0] != '\\': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(TEX = r'%s mytex.py', tools=['tex']) -env.DVI(target = 'test.dvi', source = 'test.tex') -""" % python) - -test.write('test.tex', r"""This is a test. -\end -""") - -test.run(arguments = 'test.dvi', stderr = None) - -test.fail_test(test.read('test.dvi') != "This is a test.\n") - - - -tex = test.where_is('tex') - -if tex: - - 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', """ -import os -ENV = { 'PATH' : os.environ['PATH'] } -foo = Environment(ENV = ENV) -tex = foo.Dictionary('TEX') -bar = Environment(ENV = ENV, TEX = r'%s wrapper.py ' + tex) -foo.DVI(target = 'foo.dvi', source = 'foo.tex') -foo.DVI(target = 'foo-latex.dvi', source = 'foo-latex.tex') -bar.DVI(target = 'bar', source = 'bar.tex') -bar.DVI(target = 'bar-latex', source = 'bar-latex.tex') -foo.DVI('rerun.tex') -foo.DVI('bibtex-test.tex') -""" % python) - - tex = r""" -This is the %s TeX file. -\end -""" - - latex = r""" -\document%s{letter} -\begin{document} -This is the %s LaTeX file. -\end{document} -""" - - rerun = r""" -\documentclass{article} - -\begin{document} - -\LaTeX\ will need to run twice on this document to get a reference to section -\ref{sec}. - -\section{Next section} -\label{sec} - -\end{document} -""" - - bibtex = r""" -\documentclass{article} - -\begin{document} - -Run \texttt{latex}, then \texttt{bibtex}, then \texttt{latex} twice again \cite{lamport}. - -\bibliographystyle{plain} -\bibliography{test} - -\end{document} -""" - - bib = r""" -@Book{lamport, - author = {L. Lamport}, - title = {{\LaTeX: A} Document Preparation System}, - publisher = {Addison-Wesley}, - year = 1994 -} -""" - - test.write('foo.tex', tex % 'foo.tex') - test.write('bar.tex', tex % 'bar.tex') - test.write('foo-latex.tex', latex % ('style', 'foo-latex.tex')) - test.write('bar-latex.tex', latex % ('class', 'bar-latex.tex')) - test.write('rerun.tex', rerun) - test.write('bibtex-test.tex', bibtex) - test.write('test.bib', bib) - - test.run(arguments = 'foo.dvi foo-latex.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.fail_test(not os.path.exists(test.workpath('foo-latex.dvi'))) - - test.run(arguments = 'bar.dvi bar-latex.dvi', stderr = None) - test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) - test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) - test.fail_test(not os.path.exists(test.workpath('bar-latex.dvi'))) - - test.run(stderr = None) - output_lines = string.split(test.stdout(), '\n') - reruns = filter(lambda x: x == 'latex rerun.tex', output_lines) - test.fail_test(len(reruns) != 2) - bibtex = filter(lambda x: x == 'bibtex bibtex-test', output_lines) - test.fail_test(len(bibtex) != 1) - -test.pass_test() diff --git a/test/TEX/LATEX.py b/test/TEX/LATEX.py new file mode 100644 index 0000000..4ed080f --- /dev/null +++ b/test/TEX/LATEX.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('mylatex.py', r""" +import sys +import os +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[0] != '\\': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LATEX = r'%s mylatex.py', tools=['latex']) +env.DVI(target = 'test1.dvi', source = 'test1.ltx') +env.DVI(target = 'test2.dvi', source = 'test2.latex') +""" % python) + +test.write('test1.ltx', r"""This is a .ltx test. +\end +""") + +test.write('test2.latex', r"""This is a .latex test. +\end +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(test.read('test1.dvi') != "This is a .ltx test.\n") + +test.fail_test(test.read('test2.dvi') != "This is a .latex test.\n") + + + +latex = test.where_is('latex') + +if latex: + + 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', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV) +latex = foo.Dictionary('LATEX') +bar = Environment(ENV = ENV, LATEX = r'%s wrapper.py ' + latex) +foo.DVI(target = 'foo.dvi', source = 'foo.ltx') +bar.DVI(target = 'bar', source = 'bar.latex') +""" % python) + + latex = r""" +\documentclass{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + test.write('foo.ltx', latex % 'foo.ltx') + + test.write('bar.latex', latex % 'bar.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 = 'bar.dvi', stderr = None) + + test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + + test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) + +test.pass_test() diff --git a/test/TEX/LATEXCOM.py b/test/TEX/LATEXCOM.py new file mode 100644 index 0000000..803d26d --- /dev/null +++ b/test/TEX/LATEXCOM.py @@ -0,0 +1,69 @@ +#!/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 $LATEXCOM construction variable. +""" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + + + +test.write('mylatex.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in filter(lambda l: l != '/*latex*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['latex'], + LATEXCOM = r'%(python)s mylatex.py $TARGET $SOURCE') +env.DVI('test1', 'test1.latex') +""" % locals()) + +test.write('test1.latex', """\ +test1.latex +/*latex*/ +""") + +test.run() + +test.must_match('test1.dvi', "test1.latex\n") + + + +test.pass_test() diff --git a/test/TEX/LATEXCOMSTR.py b/test/TEX/LATEXCOMSTR.py new file mode 100644 index 0000000..5e31301 --- /dev/null +++ b/test/TEX/LATEXCOMSTR.py @@ -0,0 +1,73 @@ +#!/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 $LATEXCOMSTR construction variable allows you to configure +the C compilation output. +""" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + + + +test.write('mylatex.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in filter(lambda l: l != '/*latex*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['latex'], + LATEXCOM = r'%(python)s mylatex.py $TARGET $SOURCE', + LATEXCOMSTR = 'Building $TARGET from $SOURCE') +env.DVI('test1', 'test1.latex') +""" % locals()) + +test.write('test1.latex', """\ +test1.latex +/*latex*/ +""") + +test.run(stdout = test.wrap_stdout("""\ +Building test1.dvi from test1.latex +""" % locals())) + +test.must_match('test1.dvi', "test1.latex\n") + + + +test.pass_test() diff --git a/test/TEX/LATEXFLAGS.py b/test/TEX/LATEXFLAGS.py new file mode 100644 index 0000000..badf85e --- /dev/null +++ b/test/TEX/LATEXFLAGS.py @@ -0,0 +1,123 @@ +#!/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('mylatex.py', r""" +import getopt +import os +import sys +cmd_opts, args = getopt.getopt(sys.argv[1:], 'tx', []) +opt_string = '' +for opt, arg in cmd_opts: + opt_string = opt_string + ' ' + opt +base_name = os.path.splitext(args[0])[0] +infile = open(args[0], 'rb') +out_file = open(base_name+'.dvi', 'wb') +out_file.write(opt_string + "\n") +for l in infile.readlines(): + if l[0] != '\\': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LATEX = r'%s mylatex.py', LATEXFLAGS = '-x', tools=['latex']) +env.DVI(target = 'test1.dvi', source = 'test1.ltx') +env.Copy(LATEXFLAGS = '-t').DVI(target = 'test2.dvi', source = 'test2.latex') +""" % python) + +test.write('test1.ltx', r"""This is a .ltx test. +\end +""") + +test.write('test2.latex', r"""This is a .latex test. +\end +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(test.read('test1.dvi') != " -x\nThis is a .ltx test.\n") + +test.fail_test(test.read('test2.dvi') != " -t\nThis is a .latex test.\n") + + + +latex = test.where_is('latex') + +if latex: + + 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', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV, LATEXFLAGS = '--output-comment Commentary') +latex = foo.Dictionary('LATEX') +bar = Environment(ENV = ENV, LATEX = r'%s wrapper.py ' + latex) +foo.DVI(target = 'foo.dvi', source = 'foo.ltx') +bar.DVI(target = 'bar', source = 'bar.latex') +""" % python) + + latex = r""" +\documentclass{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + test.write('foo.ltx', latex % 'foo.ltx') + + test.write('bar.latex', latex % 'bar.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 = 'bar.dvi', stderr = None) + + test.fail_test(test.read('wrapper.out') != "wrapper.py\n") + + test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) + +test.pass_test() diff --git a/test/TEX/PDFLATEX.py b/test/TEX/PDFLATEX.py new file mode 100644 index 0000000..4c6f84d --- /dev/null +++ b/test/TEX/PDFLATEX.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('mypdflatex.py', r""" +import sys +import os +base_name = os.path.splitext(sys.argv[1])[0] +infile = open(sys.argv[1], 'rb') +out_file = open(base_name+'.pdf', 'wb') +for l in infile.readlines(): + if l[0] != '\\': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(PDFLATEX = r'%s mypdflatex.py', tools=['pdflatex']) +env.PDF(target = 'test1.pdf', source = 'test1.ltx') +env.PDF(target = 'test2.pdf', source = 'test2.latex') +""" % python) + +test.write('test1.ltx', r"""This is a .ltx test. +\end +""") + +test.write('test2.latex', r"""This is a .latex test. +\end +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(not os.path.exists(test.workpath('test1.pdf'))) + +test.fail_test(not os.path.exists(test.workpath('test2.pdf'))) + + + +pdflatex = test.where_is('pdflatex') + +if pdflatex: + + 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', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV) +pdflatex = foo.Dictionary('PDFLATEX') +bar = Environment(ENV = ENV, PDFLATEX = r'%s wrapper.py ' + pdflatex) +foo.PDF(target = 'foo.pdf', source = 'foo.ltx') +bar.PDF(target = 'bar', source = 'bar.latex') +""" % python) + + latex = r""" +\documentclass{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + test.write('foo.ltx', latex % 'foo.ltx') + + test.write('bar.latex', latex % 'bar.latex') + + 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') != "wrapper.py\n") + + test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) + +test.pass_test() diff --git a/test/TEX/PDFLATEXCOM.py b/test/TEX/PDFLATEXCOM.py new file mode 100644 index 0000000..f46ed37 --- /dev/null +++ b/test/TEX/PDFLATEXCOM.py @@ -0,0 +1,69 @@ +#!/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 $PDFLATEXCOM construction variable. +""" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + + + +test.write('mypdflatex.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in filter(lambda l: l != '/*latex*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['pdflatex'], + PDFLATEXCOM = r'%(python)s mypdflatex.py $TARGET $SOURCE') +env.PDF('test1', 'test1.latex') +""" % locals()) + +test.write('test1.latex', """\ +test1.latex +/*latex*/ +""") + +test.run() + +test.must_match('test1.pdf', "test1.latex\n") + + + +test.pass_test() diff --git a/test/TEX/PDFLATEXCOMSTR.py b/test/TEX/PDFLATEXCOMSTR.py new file mode 100644 index 0000000..94cf121 --- /dev/null +++ b/test/TEX/PDFLATEXCOMSTR.py @@ -0,0 +1,74 @@ + +#!/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 $PDFLATEXCOMSTR construction variable allows you to configure +the C compilation output. +""" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + + + +test.write('mypdflatex.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in filter(lambda l: l != '/*latex*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['pdflatex'], + PDFLATEXCOM = r'%(python)s mypdflatex.py $TARGET $SOURCE', + PDFLATEXCOMSTR = 'Building $TARGET from $SOURCE') +env.PDF('test1', 'test1.latex') +""" % locals()) + +test.write('test1.latex', """\ +test1.latex +/*latex*/ +""") + +test.run(stdout = test.wrap_stdout("""\ +Building test1.pdf from test1.latex +""" % locals())) + +test.must_match('test1.pdf', "test1.latex\n") + + + +test.pass_test() diff --git a/test/TEX/PDFLATEXFLAGS.py b/test/TEX/PDFLATEXFLAGS.py new file mode 100644 index 0000000..880d6d0 --- /dev/null +++ b/test/TEX/PDFLATEXFLAGS.py @@ -0,0 +1,123 @@ +#!/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('mypdflatex.py', r""" +import getopt +import os +import sys +cmd_opts, args = getopt.getopt(sys.argv[1:], 'tx', []) +opt_string = '' +for opt, arg in cmd_opts: + opt_string = opt_string + ' ' + opt +base_name = os.path.splitext(args[0])[0] +infile = open(args[0], 'rb') +out_file = open(base_name+'.pdf', 'wb') +out_file.write(opt_string + "\n") +for l in infile.readlines(): + if l[0] != '\\': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(PDFLATEX = r'%s mypdflatex.py', PDFLATEXFLAGS = '-x', tools=['pdflatex']) +env.PDF(target = 'test1.pdf', source = 'test1.ltx') +env.Copy(PDFLATEXFLAGS = '-t').PDF(target = 'test2.pdf', source = 'test2.latex') +""" % python) + +test.write('test1.ltx', r"""This is a .ltx test. +\end +""") + +test.write('test2.latex', r"""This is a .latex test. +\end +""") + +test.run(arguments = '.', stderr = None) + +test.fail_test(not os.path.exists(test.workpath('test1.pdf'))) + +test.fail_test(not os.path.exists(test.workpath('test2.pdf'))) + + + +pdflatex = test.where_is('pdflatex') + +if pdflatex: + + 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', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV, PDFLATEXFLAGS = '--output-comment Commentary') +pdflatex = foo.Dictionary('PDFLATEX') +bar = Environment(ENV = ENV, PDFLATEX = r'%s wrapper.py ' + pdflatex) +foo.PDF(target = 'foo.pdf', source = 'foo.ltx') +bar.PDF(target = 'bar', source = 'bar.latex') +""" % python) + + latex = r""" +\documentclass{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + test.write('foo.ltx', latex % 'foo.ltx') + + test.write('bar.latex', latex % 'bar.latex') + + 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') != "wrapper.py\n") + + test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) + +test.pass_test() diff --git a/test/TEX/PDFTEX.py b/test/TEX/PDFTEX.py new file mode 100644 index 0000000..2015c33 --- /dev/null +++ b/test/TEX/PDFTEX.py @@ -0,0 +1,108 @@ +#!/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('mypdftex.py', r""" +import sys +import os +base_name = os.path.splitext(sys.argv[1])[0] +infile = open(sys.argv[1], 'rb') +out_file = open(base_name+'.pdf', 'wb') +for l in infile.readlines(): + if l[0] != '\\': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(PDFTEX = r'%s mypdftex.py', tools=['pdftex']) +env.PDF(target = 'test.pdf', source = 'test.tex') +""" % python) + +test.write('test.tex', r"""This is a test. +\end +""") + +test.run(arguments = 'test.pdf', stderr = None) + +test.fail_test(not os.path.exists(test.workpath('test.pdf'))) + + + +pdftex = test.where_is('pdftex') + +if pdftex: + + 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', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV) +pdftex = foo.Dictionary('PDFTEX') +bar = Environment(ENV = ENV, PDFTEX = r'%s wrapper.py ' + pdftex) +foo.PDF(target = 'foo.pdf', source = 'foo.tex') +bar.PDF(target = 'bar', source = 'bar.tex') +""" % python) + + tex = r""" +This is the %s TeX file. +\end +""" + + test.write('foo.tex', tex % 'foo.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 = 'bar.pdf', stderr = None) + + test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) + + test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) + +test.pass_test() diff --git a/test/TEX/PDFTEXCOM.py b/test/TEX/PDFTEXCOM.py new file mode 100644 index 0000000..2a7f06b --- /dev/null +++ b/test/TEX/PDFTEXCOM.py @@ -0,0 +1,69 @@ +#!/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 $PDFTEXCOM construction variable. +""" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + + + +test.write('mypdftex.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in filter(lambda l: l != '/*tex*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['pdftex'], + PDFTEXCOM = r'%(python)s mypdftex.py $TARGET $SOURCE') +env.PDF('test1') +""" % locals()) + +test.write('test1.tex', """\ +test1.tex +/*tex*/ +""") + +test.run() + +test.must_match('test1.pdf', "test1.tex\n") + + + +test.pass_test() diff --git a/test/TEX/PDFTEXCOMSTR.py b/test/TEX/PDFTEXCOMSTR.py new file mode 100644 index 0000000..dbb7b39 --- /dev/null +++ b/test/TEX/PDFTEXCOMSTR.py @@ -0,0 +1,74 @@ + +#!/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 $PDFTEXCOMSTR construction variable allows you to configure +the C compilation output. +""" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + + + +test.write('mypdftex.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in filter(lambda l: l != '/*tex*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['pdftex'], + PDFTEXCOM = r'%(python)s mypdftex.py $TARGET $SOURCE', + PDFTEXCOMSTR = 'Building $TARGET from $SOURCE') +env.PDF('test1') +""" % locals()) + +test.write('test1.tex', """\ +test1.tex +/*tex*/ +""") + +test.run(stdout = test.wrap_stdout("""\ +Building test1.pdf from test1.tex +""" % locals())) + +test.must_match('test1.pdf', "test1.tex\n") + + + +test.pass_test() diff --git a/test/TEX/PDFTEXFLAGS.py b/test/TEX/PDFTEXFLAGS.py new file mode 100644 index 0000000..fb1fbf0 --- /dev/null +++ b/test/TEX/PDFTEXFLAGS.py @@ -0,0 +1,114 @@ +#!/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('mypdftex.py', r""" +import getopt +import os +import sys +cmd_opts, args = getopt.getopt(sys.argv[1:], 'tx', []) +opt_string = '' +for opt, arg in cmd_opts: + opt_string = opt_string + ' ' + opt +base_name = os.path.splitext(args[0])[0] +infile = open(args[0], 'rb') +out_file = open(base_name+'.pdf', 'wb') +out_file.write(opt_string + "\n") +for l in infile.readlines(): + if l[0] != '\\': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(PDFTEX = r'%s mypdftex.py', PDFTEXFLAGS = '-x', tools=['pdftex']) +env.PDF(target = 'test.pdf', source = 'test.tex') +""" % python) + +test.write('test.tex', r"""This is a test. +\end +""") + +test.run(arguments = 'test.pdf', stderr = None) + +test.fail_test(not os.path.exists(test.workpath('test.pdf'))) + + + +pdftex = test.where_is('pdftex') + +if pdftex: + + 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', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV, PDFTEXFLAGS = '--output-comment Commentary') +pdftex = foo.Dictionary('PDFTEX') +bar = Environment(ENV = ENV, PDFTEX = r'%s wrapper.py ' + pdftex) +foo.PDF(target = 'foo.pdf', source = 'foo.tex') +bar.PDF(target = 'bar', source = 'bar.tex') +""" % python) + + tex = r""" +This is the %s TeX file. +\end +""" + + test.write('foo.tex', tex % 'foo.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 = 'bar.pdf', stderr = None) + + test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) + + test.fail_test(not os.path.exists(test.workpath('bar.pdf'))) + +test.pass_test() diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py new file mode 100644 index 0000000..a2e69fa --- /dev/null +++ b/test/TEX/TEX.py @@ -0,0 +1,164 @@ +#!/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 sys +import os +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[0] != '\\': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TEX = r'%s mytex.py', tools=['tex']) +env.DVI(target = 'test.dvi', source = 'test.tex') +""" % python) + +test.write('test.tex', r"""This is a test. +\end +""") + +test.run(arguments = 'test.dvi', stderr = None) + +test.fail_test(test.read('test.dvi') != "This is a test.\n") + + + +tex = test.where_is('tex') + +if tex: + + 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', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV) +tex = foo.Dictionary('TEX') +bar = Environment(ENV = ENV, TEX = r'%s wrapper.py ' + tex) +foo.DVI(target = 'foo.dvi', source = 'foo.tex') +foo.DVI(target = 'foo-latex.dvi', source = 'foo-latex.tex') +bar.DVI(target = 'bar', source = 'bar.tex') +bar.DVI(target = 'bar-latex', source = 'bar-latex.tex') +foo.DVI('rerun.tex') +foo.DVI('bibtex-test.tex') +""" % python) + + tex = r""" +This is the %s TeX file. +\end +""" + + latex = r""" +\document%s{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + rerun = r""" +\documentclass{article} + +\begin{document} + +\LaTeX\ will need to run twice on this document to get a reference to section +\ref{sec}. + +\section{Next section} +\label{sec} + +\end{document} +""" + + bibtex = r""" +\documentclass{article} + +\begin{document} + +Run \texttt{latex}, then \texttt{bibtex}, then \texttt{latex} twice again \cite{lamport}. + +\bibliographystyle{plain} +\bibliography{test} + +\end{document} +""" + + bib = r""" +@Book{lamport, + author = {L. Lamport}, + title = {{\LaTeX: A} Document Preparation System}, + publisher = {Addison-Wesley}, + year = 1994 +} +""" + + test.write('foo.tex', tex % 'foo.tex') + test.write('bar.tex', tex % 'bar.tex') + test.write('foo-latex.tex', latex % ('style', 'foo-latex.tex')) + test.write('bar-latex.tex', latex % ('class', 'bar-latex.tex')) + test.write('rerun.tex', rerun) + test.write('bibtex-test.tex', bibtex) + test.write('test.bib', bib) + + test.run(arguments = 'foo.dvi foo-latex.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.fail_test(not os.path.exists(test.workpath('foo-latex.dvi'))) + + test.run(arguments = 'bar.dvi bar-latex.dvi', stderr = None) + test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) + test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) + test.fail_test(not os.path.exists(test.workpath('bar-latex.dvi'))) + + test.run(stderr = None) + output_lines = string.split(test.stdout(), '\n') + reruns = filter(lambda x: x == 'latex rerun.tex', output_lines) + test.fail_test(len(reruns) != 2) + bibtex = filter(lambda x: x == 'bibtex bibtex-test', output_lines) + test.fail_test(len(bibtex) != 1) + +test.pass_test() diff --git a/test/TEX/TEXCOM.py b/test/TEX/TEXCOM.py new file mode 100644 index 0000000..4957427 --- /dev/null +++ b/test/TEX/TEXCOM.py @@ -0,0 +1,69 @@ +#!/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 $TEXCOM construction variable. +""" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + + + +test.write('mytex.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in filter(lambda l: l != '/*tex*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['tex'], + TEXCOM = r'%(python)s mytex.py $TARGET $SOURCE') +env.DVI('test1') +""" % locals()) + +test.write('test1.tex', """\ +test1.tex +/*tex*/ +""") + +test.run() + +test.must_match('test1.dvi', "test1.tex\n") + + + +test.pass_test() diff --git a/test/TEX/TEXCOMSTR.py b/test/TEX/TEXCOMSTR.py new file mode 100644 index 0000000..81e7123 --- /dev/null +++ b/test/TEX/TEXCOMSTR.py @@ -0,0 +1,73 @@ +#!/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 $TEXCOMSTR construction variable allows you to configure +the C compilation output. +""" + +import os +import string +import sys +import TestSCons + +python = TestSCons.python +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + + + +test.write('mytex.py', r""" +import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in filter(lambda l: l != '/*tex*/\n', infile.readlines()): + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TOOLS = ['tex'], + TEXCOM = r'%(python)s mytex.py $TARGET $SOURCE', + TEXCOMSTR = 'Building $TARGET from $SOURCE') +env.DVI('test1') +""" % locals()) + +test.write('test1.tex', """\ +test1.tex +/*tex*/ +""") + +test.run(stdout = test.wrap_stdout("""\ +Building test1.dvi from test1.tex +""" % locals())) + +test.must_match('test1.dvi', "test1.tex\n") + + + +test.pass_test() diff --git a/test/TEX/TEXFLAGS.py b/test/TEX/TEXFLAGS.py new file mode 100644 index 0000000..fa5edb6 --- /dev/null +++ b/test/TEX/TEXFLAGS.py @@ -0,0 +1,114 @@ +#!/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 getopt +import os +import sys +cmd_opts, args = getopt.getopt(sys.argv[1:], 'tx', []) +opt_string = '' +for opt, arg in cmd_opts: + opt_string = opt_string + ' ' + opt +base_name = os.path.splitext(args[0])[0] +infile = open(args[0], 'rb') +out_file = open(base_name+'.dvi', 'wb') +out_file.write(opt_string + "\n") +for l in infile.readlines(): + if l[0] != '\\': + out_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TEX = r'%s mytex.py', TEXFLAGS = '-x', tools=['tex']) +env.DVI(target = 'test.dvi', source = 'test.tex') +""" % python) + +test.write('test.tex', r"""This is a test. +\end +""") + +test.run(arguments = 'test.dvi', stderr = None) + +test.fail_test(test.read('test.dvi') != " -x\nThis is a test.\n") + + + +tex = test.where_is('tex') + +if tex: + + 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', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV, TEXFLAGS = '--output-comment Commentary') +tex = foo.Dictionary('TEX') +bar = Environment(ENV = ENV, TEX = r'%s wrapper.py ' + tex) +foo.DVI(target = 'foo.dvi', source = 'foo.tex') +bar.DVI(target = 'bar', source = 'bar.tex') +""" % python) + + tex = r""" +This is the %s TeX file. +\end +""" + + test.write('foo.tex', tex % 'foo.tex') + + test.write('bar.tex', tex % 'bar.tex') + + 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 = 'bar.dvi', stderr = None) + + test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) + + test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) + +test.pass_test() diff --git a/test/TEXFLAGS.py b/test/TEXFLAGS.py deleted file mode 100644 index fa5edb6..0000000 --- a/test/TEXFLAGS.py +++ /dev/null @@ -1,114 +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 getopt -import os -import sys -cmd_opts, args = getopt.getopt(sys.argv[1:], 'tx', []) -opt_string = '' -for opt, arg in cmd_opts: - opt_string = opt_string + ' ' + opt -base_name = os.path.splitext(args[0])[0] -infile = open(args[0], 'rb') -out_file = open(base_name+'.dvi', 'wb') -out_file.write(opt_string + "\n") -for l in infile.readlines(): - if l[0] != '\\': - out_file.write(l) -sys.exit(0) -""") - -test.write('SConstruct', """ -env = Environment(TEX = r'%s mytex.py', TEXFLAGS = '-x', tools=['tex']) -env.DVI(target = 'test.dvi', source = 'test.tex') -""" % python) - -test.write('test.tex', r"""This is a test. -\end -""") - -test.run(arguments = 'test.dvi', stderr = None) - -test.fail_test(test.read('test.dvi') != " -x\nThis is a test.\n") - - - -tex = test.where_is('tex') - -if tex: - - 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', """ -import os -ENV = { 'PATH' : os.environ['PATH'] } -foo = Environment(ENV = ENV, TEXFLAGS = '--output-comment Commentary') -tex = foo.Dictionary('TEX') -bar = Environment(ENV = ENV, TEX = r'%s wrapper.py ' + tex) -foo.DVI(target = 'foo.dvi', source = 'foo.tex') -bar.DVI(target = 'bar', source = 'bar.tex') -""" % python) - - tex = r""" -This is the %s TeX file. -\end -""" - - test.write('foo.tex', tex % 'foo.tex') - - test.write('bar.tex', tex % 'bar.tex') - - 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 = 'bar.dvi', stderr = None) - - test.fail_test(not os.path.exists(test.workpath('wrapper.out'))) - - test.fail_test(not os.path.exists(test.workpath('bar.dvi'))) - -test.pass_test() -- cgit v0.12