diff options
author | Steven Knight <knight@baldmt.com> | 2004-12-03 04:09:35 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-12-03 04:09:35 (GMT) |
commit | abcf29987d2baa25d51716f888015aaa9d104d36 (patch) | |
tree | 55b5ddbfe2baca260bb10c209041d2235d1f9565 /test/TEX | |
parent | 2fa621343311180c159ee09262cefe0ee0ad2d83 (diff) | |
download | SCons-abcf29987d2baa25d51716f888015aaa9d104d36.zip SCons-abcf29987d2baa25d51716f888015aaa9d104d36.tar.gz SCons-abcf29987d2baa25d51716f888015aaa9d104d36.tar.bz2 |
More command-line customizability: , , , , .
Diffstat (limited to 'test/TEX')
-rw-r--r-- | test/TEX/LATEX.py | 117 | ||||
-rw-r--r-- | test/TEX/LATEXCOM.py | 69 | ||||
-rw-r--r-- | test/TEX/LATEXCOMSTR.py | 73 | ||||
-rw-r--r-- | test/TEX/LATEXFLAGS.py | 123 | ||||
-rw-r--r-- | test/TEX/PDFLATEX.py | 117 | ||||
-rw-r--r-- | test/TEX/PDFLATEXCOM.py | 69 | ||||
-rw-r--r-- | test/TEX/PDFLATEXCOMSTR.py | 74 | ||||
-rw-r--r-- | test/TEX/PDFLATEXFLAGS.py | 123 | ||||
-rw-r--r-- | test/TEX/PDFTEX.py | 108 | ||||
-rw-r--r-- | test/TEX/PDFTEXCOM.py | 69 | ||||
-rw-r--r-- | test/TEX/PDFTEXCOMSTR.py | 74 | ||||
-rw-r--r-- | test/TEX/PDFTEXFLAGS.py | 114 | ||||
-rw-r--r-- | test/TEX/TEX.py | 164 | ||||
-rw-r--r-- | test/TEX/TEXCOM.py | 69 | ||||
-rw-r--r-- | test/TEX/TEXCOMSTR.py | 73 | ||||
-rw-r--r-- | test/TEX/TEXFLAGS.py | 114 |
16 files changed, 1550 insertions, 0 deletions
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() |