diff options
Diffstat (limited to 'test/TEX')
56 files changed, 7579 insertions, 0 deletions
diff --git a/test/TEX/LATEX.py b/test/TEX/LATEX.py new file mode 100644 index 000000000..03d3a0074 --- /dev/null +++ b/test/TEX/LATEX.py @@ -0,0 +1,205 @@ +#!/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__" + +""" +Validate that we can set the LATEX string to our own utility, that +the produced .dvi, .aux and .log files get removed by the -c option, +and that we can use this to wrap calls to the real latex utility. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + + + +test.write('mylatex.py', r""" +import sys +import os +import getopt +cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) +base_name = os.path.splitext(arg[0])[0] +infile = open(arg[0], 'rb') +dvi_file = open(base_name+'.dvi', 'wb') +aux_file = open(base_name+'.aux', 'wb') +log_file = open(base_name+'.log', 'wb') +for l in infile.readlines(): + if l[0] != '\\': + dvi_file.write(l) + aux_file.write(l) + log_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LATEX = r'%(_python_)s mylatex.py', tools=['latex']) +env.DVI(target = 'test1.dvi', source = 'test1.ltx') +env.DVI(target = 'test2.dvi', source = 'test2.latex') +""" % locals()) + +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 = '.') + +test.must_match('test1.dvi', "This is a .ltx test.\n") +test.must_match('test1.aux', "This is a .ltx test.\n") +test.must_match('test1.log', "This is a .ltx test.\n") + +test.must_match('test2.dvi', "This is a .latex test.\n") +test.must_match('test2.aux', "This is a .latex test.\n") +test.must_match('test2.log', "This is a .latex test.\n") + +test.run(arguments = '-c .') + +test.must_not_exist('test1.dvi') +test.must_not_exist('test1.aux') +test.must_not_exist('test1.log') + +test.must_not_exist('test2.dvi') +test.must_not_exist('test2.aux') +test.must_not_exist('test2.log') + + + +latex = test.where_is('latex') + +if latex: + + test.write("wrapper.py", """import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + test.write('SConstruct', """ +import os +ENV = { 'PATH' : os.environ['PATH'], + 'TEXINPUTS' : [ 'subdir', os.environ.get('TEXINPUTS', '') ] } +foo = Environment(ENV = ENV) +latex = foo.Dictionary('LATEX') +makeindex = foo.Dictionary('MAKEINDEX') +python_path = r'%(_python_)s' +bar = Environment(ENV = ENV, + LATEX = python_path + ' wrapper.py ' + latex, + MAKEINDEX = python_path + ' wrapper.py ' + makeindex) +foo.DVI(target = 'foo.dvi', source = 'foo.ltx') +bar.DVI(target = 'bar', source = 'bar.latex') + +bar.DVI(target = 'makeindex', source = 'makeindex.tex') +foo.DVI(target = 'latexi', source = 'latexi.tex') +""" % locals()) + + latex = r""" +\documentclass{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + makeindex = r""" +\documentclass{report} +\usepackage{makeidx} +\makeindex +\begin{document} +\index{info} +This is the %s LaTeX file. +\printindex{} +\end{document} +""" + + latex1 = r""" +\documentclass{report} +\usepackage{makeidx} +\input{latexinputfile} +\begin{document} +\index{info} +This is the %s LaTeX file. + +It has an Index and includes another file. +\include{latexincludefile} +\end{document} +""" + + latex2 = r""" +\makeindex +""" + + latex3 = r""" +\index{include} +This is the include file. mod %s +\printindex{} +""" + + test.write('foo.ltx', latex % 'foo.ltx') + + test.write('bar.latex', latex % 'bar.latex') + + test.write('makeindex.tex', makeindex % 'makeindex.tex') + test.write('makeindex.idx', '') + + test.subdir('subdir') + test.write('latexi.tex', latex1 % 'latexi.tex'); + test.write([ 'subdir', 'latexinputfile'], latex2) + test.write([ 'subdir', 'latexincludefile.tex'], latex3 % '1') + + test.run(arguments = 'foo.dvi', stderr = None) + test.must_not_exist('wrapper.out') + test.must_exist('foo.dvi') + + test.run(arguments = 'bar.dvi', stderr = None) + test.must_match('wrapper.out', "wrapper.py\n") + test.must_exist('bar.dvi') + + test.run(arguments = 'makeindex.dvi', stderr = None) + test.must_match('wrapper.out', "wrapper.py\n") + + test.run(arguments = 'latexi.dvi', stderr = None) + test.must_exist('latexi.dvi') + test.must_exist('latexi.ind') + + test.write([ 'subdir', 'latexincludefile.tex'], latex3 % '2') + test.not_up_to_date(arguments = 'latexi.dvi', stderr = None) + + test.run(arguments = '-c', stderr = None) + test.must_not_exist('latexi.ind') + test.must_not_exist('latexi.ilg') + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/LATEX2.py b/test/TEX/LATEX2.py new file mode 100644 index 000000000..566f164af --- /dev/null +++ b/test/TEX/LATEX2.py @@ -0,0 +1,125 @@ +#!/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__" + +""" +Validate that we can produce several .pdf at once from several sources. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + + +latex = test.where_is('latex') + +if latex: + + test.write('SConstruct', """ +import os +foo = Environment() +foo['TEXINPUTS'] = ['subdir',os.environ.get('TEXINPUTS', '')] +foo.PDF(source = ['foo.ltx','bar.latex','makeindex.tex','latexi.tex']) +""" % locals()) + + latex = r""" +\documentclass{letter} +\begin{document} +This is the %s LaTeX file. +\end{document} +""" + + makeindex = r""" +\documentclass{report} +\usepackage{makeidx} +\makeindex +\begin{document} +\index{info} +This is the %s LaTeX file. +\printindex{} +\end{document} +""" + + latex1 = r""" +\documentclass{report} +\usepackage{makeidx} +\input{latexinputfile} +\begin{document} +\index{info} +This is the %s LaTeX file. + +It has an Index and includes another file. +\include{latexincludefile} +\end{document} +""" + + latex2 = r""" +\makeindex +""" + + latex3 = r""" +\index{include} +This is the include file. mod %s +\printindex{} +""" + + test.write('foo.ltx', latex % 'foo.ltx') + + test.write('bar.latex', latex % 'bar.latex') + + test.write('makeindex.tex', makeindex % 'makeindex.tex') + test.write('makeindex.idx', '') + + test.subdir('subdir') + test.write('latexi.tex', latex1 % 'latexi.tex'); + test.write([ 'subdir', 'latexinputfile'], latex2) + test.write([ 'subdir', 'latexincludefile.tex'], latex3 % '1') + + test.run(stderr = None) + test.must_not_exist('wrapper.out') + test.must_exist('foo.pdf') + + test.must_exist('bar.pdf') + + test.must_exist('latexi.pdf') + test.must_exist('latexi.ind') + + test.write([ 'subdir', 'latexincludefile.tex'], latex3 % '2') + test.not_up_to_date(arguments = 'latexi.pdf', stderr = None) + + test.run(arguments = '-c', stderr = None) + test.must_not_exist('latexi.ind') + test.must_not_exist('latexi.ilg') + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/LATEXCOM.py b/test/TEX/LATEXCOM.py new file mode 100644 index 000000000..2c638645d --- /dev/null +++ b/test/TEX/LATEXCOM.py @@ -0,0 +1,72 @@ +#!/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 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 [l for l in infile.readlines() if l != '/*latex*/\n']: + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/LATEXCOMSTR.py b/test/TEX/LATEXCOMSTR.py new file mode 100644 index 000000000..4e1b93c25 --- /dev/null +++ b/test/TEX/LATEXCOMSTR.py @@ -0,0 +1,76 @@ +#!/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 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 [l for l in infile.readlines() if l != '/*latex*/\n']: + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/LATEXFLAGS.py b/test/TEX/LATEXFLAGS.py new file mode 100644 index 000000000..f693970be --- /dev/null +++ b/test/TEX/LATEXFLAGS.py @@ -0,0 +1,128 @@ +#!/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 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'%(_python_)s mylatex.py', + LATEXFLAGS = '-x', + tools=['latex']) +env.DVI(target = 'test1.dvi', source = 'test1.ltx') +env.Clone(LATEXFLAGS = '-t').DVI(target = 'test2.dvi', source = 'test2.latex') +""" % locals()) + +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 sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + 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'%(_python_)s wrapper.py ' + latex) +foo.DVI(target = 'foo.dvi', source = 'foo.ltx') +bar.DVI(target = 'bar', source = 'bar.latex') +""" % locals()) + + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/PDFLATEX.py b/test/TEX/PDFLATEX.py new file mode 100644 index 000000000..dbae623c9 --- /dev/null +++ b/test/TEX/PDFLATEX.py @@ -0,0 +1,144 @@ +#!/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__" + +""" +Validate that we can set the PDFLATEX string to our own utility, that +the produced .dvi, .aux and .log files get removed by the -c option, +and that we can use this to wrap calls to the real latex utility. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + + + +test.write('mypdflatex.py', r""" +import sys +import os +import getopt +cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) +base_name = os.path.splitext(arg[0])[0] +infile = open(arg[0], 'rb') +pdf_file = open(base_name+'.pdf', 'wb') +aux_file = open(base_name+'.aux', 'wb') +log_file = open(base_name+'.log', 'wb') +for l in infile.readlines(): + if l[0] != '\\': + pdf_file.write(l) + aux_file.write(l) + log_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(PDFLATEX = r'%(_python_)s mypdflatex.py', tools=['pdflatex']) +env.PDF(target = 'test1.pdf', source = 'test1.ltx') +env.PDF(target = 'test2.pdf', source = 'test2.latex') +""" % locals()) + +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 = '.') + +test.must_exist('test1.pdf') +test.must_exist('test1.aux') +test.must_exist('test1.log') + +test.must_exist('test2.pdf') +test.must_exist('test2.aux') +test.must_exist('test2.log') + +test.run(arguments = '-c .') + +test.must_not_exist('test1.pdf') +test.must_not_exist('test1.aux') +test.must_not_exist('test1.log') + +test.must_not_exist('test2.pdf') +test.must_not_exist('test2.aux') +test.must_not_exist('test2.log') + + + +pdflatex = test.where_is('pdflatex') + +if pdflatex: + + test.write("wrapper.py", """import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + test.write('SConstruct', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV) +pdflatex = foo.Dictionary('PDFLATEX') +bar = Environment(ENV = ENV, PDFLATEX = r'%(_python_)s wrapper.py ' + pdflatex) +foo.PDF(target = 'foo.pdf', source = 'foo.ltx') +bar.PDF(target = 'bar', source = 'bar.latex') +""" % locals()) + + 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.must_not_exist('wrapper.out') + + test.must_exist('foo.pdf') + + test.run(arguments = 'bar.pdf', stderr = None) + + test.must_match('wrapper.out', "wrapper.py\n") + + test.must_exist('bar.pdf') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/PDFLATEXCOM.py b/test/TEX/PDFLATEXCOM.py new file mode 100644 index 000000000..09283f30a --- /dev/null +++ b/test/TEX/PDFLATEXCOM.py @@ -0,0 +1,72 @@ +#!/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 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 [l for l in infile.readlines() if l != '/*latex*/\n']: + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/PDFLATEXCOMSTR.py b/test/TEX/PDFLATEXCOMSTR.py new file mode 100644 index 000000000..c751e8e49 --- /dev/null +++ b/test/TEX/PDFLATEXCOMSTR.py @@ -0,0 +1,77 @@ + +#!/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 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 [l for l in infile.readlines() if l != '/*latex*/\n']: + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/PDFLATEXFLAGS.py b/test/TEX/PDFLATEXFLAGS.py new file mode 100644 index 000000000..deee9edec --- /dev/null +++ b/test/TEX/PDFLATEXFLAGS.py @@ -0,0 +1,128 @@ +#!/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 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'%(_python_)s mypdflatex.py', + PDFLATEXFLAGS = '-x', + tools=['pdflatex']) +env.PDF(target = 'test1.pdf', source = 'test1.ltx') +env.Clone(PDFLATEXFLAGS = '-t').PDF(target = 'test2.pdf', source = 'test2.latex') +""" % locals()) + +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 sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + 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'%(_python_)s wrapper.py ' + pdflatex) +foo.PDF(target = 'foo.pdf', source = 'foo.ltx') +bar.PDF(target = 'bar', source = 'bar.latex') +""" % locals()) + + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/PDFTEX.py b/test/TEX/PDFTEX.py new file mode 100644 index 000000000..321a58ae4 --- /dev/null +++ b/test/TEX/PDFTEX.py @@ -0,0 +1,129 @@ +#!/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__" + +""" +Validate that we can set the PDFTEX string to our own utility, that +the produced .dvi, .aux and .log files get removed by the -c option, +and that we can use this to wrap calls to the real latex utility. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + + + +test.write('mypdftex.py', r""" +import sys +import os +import getopt +cmd_opts, arg = getopt.getopt(sys.argv[2:], 'i:r:', []) +base_name = os.path.splitext(arg[0])[0] +infile = open(arg[0], 'rb') +pdf_file = open(base_name+'.pdf', 'wb') +aux_file = open(base_name+'.aux', 'wb') +log_file = open(base_name+'.log', 'wb') +for l in infile.readlines(): + if l[0] != '\\': + pdf_file.write(l) + aux_file.write(l) + log_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(PDFTEX = r'%(_python_)s mypdftex.py', tools=['pdftex']) +env.PDF(target = 'test.pdf', source = 'test.tex') +""" % locals()) + +test.write('test.tex', r"""This is a test. +\end +""") + +test.run(arguments = 'test.pdf') + +test.must_exist('test.pdf') +test.must_exist('test.aux') +test.must_exist('test.log') + +test.run(arguments = '-c test.pdf') + +test.must_not_exist('test.pdf') +test.must_not_exist('test.aux') +test.must_not_exist('test.log') + + + +pdftex = test.where_is('pdftex') + +if pdftex: + + test.write("wrapper.py", """import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + test.write('SConstruct', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV) +pdftex = foo.Dictionary('PDFTEX') +bar = Environment(ENV = ENV, PDFTEX = r'%(_python_)s wrapper.py ' + pdftex) +foo.PDF(target = 'foo.pdf', source = 'foo.tex') +bar.PDF(target = 'bar', source = 'bar.tex') +""" % locals()) + + 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.must_not_exist('wrapper.out') + + test.must_exist('foo.pdf') + + test.run(arguments = 'bar.pdf', stderr = None) + + test.must_exist('wrapper.out') + + test.must_exist('bar.pdf') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/PDFTEXCOM.py b/test/TEX/PDFTEXCOM.py new file mode 100644 index 000000000..8c31da3bc --- /dev/null +++ b/test/TEX/PDFTEXCOM.py @@ -0,0 +1,72 @@ +#!/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 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 [l for l in infile.readlines() if l != '/*tex*/\n']: + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/PDFTEXCOMSTR.py b/test/TEX/PDFTEXCOMSTR.py new file mode 100644 index 000000000..13abe7a30 --- /dev/null +++ b/test/TEX/PDFTEXCOMSTR.py @@ -0,0 +1,77 @@ + +#!/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 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 [l for l in infile.readlines() if l != '/*tex*/\n']: + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/PDFTEXFLAGS.py b/test/TEX/PDFTEXFLAGS.py new file mode 100644 index 000000000..ce27e82dd --- /dev/null +++ b/test/TEX/PDFTEXFLAGS.py @@ -0,0 +1,119 @@ +#!/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 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'%(_python_)s mypdftex.py', + PDFTEXFLAGS = '-x', + tools=['pdftex']) +env.PDF(target = 'test.pdf', source = 'test.tex') +""" % locals()) + +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 sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + 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'%(_python_)s wrapper.py ' + pdftex) +foo.PDF(target = 'foo.pdf', source = 'foo.tex') +bar.PDF(target = 'bar', source = 'bar.tex') +""" % locals()) + + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/PDF_single_source.py b/test/TEX/PDF_single_source.py new file mode 100644 index 000000000..aefdd3e1a --- /dev/null +++ b/test/TEX/PDF_single_source.py @@ -0,0 +1,143 @@ +#!/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 creation of a mulitple pdf's from a list of PostScript files. + +Test courtesy Rob Managan. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +epstopdf = test.where_is('epstopdf') +if not epstopdf: + test.skip_test("Could not find 'epstopdf'; skipping test.\n") + + +test.write(['SConstruct'], """\ +import os + +env = Environment(ENV = { 'PATH' : os.environ['PATH'] }) + +env.PDF(['Fig1.ps','Fig3.ps','Fig2.ps']) +""") + + +figure = """\ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: Fig1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Apr 25 09:56:11 2006 +%%For: managan@mangrove.llnl.gov (Rob Managan) +%%BoundingBox: 0 0 98 98 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def + +end +save +newpath 0 98 moveto 0 0 lineto 98 0 lineto 98 98 lineto closepath clip newpath +-24.9 108.2 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/sc {scale} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/tr {translate} bind def + /DrawEllipse { + /endangle exch def + /startangle exch def + /yrad exch def + /xrad exch def + /y exch def + /x exch def + /savematrix mtrx currentmatrix def + x y tr xrad yrad sc 0 0 1 startangle endangle arc + closepath + savematrix setmatrix + } def + +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit + 0.06299 0.06299 sc +% +% Fig objects follow +% +7.500 slw +% Ellipse +n 1170 945 766 766 0 360 DrawEllipse gs col0 s gr + +$F2psEnd +rs +""" +test.write('Fig1.ps',figure ) +test.write('Fig2.ps',figure ) +test.write('Fig3.ps',figure ) + + +test.run(arguments = '.', stderr=None) + + +files = [ + 'Fig1.pdf', + 'Fig2.pdf', + 'Fig3.pdf', +] + +for f in files: + test.must_exist(f) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py new file mode 100644 index 000000000..24d4bdd48 --- /dev/null +++ b/test/TEX/TEX.py @@ -0,0 +1,192 @@ +#!/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__" + +""" +Validate that we can set the TEX string to our own utility, that +the produced .dvi, .aux and .log files get removed by the -c option, +and that we can use this to wrap calls to the real latex utility. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + + + +test.write('mytex.py', r""" +import sys +import os +import getopt +cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', []) +base_name = os.path.splitext(arg[0])[0] +infile = open(arg[0], 'rb') +dvi_file = open(base_name+'.dvi', 'wb') +aux_file = open(base_name+'.aux', 'wb') +log_file = open(base_name+'.log', 'wb') +for l in infile.readlines(): + if l[0] != '\\': + dvi_file.write(l) + aux_file.write(l) + log_file.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(TEX = r'%(_python_)s mytex.py', tools=['tex']) +env.DVI(target = 'test.dvi', source = 'test.tex') +""" % locals()) + +test.write('test.tex', r"""This is a test. +\end +""") + +test.run(arguments = 'test.dvi') + +test.must_match('test.dvi', "This is a test.\n") +test.must_match('test.aux', "This is a test.\n") +test.must_match('test.log', "This is a test.\n") + +test.run(arguments = '-c test.dvi') + +test.must_not_exist('test.dvi') +test.must_not_exist('test.aux') +test.must_not_exist('test.log') + + + +tex = test.where_is('tex') + +if tex: + + test.write("wrapper.py", """import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + test.write('SConstruct', """ +import os +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV) +tex = foo.Dictionary('TEX') +bar = Environment(ENV = ENV, TEX = r'%(_python_)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') +""" % locals()) + + 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.must_not_exist('wrapper.out') + test.must_exist('foo.dvi') + test.must_exist('foo-latex.dvi') + + test.run(arguments = 'bar.dvi bar-latex.dvi', stderr = None) + test.must_exist('wrapper.out') + test.must_exist('bar.dvi') + test.must_exist('bar-latex.dvi') + + test.run(stderr = None) + output_lines = test.stdout().split('\n') + + reruns = [x for x in output_lines if x.find('latex -interaction=nonstopmode -recorder rerun.tex') != -1] + if len(reruns) != 2: + print "Expected 2 latex calls, got %s:" % len(reruns) + print '\n'.join(reruns) + test.fail_test() + + bibtex = [x for x in output_lines if x.find('bibtex bibtex-test') != -1] + if len(bibtex) != 1: + print "Expected 1 bibtex call, got %s:" % len(bibtex) + print '\n'.join(bibtex) + test.fail_test() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/TEXCOM.py b/test/TEX/TEXCOM.py new file mode 100644 index 000000000..1cadd6340 --- /dev/null +++ b/test/TEX/TEXCOM.py @@ -0,0 +1,72 @@ +#!/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 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 [l for l in infile.readlines() if l != '/*tex*/\n']: + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/TEXCOMSTR.py b/test/TEX/TEXCOMSTR.py new file mode 100644 index 000000000..f1ead7fb1 --- /dev/null +++ b/test/TEX/TEXCOMSTR.py @@ -0,0 +1,76 @@ +#!/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 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 [l for l in infile.readlines() if l != '/*tex*/\n']: + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/TEXFLAGS.py b/test/TEX/TEXFLAGS.py new file mode 100644 index 000000000..7ae86ffcc --- /dev/null +++ b/test/TEX/TEXFLAGS.py @@ -0,0 +1,119 @@ +#!/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 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'%(_python_)s mytex.py', + TEXFLAGS = '-x', + tools=['tex']) +env.DVI(target = 'test.dvi', source = 'test.tex') +""" % locals()) + +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 sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + 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'%(_python_)s wrapper.py ' + tex) +foo.DVI(target = 'foo.dvi', source = 'foo.tex') +bar.DVI(target = 'bar', source = 'bar.tex') +""" % locals()) + + 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() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/auxiliaries.py b/test/TEX/auxiliaries.py new file mode 100644 index 000000000..832e8098c --- /dev/null +++ b/test/TEX/auxiliaries.py @@ -0,0 +1,175 @@ +#!/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__" + +""" +Verify that sections of LaTeX output that use auxiliary files (a +bibliography in our configuration below) are consistent when re-run +after modifying the input file. + +This checks for a bug that was triggered by the presence of auxiliary +files which were detected by SCons but then removed prior to invoking +TeX, causing the auxiliary sections to be excluded from the output. +That was fixed (courtesy Joel B. Mohler) by making all the relevant +auxiliary files Precious(). + +Test configuration courtesy Dmitry Mikhin. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +dvips = test.where_is('dvips') +latex = test.where_is('latex') + +if not dvips or not latex: + test.skip_test("Could not find dvips or latex; skipping test(s).\n") + + +test.subdir(['docs']) + +test.write(['SConstruct'], """\ +import os +env = Environment(tools = ['pdftex', 'dvipdf', 'dvips', 'tex', 'latex'], + BUILD_DIR = '#build/docs') + +# Use 'duplicate=1' because LaTeX toolchain does not work properly for +# input/output files outside of the current directory + +env.VariantDir('$BUILD_DIR', 'docs', duplicate=1) +env.SConscript('$BUILD_DIR/SConscript', exports = ['env']) +""") + +test.write(['docs', 'SConscript'], """\ +Import('env') +envc = env.Clone() + +test_dvi = envc.DVI(source='test.tex') +test_ps = envc.PostScript(source='test.tex') +test_pdf = envc.PDF(source='test.tex') + +envc.Default(test_dvi) +envc.Default(test_ps) +envc.Default(test_pdf) +""") + +test.write(['docs', 'my.bib'], """\ +@ARTICLE{Mikhin, + author = "Dmitry {\uppercase{Y}u}. Mikhin", + title = "Blah!", + journal = "Some yellow paper", + year = "2007", + volume = "7", + number = "3", + pages = "1--2" +} +""") + +tex_input = r"""\documentclass{article} + +\title{BUG IN SCONS} + +\author{Dmitry Yu. Mikhin} + +\begin{document} + +\maketitle + + +\begin{abstract} +\noindent A bug in BibTeX processing? +\end{abstract} + + +\section{The problem} + +Provide a citation here: \cite{Mikhin}. + + +\bibliography{my} +\bibliographystyle{unsrtnat} + +\end{document} +""" + +test.write(['docs', 'test.tex'], tex_input) + +test.run(stderr=None) + +pdf_output_1 = test.read(['build', 'docs', 'test.pdf']) +ps_output_1 = test.read(['build', 'docs', 'test.ps']) + +# Adding blank lines will cause SCons to re-run the builds, but the +# actual contents of the output files should be the same modulo +# the CreationDate header and some other PDF garp. +test.write(['docs', 'test.tex'], tex_input + "\n\n\n") + +test.run(stderr=None) + +pdf_output_2 = test.read(['build', 'docs', 'test.pdf']) +ps_output_2 = test.read(['build', 'docs', 'test.ps']) + + + +pdf_output_1 = test.normalize_pdf(pdf_output_1) +pdf_output_2 = test.normalize_pdf(pdf_output_2) + +if pdf_output_1 != pdf_output_2: + import sys + test.write(['build', 'docs', 'test.normalized.1.pdf'], pdf_output_1) + test.write(['build', 'docs', 'test.normalized.2.pdf'], pdf_output_2) + sys.stdout.write("***** 1.pdf and 2.pdf are different!\n") + sys.stdout.write(test.diff_substr(pdf_output_1, pdf_output_2, 80, 80) + '\n') + sys.stdout.write("Output from run 1:\n") + sys.stdout.write(test.stdout(-1) + '\n') + sys.stdout.write("Output from run 2:\n") + sys.stdout.write(test.stdout() + '\n') + sys.stdout.flush() + test.fail_test() + +ps_output_1 = test.normalize_ps(ps_output_1) +ps_output_2 = test.normalize_ps(ps_output_2) + +if ps_output_1 != ps_output_2: + import sys + sys.stdout.write("***** 1.ps and 2.ps are different!\n") + sys.stdout.write(test.diff_substr(ps_output_1, ps_output_2, 80, 80) + '\n') + sys.stdout.write("Output from run 1:\n") + sys.stdout.write(test.stdout(-1) + '\n') + sys.stdout.write("Output from run 2:\n") + sys.stdout.write(test.stdout() + '\n') + sys.stdout.flush() + test.fail_test() + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/biber_biblatex.py b/test/TEX/biber_biblatex.py new file mode 100755 index 000000000..a63fb3f00 --- /dev/null +++ b/test/TEX/biber_biblatex.py @@ -0,0 +1,124 @@ +#!/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 creation of a Tex document that uses the multibib oackage + +Test courtesy Rob Managan. +""" + +import TestSCons +import os + +test = TestSCons.TestSCons() + +latex = test.where_is('pdflatex') +if not latex: + test.skip_test("Could not find 'pdflatex'; skipping test.\n") + +biber = test.where_is('biber') +if not biber: + test.skip_test("Could not find 'biber'; skipping test.\n") + +gloss = os.system('kpsewhich biblatex.sty') +if not gloss==0: + test.skip_test("biblatex.sty not installed; skipping test(s).\n") + + +test.write(['SConstruct'], """\ +#!/usr/bin/env python + +import os +env = Environment(ENV=os.environ) +env['BIBTEX'] = 'biber' +main_output = env.PDF('bibertest.tex') +""") + + +sources_bib_content = r""" +@book{mybook, + title={Title}, + author={Author, A}, + year={%s}, + publisher={Publisher}, +} +""" +test.write(['ref.bib'],sources_bib_content % '2013' ) + +test.write(['bibertest.tex'],r""" +\documentclass{article} + +\usepackage[backend=biber]{biblatex} +\addbibresource{ref.bib} + +\begin{document} + +Hello. This is boring. +\cite{mybook} +And even more boring. + +\printbibliography +\end{document} +""") + + +test.run() + + +# All (?) the files we expect will get created in the docs directory +files = [ + 'bibertest.aux', + 'bibertest.bbl', + 'bibertest.bcf', + 'bibertest.blg', + 'bibertest.fls', + 'bibertest.log', + 'bibertest.pdf', + 'bibertest.run.xml', +] + + +for f in files: + test.must_exist([ f]) + +pdf_output_1 = test.read('bibertest.pdf') + + + +test.write(['ref.bib'],sources_bib_content % '1982') + +test.run() + +pdf_output_2 = test.read('bibertest.pdf') + +pdf_output_1 = test.normalize_pdf(pdf_output_1) +pdf_output_2 = test.normalize_pdf(pdf_output_2) + +# If the PDF file is the same as it was previously, then it didn't +# pick up the change from 1981 to 1982, so fail. +test.fail_test(pdf_output_1 == pdf_output_2) + +test.pass_test() diff --git a/test/TEX/biber_biblatex2.py b/test/TEX/biber_biblatex2.py new file mode 100644 index 000000000..95b56171c --- /dev/null +++ b/test/TEX/biber_biblatex2.py @@ -0,0 +1,128 @@ +#!/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 creation of a Tex document that uses the biblatex package +It uses the default backend, could be bibtex or biber. +Require both be installed + +Test courtesy Rob Managan. +""" + +import TestSCons +import os + +test = TestSCons.TestSCons() + +latex = test.where_is('pdflatex') +if not latex: + test.skip_test("Could not find 'pdflatex'; skipping test.\n") + +biber = test.where_is('biber') +if not biber: + test.skip_test("Could not find 'biber'; skipping test.\n") + +bibtex = test.where_is('bibtex') +if not bibtex: + test.skip_test("Could not find 'bibtex'; skipping test.\n") + +biblatex = os.system('kpsewhich biblatex.sty') +if not biblatex==0: + test.skip_test("biblatex.sty not installed; skipping test(s).\n") + + +test.write(['SConstruct'], """\ +#!/usr/bin/env python + +import os +env = Environment(ENV=os.environ) +main_output = env.PDF('bibertest.tex') +""") + + +sources_bib_content = r""" +@book{mybook, + title={Title}, + author={Author, A}, + year={%s}, + publisher={Publisher}, +} +""" +test.write(['ref.bib'],sources_bib_content % '2013' ) + +test.write(['bibertest.tex'],r""" +\documentclass{article} + +\usepackage{biblatex} +\addbibresource{ref.bib} + +\begin{document} + +Hello. This is boring. +\cite{mybook} +And even more boring. + +\printbibliography +\end{document} +""") + + +test.run() + + +# All (?) the files we expect will get created in the docs directory +files = [ + 'bibertest.aux', + 'bibertest.bbl', + 'bibertest.blg', + 'bibertest.fls', + 'bibertest.log', + 'bibertest.pdf', + 'bibertest.run.xml', +] + + +for f in files: + test.must_exist([ f]) + +pdf_output_1 = test.read('bibertest.pdf') + + + +test.write(['ref.bib'],sources_bib_content % '1982') + +test.run() + +pdf_output_2 = test.read('bibertest.pdf') + +pdf_output_1 = test.normalize_pdf(pdf_output_1) +pdf_output_2 = test.normalize_pdf(pdf_output_2) + +# If the PDF file is the same as it was previously, then it didn't +# pick up the change from 1981 to 1982, so fail. +test.fail_test(pdf_output_1 == pdf_output_2) + +test.pass_test() diff --git a/test/TEX/biblatex.py b/test/TEX/biblatex.py new file mode 100755 index 000000000..a6fbd483a --- /dev/null +++ b/test/TEX/biblatex.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__" + +""" +Test creation of a Tex document that uses the biblatex package + +Test courtesy Rob Managan. +""" + +import TestSCons +import os + +test = TestSCons.TestSCons() + +latex = test.where_is('pdflatex') +if not latex: + test.skip_test("Could not find 'pdflatex'; skipping test.\n") + +biblatex = os.system('kpsewhich biblatex.sty') +if not biblatex==0: + test.skip_test("biblatex.sty not installed; skipping test(s).\n") + + +test.write(['SConstruct'], """\ +#!/usr/bin/env python + +import os +env = Environment(ENV=os.environ) +main_output = env.PDF(target='biblatextest.pdf', source='biblatextest.tex') +""") + + +sources_bib_content = r""" +@book{mybook, + title={Title}, + author={Author, A}, + year={%s}, + publisher={Publisher}, +} +""" +test.write(['ref.bib'],sources_bib_content % '2013' ) + +test.write(['biblatextest.tex'],r""" +\documentclass{article} + +\usepackage{biblatex} +\addbibresource{ref.bib} + +\begin{document} + +Hello. This is boring. +\cite{mybook} +And even more boring. + +\printbibliography +\end{document} +""") + + +test.run() + + +# All (?) the files we expect will get created in the docs directory +files = [ + 'biblatextest.aux', + 'biblatextest.bbl', + 'biblatextest.blg', + 'biblatextest.fls', + 'biblatextest.log', + 'biblatextest.pdf', + 'biblatextest.run.xml', +] + +for f in files: + test.must_exist([ f]) + +pdf_output_1 = test.read('biblatextest.pdf') + + + +test.write(['ref.bib'],sources_bib_content % '1982') + +test.run() + +pdf_output_2 = test.read('biblatextest.pdf') + +pdf_output_1 = test.normalize_pdf(pdf_output_1) +pdf_output_2 = test.normalize_pdf(pdf_output_2) + +# If the PDF file is the same as it was previously, then it didn't +# pick up the change from 1981 to 1982, so fail. +test.fail_test(pdf_output_1 == pdf_output_2) + +test.pass_test() diff --git a/test/TEX/biblatex_plain.py b/test/TEX/biblatex_plain.py new file mode 100644 index 000000000..68f7cc379 --- /dev/null +++ b/test/TEX/biblatex_plain.py @@ -0,0 +1,91 @@ +#!/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 creation of a Tex document that uses the biblatex package + +Test courtesy Rob Managan. +""" + +import TestSCons +import os + +test = TestSCons.TestSCons() + +latex = test.where_is('pdflatex') +if not latex: + test.skip_test("Could not find 'pdflatex'; skipping test.\n") + +biblatex = os.system('kpsewhich biblatex.sty') +if not biblatex==0: + test.skip_test("biblatex.sty not installed; skipping test(s).\n") + + +test.write(['SConstruct'], """\ +#!/usr/bin/env python + +import os +env = Environment(ENV=os.environ) +main_output = env.PDF(target='biblatextest.pdf', source='biblatextest.tex') +""") + +test.write(['biblatextest.tex'],r""" +\documentclass{article} + +\usepackage{biblatex} + +\begin{document} + +Hello. This is boring. +And even more boring. + +\end{document} +""") + + +test.run() + + +# All (?) the files we expect will get created in the docs directory +files = [ + 'biblatextest.aux', + 'biblatextest.blg', + 'biblatextest.fls', + 'biblatextest.log', + 'biblatextest.pdf', + 'biblatextest.run.xml', +] + +for f in files: + test.must_exist([ f]) + +test.run(arguments = '-c .') + +for f in files: + test.must_not_exist([ f]) + +test.pass_test() + diff --git a/test/TEX/bibliography.py b/test/TEX/bibliography.py new file mode 100644 index 000000000..5e26f6ef6 --- /dev/null +++ b/test/TEX/bibliography.py @@ -0,0 +1,215 @@ +#!/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__" + +""" +Validate that use of \bibliography in TeX source files causes SCons to +be aware of the necessary created bibliography files. + +Test configuration contributed by Christopher Drexler. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +dvips = test.where_is('dvips') +bibtex = test.where_is('bibtex') + +if not dvips or not bibtex: + test.skip_test("Could not find dvips or bibtex; skipping test(s).\n") + +test.write('SConstruct', """\ +import os +env = Environment(tools = ['tex', 'latex', 'dvips']) +env.PostScript('simple', 'simple.tex') +""") + +test.write('simple.tex', r""" +\documentclass[12pt]{book} + +\begin{document} + +\chapter{Chapter 1}\label{c:c1} + +Test test.\cite{Aloimonos88:AV} + +\section{Section 1}\label{s:c1s1} +Test test. + +\section{Section 2}\label{s:c1s2} +Test test. + +\chapter{Chapter 2}\label{c:c2} + +Test test.\cite{Ayache86:HAN} + +\section{Section 1}\label{s:c2s1} +Test test. + +\section{Section 2}\label{s:c2s2} +Test test. + +\bibliographystyle{plain} +\bibliography{simple} +\end{document} +""") + +test.write('simple.bib', r""" +@Article{Aloimonos88:AV, + Author = {Aloimonos,~J and Weiss,~I. and Bandyopadyay,~A.}, + Title = {Active Vision}, + Journal = ijcv, + Volume = 2, + Number = 3, + Pages = {333--356}, + year = 1988, +} + +@Article{Ayache86:HAN, + Author = {Ayache, N. and Faugeras, O. D.}, + Title = {HYPER: A new approach for the recognition and + positioning of 2D objects}, + Journal = pami, + Volume = 8, + Number = 1, + Pages = {44-54}, + year = 1986, +} +""") + +test.run(arguments = '.', stderr=None) + +test.must_exist(test.workpath('simple.aux')) +test.must_exist(test.workpath('simple.bbl')) +test.must_exist(test.workpath('simple.blg')) + +test.run(arguments = '-c .') + +x = "Could not remove 'simple.aux': No such file or directory" +test.must_not_contain_any_line(test.stdout(), [x]) + +test.must_not_exist(test.workpath('simple.aux')) +test.must_not_exist(test.workpath('simple.bbl')) +test.must_not_exist(test.workpath('simple.blg')) + +test.pass_test() + + + +# FUTURE: + +test.write('SConstruct', """\ +env = Environment(tools = ['tex', 'latex', 'dvips']) +env.PostScript('d00', 'd00.tex') +""") + +test.write('d00.tex', r""" +\documentclass[12pt]{book} + +\begin{document} +\include{d-toc} + +\include{d01} +\include{d02} +\include{d03} + +\include{d-lit} +\end{document} +""") + +test.write('d01.tex', r""" +\chapter{Chapter 1}\label{c:c1} + +Test test.\cite{Aloimonos88:AV} + +\section{Section 1}\label{s:c1s1} +Test test. + +\section{Section 2}\label{s:c1s2} +Test test. + +\section{Section 3}\label{s:c1s3} +Test test. + +\section{Section 4}\label{s:c1s4} +Test test. +""") + +test.write('d02.tex', r""" +\chapter{Chapter 2}\label{c:c2} + +Test test.\cite{Ayache86:HAN} + +\section{Section 1}\label{s:c2s1} +Test test. + +\section{Section 2}\label{s:c2s2} +Test test. + +\section{Section 3}\label{s:c2s3} +Test test. + +\section{Section 4}\label{s:c2s4} +Test test. +""") + +test.write('d03.tex', r""" +\chapter{Chapter 3}\label{c:c3} + +Test test. + +\section{Section 1}\label{s:c3s1} +Test test. + +\section{Section 2}\label{s:c3s2} +Test test. + +\section{Section 3}\label{s:c3s3} +Test test. + +\section{Section 4}\label{s:c3s4} +Test test. +""") + +test.write('d-lit.tex', r""" +\bibliographystyle{plain} +\bibliography{d00} +""") + +test.write('d-toc.tex', r""" +\tableofcontents +\clearpage +\listoffigures +\clearpage +\listoftables +\cleardoublepage +""") + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/bibtex-latex-rerun.py b/test/TEX/bibtex-latex-rerun.py new file mode 100644 index 000000000..a2538f157 --- /dev/null +++ b/test/TEX/bibtex-latex-rerun.py @@ -0,0 +1,129 @@ +#!/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__" + +""" +Verify that we re-run LaTeX after running BibTeX in response to +changes in a .bib file. + +Thanks to Rob Managan for the patch that fixed this, and to Joel B. Mohler +for code clean up and packaging the test case. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +pdflatex = test.where_is('pdflatex') + +if not pdflatex: + test.skip_test("Could not find pdflatex; skipping test(s).\n") + +test.write(['SConstruct'], """\ +import os +env = Environment(tools=['pdftex', 'tex']) +env.PDF( 'bibtest.tex' ) +""") + +test.write(['bibtest.tex'], r""" +\documentclass{article} +\begin{document} +Learn about cool math in \cite{koblitz:elliptic_curves}. +\bibliographystyle{alpha} +\bibliography{sources} +\end{document} +""") + +sources_bib_content = r""" +@book{koblitz:elliptic_curves, + author = "Neal Koblitz", + title = "Elliptic Curves and Modular Forms", + year = "%s", + publisher = "Springer-Verlag New York Inc." +} +""" + + + +test.write('sources.bib', sources_bib_content % '1981') + +test.run() + +pdf_output_1 = test.read('bibtest.pdf') + + + +test.write('sources.bib', sources_bib_content % '1982') + +test.run() + +pdf_output_2 = test.read('bibtest.pdf') + +# If the PDF file is the same as it was previously, then it didn't +# pick up the change from 1981 to 1982, so fail. +test.fail_test(pdf_output_1 == pdf_output_2) + + + +# Double-check: clean everything and rebuild from scratch, which +# should force the PDF file to be the 1982 version. + +test.run(arguments = '-c') + +test.run() + +pdf_output_3 = test.read('bibtest.pdf') + + + +# If the PDF file is now different than the second run, modulo the +# creation timestamp and the ID and some other PDF garp, then something +# else odd has happened, so fail. + +pdf_output_2 = test.normalize_pdf(pdf_output_2) +pdf_output_3 = test.normalize_pdf(pdf_output_3) + +if pdf_output_2 != pdf_output_3: + import sys + test.write('bibtest.normalized.2.pdf', pdf_output_2) + test.write('bibtest.normalized.3.pdf', pdf_output_3) + sys.stdout.write("***** 2 and 3 are different!\n") + sys.stdout.write(test.diff_substr(pdf_output_2, pdf_output_3, 80, 80) + '\n') + sys.stdout.write("Output from run 2:\n") + sys.stdout.write(test.stdout(-2) + '\n') + sys.stdout.write("Output from run 3:\n") + sys.stdout.write(test.stdout() + '\n') + sys.stdout.flush() + test.fail_test() + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/clean.py b/test/TEX/clean.py new file mode 100644 index 000000000..b0e5ee4bd --- /dev/null +++ b/test/TEX/clean.py @@ -0,0 +1,107 @@ +#!/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__" + +""" +Check that all auxilary files created by LaTeX are properly cleaned by scons -c. +""" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test("Could not find tex or latex; skipping test(s).\n") + +comment = os.system('kpsewhich comment.sty') +if not comment==0: + test.skip_test("comment.sty not installed; skipping test(s).\n") + +# package hyperref generates foo.out +# package comment generates comment.cut +# todo: add makeindex etc. +input_file = r""" +\documentclass{article} +\usepackage{hyperref} +\usepackage{comment} +\specialcomment{foocom}{}{} +\begin{document} +\begin{foocom} +Hi +\end{foocom} +As stated in \cite{X}, this is a bug-a-boo. +\bibliography{fooref} +\bibliographystyle{plain} +\end{document} +""" + +bibfile = r""" +@Article{X, + author = "Mr. X", + title = "A determination of bug-a-boo-ness", + journal = "Journal of B.a.B.", + year = 1920, + volume = 62, + pages = 291 +} +""" + +test.write('SConstruct', """\ +import os +env = Environment(tools = ['tex', 'latex']) +env.DVI( "foo.ltx" ) +""") + +test.write('foo.ltx', input_file) +test.write('fooref.bib', bibfile) + +test.run() + +test.must_exist('foo.log') +test.must_exist('foo.aux') +test.must_exist('foo.bbl') +test.must_exist('foo.blg') +test.must_exist('comment.cut') +test.must_exist('foo.out') + +test.run(arguments = '-c') + +test.must_not_exist('foo.log') +test.must_not_exist('foo.aux') +test.must_not_exist('foo.bbl') +test.must_not_exist('foo.blg') +test.must_not_exist('comment.cut') +test.must_not_exist('foo.out') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/configure.py b/test/TEX/configure.py new file mode 100644 index 000000000..60ebb9cd9 --- /dev/null +++ b/test/TEX/configure.py @@ -0,0 +1,93 @@ +#!/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__" + +""" +Verify execution of custom test case. +The old code base would not be able to fail the test +""" + +import TestSCons + +_exe = TestSCons._exe +_obj = TestSCons._obj +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +dvips = test.where_is('dvips') +latex = test.where_is('latex') + +if not dvips or not latex: + test.skip_test("Could not find dvips or latex; skipping test(s).\n") + +NCR = test.NCR # non-cached rebuild + +#---------------- +# 'lmodern' package for LaTeX available? +# misspell package name to ensure failure + +test.write('SConstruct', r""" +lmodern_test_text = r''' +\documentclass{article} +\usepackage{lmodernD} +\title{Mytitle} +\author{Jane Doe} +\begin{document} + \maketitle + Hello world! +\end{document} +''' + +def CheckLModern(context): + context.Message("Checking for lmodern...") + b = context.env.DVI + is_ok = context.TryBuild(b,lmodern_test_text,'.tex') + context.Result(is_ok) + return is_ok + +import os +env = Environment() +env['TEXINPUTS'] = '.' +conf = Configure( env, custom_tests={'CheckLModern' : CheckLModern} ) +conf.CheckLModern() +env = conf.Finish() +""" % locals()) + +test.run() + +test.checkLogAndStdout(["Checking for lmodern..."], + ["no"], + [[(('', NCR), )]], + "config.log", ".sconf_temp", "SConstruct") + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/dryrun.py b/test/TEX/dryrun.py new file mode 100644 index 000000000..308e16782 --- /dev/null +++ b/test/TEX/dryrun.py @@ -0,0 +1,68 @@ +#!/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__" + +""" +Validate that we can set the LATEX string to our own utility, that +the produced .dvi, .aux and .log files get removed by the -c option, +and that we can use this to wrap calls to the real latex utility. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test('could not find latex; skipping test\n') + +test.write('SConstruct', """ +import os +foo = Environment() +foo.DVI(target = 'foo.dvi', source = 'foo.ltx') +""" % locals()) + +test.write('foo.ltx', r""" +\documentclass{letter} +\begin{document} +This is the foo.ltx file. +\end{document} +""") + +test.run(arguments = '--dry-run', stdout = test.wrap_stdout("""\ +cd . && latex -interaction=nonstopmode -recorder foo.ltx ... +"""), stderr = None) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/eps_graphics.py b/test/TEX/eps_graphics.py new file mode 100644 index 000000000..e0a8731b1 --- /dev/null +++ b/test/TEX/eps_graphics.py @@ -0,0 +1,193 @@ +#!/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 creation of a Tex document with nested includes in a +subdir that needs to create a fig.pdf. + +Test courtesy Rob Managan. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +epstopdf = test.where_is('epstopdf') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +if not epstopdf: + test.skip_test("Could not find 'epstopdf'; skipping test.\n") + +test.subdir(['docs']) + + +test.write(['SConstruct'], """\ +import os + +env = Environment() + +test = env.DVI(source='docs/test.tex') +""") + + +test.write(['docs','Fig1.eps'], """\ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: Fig1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Apr 25 09:56:11 2006 +%%For: managan@mangrove.llnl.gov (Rob Managan) +%%BoundingBox: 0 0 98 98 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def + +end +save +newpath 0 98 moveto 0 0 lineto 98 0 lineto 98 98 lineto closepath clip newpath +-24.9 108.2 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/sc {scale} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/tr {translate} bind def + /DrawEllipse { + /endangle exch def + /startangle exch def + /yrad exch def + /xrad exch def + /y exch def + /x exch def + /savematrix mtrx currentmatrix def + x y tr xrad yrad sc 0 0 1 startangle endangle arc + closepath + savematrix setmatrix + } def + +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit + 0.06299 0.06299 sc +% +% Fig objects follow +% +7.500 slw +% Ellipse +n 1170 945 766 766 0 360 DrawEllipse gs col0 s gr + +$F2psEnd +rs +""") + + + +test.write(['docs','test.tex'], +r"""\documentclass{report} + +\usepackage{graphicx} +\usepackage{epsfig,color} % for .tex version of figures if we go that way + +\begin{document} + +\title{Report Title} + +\author{A. N. Author} + +\maketitle + +\begin{abstract} +there is no abstract +\end{abstract} + +\chapter{Introduction} + +The introduction is short. + +\section{Acknowledgements} + +The Acknowledgements are shown as well. + +To get a hard copy of this report call me. + +\begin{figure}[htbp] +\begin{center} +\includegraphics{Fig1} +\caption{Zone and Node indexing} +\label{fig1} +\end{center} +\end{figure} + +All done now. + +\end{document} +""") + +# makeindex will write status messages to stderr (grrr...), so ignore it. +test.run(arguments = '.', stderr=None) + + +# All (?) the files we expect will get created in the subdir +# (mybuild/docs) and not in the srcdir (docs). +files = [ + 'docs/test.aux', + 'docs/test.log', + 'docs/test.dvi', +] + +for f in files: + test.must_exist([ f]) + +test.must_not_exist(['docs/Fig1.pdf',]) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/eps_graphics2.py b/test/TEX/eps_graphics2.py new file mode 100644 index 000000000..e523df7eb --- /dev/null +++ b/test/TEX/eps_graphics2.py @@ -0,0 +1,190 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test creation of a Tex document with nested includes in a +subdir that needs to create a fig.pdf. +Test creation with pdflatex + +Test courtesy Rob Managan. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +epstopdf = test.where_is('epstopdf') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +if not epstopdf: + test.skip_test("Could not find 'epstopdf'; skipping test.\n") + +test.subdir(['docs']) + + +test.write(['SConstruct'], """\ +import os + +env = Environment() + +env.PDF('docs/Fig1.eps') +test = env.PDF(source='docs/test.tex') +""") + + +test.write(['docs','Fig1.eps'], """\ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: Fig1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Apr 25 09:56:11 2006 +%%For: managan@mangrove.llnl.gov (Rob Managan) +%%BoundingBox: 0 0 98 98 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def + +end +save +newpath 0 98 moveto 0 0 lineto 98 0 lineto 98 98 lineto closepath clip newpath +-24.9 108.2 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/sc {scale} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/tr {translate} bind def + /DrawEllipse { + /endangle exch def + /startangle exch def + /yrad exch def + /xrad exch def + /y exch def + /x exch def + /savematrix mtrx currentmatrix def + x y tr xrad yrad sc 0 0 1 startangle endangle arc + closepath + savematrix setmatrix + } def + +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit + 0.06299 0.06299 sc +% +% Fig objects follow +% +7.500 slw +% Ellipse +n 1170 945 766 766 0 360 DrawEllipse gs col0 s gr + +$F2psEnd +rs +""") + + + +test.write(['docs','test.tex'], +r"""\documentclass{report} + +\usepackage{graphicx} +\usepackage{epsfig,color} % for .tex version of figures if we go that way + +\begin{document} + +\title{Report Title} + +\author{A. N. Author} + +\maketitle + +\begin{abstract} +there is no abstract +\end{abstract} + +\chapter{Introduction} + +The introduction is short. + +\section{Acknowledgements} + +The Acknowledgements are shown as well. + +To get a hard copy of this report call me. + +\begin{figure}[htbp] +\begin{center} +\includegraphics + [width=.5\textwidth] + {Fig1} +\caption{Zone and Node indexing} +\label{fig1} +\end{center} +\end{figure} + +All done now. + +\end{document} +""") + +# makeindex will write status messages to stderr (grrr...), so ignore it. +test.run(arguments = 'docs/test.pdf', stderr=None) + + +# All (?) the files we expect will get created in the docs directory +files = [ + 'docs/test.aux', + 'docs/test.log', + 'docs/test.pdf', +] + +for f in files: + test.must_exist([ f]) + +#test.must_not_exist(['docs/Fig1.pdf',]) + +test.pass_test() diff --git a/test/TEX/generated_files.py b/test/TEX/generated_files.py new file mode 100644 index 000000000..03251549e --- /dev/null +++ b/test/TEX/generated_files.py @@ -0,0 +1,179 @@ +#!/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 creation of a Tex document with generated tex files +This checks whether the .bbl file is kept as a side effect +Test creation with pdflatex + +Test courtesy Rob Managan. +""" + +import TestSCons +import os + +test = TestSCons.TestSCons() + +pdflatex = test.where_is('latex') +if not pdflatex: + test.skip_test("Could not find 'pdflatex'; skipping test.\n") + +test.subdir(['src']) + + +test.write(['SConstruct'], """\ +import os + +env = Environment() + +copy_latex = Builder(action=Copy('$TARGET', '$SOURCE'), + suffix='.tex', + src_suffix='.src') +env.Append( BUILDERS={'CopyLatex' : copy_latex} ) + +Export(['env']) + +VariantDir('pdf', 'src') +SConscript('pdf/SConscript') +""") + +test.write(['src','SConscript'],""" +import os +Import('env') + +latex_file = env.CopyLatex('main.src') + +# latexing +pdf = env.PDF(latex_file) + +""") + + +test.write(['src','literatura.bib'],r""" +@INPROCEEDINGS{Groce03whatwent, + author = {Alex Groce and Willem Visser}, + title = {What Went Wrong: Explaining Counterexamples}, + booktitle = {In SPIN Workshop on Model Checking of Software}, + year = {2003}, + pages = {121--135} +} + +@book{Herlihy08TAOMP, + author = {Herlihy, Maurice and Shavit, Nir}, + howpublished = {Paperback}, + isbn = {0123705916}, + month = {March}, + publisher = {Morgan Kaufmann}, + title = {The Art of Multiprocessor Programming}, + url = {http://www.worldcat.org/isbn/0123705916}, + year = {2008} +} + +@book{Grumberg99MC, + author = "Edmund M. Clarke and Orna Grumberg and Doron A. Peled", + title = "Model Checking", + publisher = "The MIT Press", + year = "1999", + address = "Cambridge, Massachusetts" +} + +@book{Katoen08PrincMC, + author = {Baier, Christel and Katoen, Joost-Pieter}, + howpublished = {Hardcover}, + isbn = {026202649X}, + keywords = {books, model\_checking}, + publisher = {The MIT Press}, + title = {Principles of Model Checking}, + url = {http://www.worldcat.org/isbn/026202649X}, + year = {2008} +} + + +""") + +test.write(['src','main.src'],r""" +% vim:ft=context +\documentclass[draft]{report} +\usepackage[utf8]{inputenc} + +%\usepackage{algorithm2e} +%\usepackage{amsthm} + + +\begin{document} + + +A safety property $\phi$ holds in a Kripke structure $M$ if and only if +$\phi$ holds in every state reachable from $S_0$ \cite{Katoen08PrincMC}. +$\phi$ holds in a state $s\in S$, written as $s \models \phi$, when +$\phi$ holds under valuation corresponding to $L(s)$. + +Given the structure and a formula, the model checker can verify it by +visiting all states from the initial state using DFS or BFS and checking +the validity of the formula at every state. When a state is found in +which the formula does not hold, the search is terminated and the path +from initial state to the failing state is presented to the user as a +counterexample. This algorithm may also be called \emph{reachability}, +because it enumerates the reachable states and additionally performs the +formula validity. + + + + +\section{Comparing correct and incorrect traces in explicit MC} +\label{hd003001} +Alex Groce and Willem Visser implemented an algorithm in the Java +PathFinder model checker which explains violations of safety properties +\cite{Groce03whatwent}. The algorithm finds a set of failing runs + +\bibliographystyle{plain} +\bibliography{literatura} + + +\end{document} + +""") + + +test.run(arguments = '', stderr=None) + + +# All (?) the files we expect will get created in the docs directory +files = [ + 'pdf/main.aux', + 'pdf/main.bbl', + 'pdf/main.blg', + 'pdf/main.fls', + 'pdf/main.log', + 'pdf/main.pdf', +] + +for f in files: + test.must_exist([ f]) + +#test.must_not_exist(['docs/Fig1.pdf',]) + +test.pass_test() diff --git a/test/TEX/glossaries.py b/test/TEX/glossaries.py new file mode 100644 index 000000000..05ddf1284 --- /dev/null +++ b/test/TEX/glossaries.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__" + +""" +Validate that use of \glossaries in TeX source files causes SCons to +be aware of the necessary created glossary files. + +Test configuration contributed by Robert Managan. +""" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test("Could not find latex; skipping test(s).\n") + +gloss = os.system('kpsewhich glossaries.sty') +if not gloss==0: + test.skip_test("glossaries.sty not installed; skipping test(s).\n") + +test.write('SConstruct', """\ +import os +env = Environment() +env.PDF('glossaries', 'glossaries.tex') +""") + +test.write('glossaries.tex', r""" +\documentclass{article} + +\usepackage[acronym]{glossaries} + +\newglossaryentry{nix}{ + name={Nix}, + description={Version 5} +} + +\newacronym{gnu}{GNU}{GNU's Not UNIX} + +\makeglossaries + + +\begin{document} + +Acronyms \gls{gnu} and glossary entries \gls{nix}. + +\printglossary[type=acronym] +\printglossary[type=main] + +\end{document} +""") + +test.run(arguments = '.', stderr=None) + +test.must_exist(test.workpath('glossaries.acn')) +test.must_exist(test.workpath('glossaries.acr')) +test.must_exist(test.workpath('glossaries.alg')) +test.must_exist(test.workpath('glossaries.aux')) +test.must_exist(test.workpath('glossaries.fls')) +test.must_exist(test.workpath('glossaries.glg')) +test.must_exist(test.workpath('glossaries.glo')) +test.must_exist(test.workpath('glossaries.ist')) +test.must_exist(test.workpath('glossaries.log')) +test.must_exist(test.workpath('glossaries.pdf')) + +test.run(arguments = '-c .') + +x = "Could not remove 'glossaries.aux': No such file or directory" +test.must_not_contain_any_line(test.stdout(), [x]) + +test.must_not_exist(test.workpath('glossaries.acn')) +test.must_not_exist(test.workpath('glossaries.acr')) +test.must_not_exist(test.workpath('glossaries.alg')) +test.must_not_exist(test.workpath('glossaries.aux')) +test.must_not_exist(test.workpath('glossaries.fls')) +test.must_not_exist(test.workpath('glossaries.glg')) +test.must_not_exist(test.workpath('glossaries.glo')) +test.must_not_exist(test.workpath('glossaries.ist')) +test.must_not_exist(test.workpath('glossaries.log')) +test.must_not_exist(test.workpath('glossaries.pdf')) + +test.pass_test() + + + + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/glossary.py b/test/TEX/glossary.py new file mode 100644 index 000000000..be0a870a3 --- /dev/null +++ b/test/TEX/glossary.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Validate that use of \glossary in TeX source files causes SCons to +be aware of the necessary created glossary files. + +Test configuration contributed by Robert Managan. +""" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test("Could not find latex; skipping test(s).\n") + +gloss = os.system('kpsewhich glossary.sty') +if not gloss==0: + test.skip_test("glossary.sty not installed; skipping test(s).\n") + +test.write('SConstruct', """\ +import os +env = Environment(tools = ['latex'], ENV = {'PATH' : os.environ['PATH']}) +env.DVI('gloassary', 'glossary.ltx') +""") + +test.write('glossary.ltx', r""" +\documentclass{article} + +\usepackage{glossary} + +\makeglossary + + +\begin{document} + +A glossary entry \glossary{name={gnu}, description={an animal or software group}} +and another\glossary{name={nix}, description={not sure}}. + +\printglossary + +\end{document} +""") + +test.run(arguments = '.', stderr=None) + +test.must_exist(test.workpath('glossary.aux')) +test.must_exist(test.workpath('glossary.fls')) +test.must_exist(test.workpath('glossary.glg')) +test.must_exist(test.workpath('glossary.glo')) +test.must_exist(test.workpath('glossary.gls')) +test.must_exist(test.workpath('glossary.ist')) +test.must_exist(test.workpath('glossary.log')) +test.must_exist(test.workpath('gloassary.dvi')) + +test.run(arguments = '-c .') + +x = "Could not remove 'glossary.aux': No such file or directory" +test.must_not_contain_any_line(test.stdout(), [x]) + +test.must_not_exist(test.workpath('glossary.aux')) +test.must_not_exist(test.workpath('glossary.fls')) +test.must_not_exist(test.workpath('glossary.glg')) +test.must_not_exist(test.workpath('glossary.glo')) +test.must_not_exist(test.workpath('glossary.gls')) +test.must_not_exist(test.workpath('glossary.ist')) +test.must_not_exist(test.workpath('glossary.log')) +test.must_not_exist(test.workpath('gloassary.dvi')) + +test.pass_test() + + + + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/input_docClass.py b/test/TEX/input_docClass.py new file mode 100644 index 000000000..3fa2b083a --- /dev/null +++ b/test/TEX/input_docClass.py @@ -0,0 +1,96 @@ +#!/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 creation of a LaTeX document that uses \input{filename} +to set the documentclass. When the file has .tex we have to search +to find the documentclass command. + +Test courtesy Rob Managan. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +test.write(['SConstruct'], """\ +import os + +env = Environment() + +test = env.PDF(source='test.tex') +""") + +test.write(['test.tex'], +r""" +\input{theClass} + +\begin{document} + +\title{Report Title} + +\author{A. N. Author} + +\maketitle + +\begin{abstract} +there is no abstract +\end{abstract} + +\tableofcontents +\listoffigures + +\chapter{Introduction} + +The introduction is short. + +\section{Acknowledgements} + +The Acknowledgements are shown as well. + +\end{document} +""") + +test.write(['theClass.tex'], +r""" +\documentclass{report} + +""") + +# makeindex will write status messages to stderr (grrr...), so ignore it. +test.run(arguments = '.', stderr=None) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/lstinputlisting.py b/test/TEX/lstinputlisting.py new file mode 100644 index 000000000..fcfe5a888 --- /dev/null +++ b/test/TEX/lstinputlisting.py @@ -0,0 +1,136 @@ +#!/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__" + +""" +Verify that we re-run LaTeX when a source file in \lstinputlisting +changes. + +Thanks to Stefan Hepp for the patch that fixed this. +""" + +import TestSCons +import os + +test = TestSCons.TestSCons() + +pdflatex = test.where_is('pdflatex') + +if not pdflatex: + test.skip_test("Could not find pdflatex; skipping test(s).\n") + +listings = os.system('kpsewhich listings.sty') +if not listings==0: + test.skip_test("listings.sty not installed; skipping test(s).\n") + +test.write(['SConstruct'], """\ +import os + +DefaultEnvironment() + +PDF("test.tex") +""") + +test.write(['test.tex'], r""" +\documentclass{article} +\usepackage{listings} + +\begin{document} + +\section{Listings} + +\lstinputlisting{test.c} + +\end{document} +""") + +source_content = r""" +int main(int argc, char** argv) { + return %s; +} +""" + + + +test.write('test.c', source_content % '0') + +test.run() + +pdf_output_1 = test.read('test.pdf') + + + +test.write('test.c', source_content % '1') + +test.run() + +pdf_output_2 = test.read('test.pdf') + +# If the PDF file is the same as it was previously, then it didn't +# pick up the change from 1981 to 1982, so fail. +test.fail_test(pdf_output_1 == pdf_output_2) + + + +# Double-check: clean everything and rebuild from scratch, which +# should force the PDF file to be the 1982 version. + +test.run(arguments = '-c') + +test.run() + +pdf_output_3 = test.read('test.pdf') + + + +# If the PDF file is now different than the second run, modulo the +# creation timestamp and the ID and some other PDF garp, then something +# else odd has happened, so fail. + +pdf_output_2 = test.normalize_pdf(pdf_output_2) +pdf_output_3 = test.normalize_pdf(pdf_output_3) + +if pdf_output_2 != pdf_output_3: + import sys + test.write('test.normalized.2.pdf', pdf_output_2) + test.write('test.normalized.3.pdf', pdf_output_3) + sys.stdout.write("***** 2 and 3 are different!\n") + sys.stdout.write(test.diff_substr(pdf_output_2, pdf_output_3, 80, 80) + '\n') + sys.stdout.write("Output from run 2:\n") + sys.stdout.write(test.stdout(-2) + '\n') + sys.stdout.write("Output from run 3:\n") + sys.stdout.write(test.stdout() + '\n') + sys.stdout.flush() + test.fail_test() + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/makeindex.py b/test/TEX/makeindex.py new file mode 100644 index 000000000..638224ae4 --- /dev/null +++ b/test/TEX/makeindex.py @@ -0,0 +1,110 @@ +#!/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__" + +""" +Validate that use of \makeindex in TeX source files causes SCons to be +aware of the necessary created index files. + +Test configuration courtesy Joel B. Mohler. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +pdflatex = test.where_is('pdflatex') +makeindex = test.where_is('makeindex') + +if not pdflatex or not makeindex: + test.skip_test("Could not find pdflatex or makeindex; skipping test(s).\n") + +test.write('SConstruct', """\ +import os +env = Environment(tools = ['pdftex', 'dvipdf', 'tex', 'latex']) +env.PDF( "no_index.tex" ) +env.PDF( "simple.tex" ) +""") + +test.write('no_index.tex', r""" +\documentclass{article} + +\begin{document} +Nothing to see here, move along! +\end{document} +""") + +test.write('simple.tex', r""" +\documentclass{article} +\usepackage{makeidx} +\makeindex + +\begin{document} +\section{Test 1} +I would like to \index{index} this. + +\section{test 2} +I'll index \index{this} as well. + +\printindex +\end{document} +""") + +# Bleah, makeindex seems to print a bunch of diagnostic stuff on stderr, +# so we have to ignore it. +test.run(arguments = '.', stderr=None) + +test.must_exist(test.workpath('simple.aux')) +test.must_exist(test.workpath('simple.idx')) +test.must_exist(test.workpath('simple.ilg')) +test.must_exist(test.workpath('simple.ind')) + +test.must_exist(test.workpath('no_index.aux')) + +test.must_not_exist(test.workpath('no_index.idx')) +test.must_not_exist(test.workpath('no_index.ilg')) +test.must_not_exist(test.workpath('no_index.ind')) + +test.run(arguments = '-c .') + +x = "Could not remove 'no_index.aux': No such file or directory" +test.must_not_contain_any_line(test.stdout(), [x]) +x = "Could not remove 'simple.aux': No such file or directory" +test.must_not_contain_any_line(test.stdout(), [x]) + +test.must_not_exist(test.workpath('simple.aux')) +test.must_not_exist(test.workpath('simple.idx')) +test.must_not_exist(test.workpath('simple.ilg')) +test.must_not_exist(test.workpath('simple.ind')) + +test.must_not_exist(test.workpath('no_index.aux')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/multi-line_include_options.py b/test/TEX/multi-line_include_options.py new file mode 100644 index 000000000..5266455c2 --- /dev/null +++ b/test/TEX/multi-line_include_options.py @@ -0,0 +1,90 @@ +#!/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__" + +""" +When an inclusion's optional argument (enclosed in square brackets: +[]) spans multiple lines (via comment wrapping), ensure that the LaTeX +Scanner doesn't throw an IndexError. + +An example of this in the wild is in Thomas Heim's epsdice LaTeX package: + \includegraphics[height=1.75ex,viewport= 3 4 38 39,% + clip=true]{\dicefile}% +In epsdice 2007/02/15, v. 2.1. +""" + +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test("Could not find latex; skipping test(s).\n") + +test.write('SConstruct', """\ +import os +env = Environment() +env.DVI('root.tex') +""") + +test.write('root.tex', +r"""\documentclass{article} +\usepackage{graphicx} +\begin{document} + \includegraphics[height=1.75ex,% + clip=true]{square} +\end{document} +""") + +# Dummy EPS file drawing a square +test.write('square.eps', +r"""%!PS-Adobe-2.0 EPSF-1.2 +%%BoundingBox: 0 0 20 20 + newpath + 5 5 moveto + 15 5 lineto + 15 15 lineto + 5 15 lineto + 5 5 lineto + stroke +%%EOF +""") + +test.run(arguments = '.') + +test.must_exist(test.workpath('root.dvi')) +test.must_exist(test.workpath('root.log')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: + diff --git a/test/TEX/multi-run.py b/test/TEX/multi-run.py new file mode 100644 index 000000000..7e94be398 --- /dev/null +++ b/test/TEX/multi-run.py @@ -0,0 +1,224 @@ +#!/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__" + +""" +Validate that both .tex and .ltx files can handle a LaTeX-style +bibliography (by calling $BIBTEX to generate a .bbl file) and +correctly re-run to resolve undefined references. + +Also verifies that package warnings are caught and re-run as needed. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +tex = test.where_is('tex') +latex = test.where_is('latex') + +if not tex and not latex: + test.skip_test("Could not find tex or latex; skipping test(s).\n") + +test.subdir('work1', 'work2', 'work3', 'work4') + + +input_file = r""" +\documentclass{article} + +\begin{document} +As stated in \cite{X}, this is a bug-a-boo. +\bibliography{fooref} +\bibliographystyle{plain} +\end{document} +""" + +input_file2 = r""" +\documentclass{article} +\begin{document} +Hello world. +% \bibliography{fooref} +% \bibliographystyle{plain} +\end{document} +""" + +input_file3 = r""" +\documentclass{article} +\usepackage{longtable} + +\begin{document} +As stated in the last paper, this is a bug-a-boo. +here is some more junk and another table +here is some more junk and another table + +\begin{longtable}[l]{rlll} + Isotope &\multicolumn{1}{c}{Abar} &Name\\ +\\ + 1001 &1.0078 &Proton &$p$\\ + 1002 &2.0141 &Deuterium &$d$\\ + 1003 &3.0170 &Tritium &$t$\\ + 2003 &3.0160 &Helium 3 &He$^3$\\ + 2004 &4.0026 &Helium 4 &He$^{4}$\\ +\end{longtable} + +and a closing comment + + These parameters and arrays are filled in when the parameter \textbf{iftnrates} + is set to 1: + +\begin{longtable}[l]{ll} +\\ +\textbf{nxxxx} &Total number of particles made by xxxx reaction\\ +\textbf{pxxxx} &Total number of particles made by xxxx reaction\\ +\textbf{nxxxxx} &Total number of particles made by xxxxx reaction\\ +\textbf{nxxxx} &Total number of particles made by xxxx reaction\\ +\textbf{pxxxx} &Total number of particles made by xxxx reaction\\ +\textbf{nxxxx} &Total number of particles made by xxxx reaction\\ +\textbf{pxxxx} &Total number of particles made by xxxx reaction\\ +\textbf{nxxxxx} &Total number of particles made by xxxxx reaction\\ +\textbf{nxxxx} &Total number of particles made by xxxx reaction\\ +\textbf{pxxxx} &Total number of particles made by xxxx reaction\\ +\\ +\textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\ +\textbf{rpxxxx} &Regional total of particles made by xxxx reaction\\ +\textbf{rnxxxxx} &Regional total of particles made by xxxxx reaction\\ +\textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\ +\textbf{rpxxxx} &Regional total of particles made by xxxx reaction\\ +\textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\ +\textbf{rpxxxx} &Regional total of particles made by xxxx reaction\\ +\textbf{rnxxxxx} &Regional total of particles made by xxxxx reaction\\ +\textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\ +\textbf{rpxxxx} &Regional total of particles made by xxxx reaction\\ +\\ +\textbf{reactot}(r) &Total number of reactions for reaction r\\ +\textbf{reacreg}(r,ir) &Total number of reactions for reaction r in region ir\\ +\end{longtable} + + +\end{document} +""" + +bibfile = r""" +@Article{X, + author = "Mr. X", + title = "A determination of bug-a-boo-ness", + journal = "Journal of B.a.B.", + year = 1920, + volume = 62, + pages = 291 +} +""" + +if tex: + + test.write(['work1', 'SConstruct'], """\ +import os +env = Environment(tools = ['pdftex', 'dvipdf', 'tex', 'latex']) +env.DVI( "foo.tex" ) +env.PDF( "foo.tex" ) +""") + + test.write(['work1', 'foo.tex'], input_file) + test.write(['work1', 'fooref.bib'], bibfile) + + test.run(chdir = 'work1', arguments = '.') + + test.must_exist(['work1', 'foo.bbl']) + + foo_log = test.read(['work1', 'foo.log']) + test.must_not_contain_any_line(foo_log, ['undefined references'], 'foo.log') + + test.write(['work3', 'SConstruct'], """\ +import os +env = Environment(tools = ['tex', 'latex'], + ENV = {'PATH' : os.environ['PATH']}) +env.DVI( "foo3.tex" ) +""") + + test.write(['work3', 'foo3.tex'], input_file3) + + test.run(chdir = 'work3', arguments = '.') + + foo_log = test.read(['work3', 'foo3.log']) + test.must_not_contain_any_line(foo_log, ['Rerun LaTeX'], 'foo3.log') + + + +if latex: + + test.write(['work2', 'SConstruct'], """\ +import os +env = Environment(tools = ['dvi', 'pdf', 'pdftex', 'dvipdf', 'pdflatex', 'tex', 'latex'], + ENV = {'PATH' : os.environ['PATH']}) +env.DVI( "foo.ltx" ) +env.PDF( "foo.ltx" ) +""") + + test.write(['work2', 'foo.ltx'], input_file) + test.write(['work2', 'fooref.bib'], bibfile) + + test.run(chdir = 'work2', arguments = '.') + + test.must_exist(['work2', 'foo.bbl']) + + foo_log = test.read(['work2', 'foo.log']) + test.must_not_contain_any_line(foo_log, ['undefined references'], 'foo.log') + + test.write(['work3', 'SConstruct'], """\ +import os +env = Environment(tools = ['pdftex', 'dvipdf', 'tex', 'latex'], + ENV = {'PATH' : os.environ['PATH']}) +env.DVI( "foo3.tex" ) +env.PDF( "foo3.tex" ) +""") + + test.write(['work3', 'foo3.tex'], input_file3) + + test.run(chdir = 'work3', arguments = '.') + + foo_log = test.read(['work3', 'foo3.log']) + test.must_not_contain_any_line(foo_log, ['Rerun LaTeX'], 'foo3.log') + + + test.write(['work4', 'SConstruct'], """\ +import os +env = Environment(tools = ['tex', 'latex'], + ENV = {'PATH' : os.environ['PATH']}) +env.DVI( "foo.ltx" ) +""") + test.write(['work4', 'foo.ltx'], input_file2) + + test.run(chdir = 'work4', arguments = '.') + + test.up_to_date(chdir = 'work4', arguments = '.') + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/multibib.py b/test/TEX/multibib.py new file mode 100644 index 000000000..cdb9b8722 --- /dev/null +++ b/test/TEX/multibib.py @@ -0,0 +1,101 @@ +#!/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 creation of a Tex document that uses the multibib oackage + +Test courtesy Rob Managan. +""" + +import TestSCons +import os + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +multibib = os.system('kpsewhich multibib.sty') +if not multibib==0: + test.skip_test("multibib.sty not installed; skipping test(s).\n") + +test.subdir(['src']) + + +test.write(['SConstruct'], """\ +import os + +env = Environment() + +DVI('multibib.tex') +""") + + +test.write(['lit.bib'],r""" +@book{Knuth:1991, author = {Knuth, Donald E.}, title = {The TEX book}, publisher = {Addison-Wesley, Reading, Massachusetts}, year = {1991}} +@book{Lamport:1994, author = {Lamport, Leslie}, title = {LATEX: A Document Preparation System}, publisher = {Addison-Wesley, Reading, Massachusetts, 2 edition}, year = {1994} } +@book{Adobe:1985, author = {Adobe System Incorporated}, title = {Postscript Language Tutorial and Cookbook}, publisher = {Addison-Wesley, Reading, Massachusetts}, year = {1985}} + +""") + +test.write(['multibib.tex'],r""" +\documentclass{article} +\usepackage{multibib} +\newcites{ltex}{\TeX\ and \LaTeX\ References} +\begin{document} +References to the \TeX book \citeltex{Knuth:1991} and to Lamport's \LaTeX\ book, which appears only in the references\nociteltex{Lamport:1994}. Finally a cite to a Postscript tutorial \cite{Adobe:1985}. +\bibliographystyleltex{alpha} +\bibliographyltex{lit} +\renewcommand{\refname}{Postscript References} +\bibliographystyle{plain} +\bibliography{lit} +\end{document} +""") + + +test.run(arguments = '', stderr=None) + + +# All (?) the files we expect will get created in the docs directory +files = [ + 'ltex.aux', + 'ltex.bbl', + 'ltex.blg', + 'multibib.aux', + 'multibib.bbl', + 'multibib.blg', + 'multibib.fls', + 'multibib.log', + 'multibib.dvi', +] + +for f in files: + test.must_exist([ f]) + +#test.must_not_exist(['docs/Fig1.pdf',]) + +test.pass_test() diff --git a/test/TEX/multiple_include.py b/test/TEX/multiple_include.py new file mode 100644 index 000000000..0480d45bd --- /dev/null +++ b/test/TEX/multiple_include.py @@ -0,0 +1,238 @@ +#!/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 creation of a fully-featured TeX document (with bibliography +and index) in a variant_dir. + +Test courtesy Rob Managan. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +epstopdf = test.where_is('epstopdf') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +if not epstopdf: + test.skip_test("Could not find 'epstopdf'; skipping test.\n") + +test.subdir(['docs']) + + +test.write(['SConstruct'], """\ +import os + +env = Environment() + +env.PDF('Fig1.ps') +test = env.PDF(source='test.tex') +""") + + +test.write(['Fig1.ps'], """\ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: Fig1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Apr 25 09:56:11 2006 +%%For: managan@mangrove.llnl.gov (Rob Managan) +%%BoundingBox: 0 0 98 98 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def + +end +save +newpath 0 98 moveto 0 0 lineto 98 0 lineto 98 98 lineto closepath clip newpath +-24.9 108.2 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/sc {scale} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/tr {translate} bind def + /DrawEllipse { + /endangle exch def + /startangle exch def + /yrad exch def + /xrad exch def + /y exch def + /x exch def + /savematrix mtrx currentmatrix def + x y tr xrad yrad sc 0 0 1 startangle endangle arc + closepath + savematrix setmatrix + } def + +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit + 0.06299 0.06299 sc +% +% Fig objects follow +% +7.500 slw +% Ellipse +n 1170 945 766 766 0 360 DrawEllipse gs col0 s gr + +$F2psEnd +rs +""") + + +test.write(['Fig1.tex'], +r"""\begin{picture}(0,0)% +\includegraphics{Fig1}% +\end{picture}% +\setlength{\unitlength}{4144sp}% +% +\begingroup\makeatletter\ifx\SetFigFont\undefined% +\gdef\SetFigFont#1#2#3#4#5{% + \reset@font\fontsize{#1}{#2pt}% + \fontfamily{#3}\fontseries{#4}\fontshape{#5}% + \selectfont}% +\fi\endgroup% +\begin{picture}(1548,1546)(397,-879) +\put(856,-196){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{\rmdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}center $r_0$}% +}}} +\end{picture} +""") + + +test.write(['test.tex'], +r"""\documentclass{report} + +\usepackage{graphicx} +\usepackage{epsfig,color} % for .tex version of figures if we go that way + +\usepackage{makeidx} +\makeindex + +\begin{document} + +\title{Report Title} + +\author{A. N. Author} + +\maketitle + +\begin{abstract} +there is no abstract +\end{abstract} + +\tableofcontents +\listoffigures + +\chapter{Introduction} + +The introduction is short. + +\index{Acknowledgements} + +\section{Acknowledgements} + +The Acknowledgements are shown as well. + +\index{Getting the Report} + +\input{getReport} + +\end{document} +""") + +test.write(['getReport.tex'], +r""" +To get a hard copy of this report call me. + +\begin{figure}[htbp] +\begin{center} +\input{Fig1.tex} % testing figure variant that uses TeX labeling +\caption{Zone and Node indexing} +\label{fig1} +\end{center} +\end{figure} + +All done now. + +%\bibliographystyle{unsrt} +%\bibliography{test} +\newpage + +\printindex +""") + +# makeindex will write status messages to stderr (grrr...), so ignore it. +test.run(arguments = '.', stderr=None) + + +# All (?) the files we expect will get created in the variant_dir +# (mybuild/docs) and not in the srcdir (docs). +files = [ + 'test.aux', + 'test.idx', + 'test.ilg', + 'test.ind', + 'test.lof', + 'test.log', + 'test.pdf', + 'test.toc', + 'Fig1.pdf' +] + +for f in files: + test.must_exist([ f]) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/multiple_include_subdir.py b/test/TEX/multiple_include_subdir.py new file mode 100644 index 000000000..ade471350 --- /dev/null +++ b/test/TEX/multiple_include_subdir.py @@ -0,0 +1,238 @@ +#!/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 creation of a Tex document with nested includes in a +subdir that needs to create a fig.pdf. + +Test courtesy Rob Managan. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +epstopdf = test.where_is('epstopdf') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +if not epstopdf: + test.skip_test("Could not find 'epstopdf'; skipping test.\n") + +test.subdir(['docs']) + + +test.write(['SConstruct'], """\ +import os + +env = Environment() + +env.PDF('docs/Fig1.eps') +test = env.PDF(source='docs/test.tex') +""") + + +test.write(['docs','Fig1.eps'], """\ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: Fig1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Apr 25 09:56:11 2006 +%%For: managan@mangrove.llnl.gov (Rob Managan) +%%BoundingBox: 0 0 98 98 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def + +end +save +newpath 0 98 moveto 0 0 lineto 98 0 lineto 98 98 lineto closepath clip newpath +-24.9 108.2 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/sc {scale} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/tr {translate} bind def + /DrawEllipse { + /endangle exch def + /startangle exch def + /yrad exch def + /xrad exch def + /y exch def + /x exch def + /savematrix mtrx currentmatrix def + x y tr xrad yrad sc 0 0 1 startangle endangle arc + closepath + savematrix setmatrix + } def + +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit + 0.06299 0.06299 sc +% +% Fig objects follow +% +7.500 slw +% Ellipse +n 1170 945 766 766 0 360 DrawEllipse gs col0 s gr + +$F2psEnd +rs +""") + + +test.write(['docs','Fig1.tex'], +r"""\begin{picture}(0,0)% +\includegraphics{Fig1}% +\end{picture}% +\setlength{\unitlength}{4144sp}% +% +\begingroup\makeatletter\ifx\SetFigFont\undefined% +\gdef\SetFigFont#1#2#3#4#5{% + \reset@font\fontsize{#1}{#2pt}% + \fontfamily{#3}\fontseries{#4}\fontshape{#5}% + \selectfont}% +\fi\endgroup% +\begin{picture}(1548,1546)(397,-879) +\put(856,-196){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{\rmdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}center $r_0$}% +}}} +\end{picture} +""") + + +test.write(['docs','test.tex'], +r"""\documentclass{report} + +\usepackage{graphicx} +\usepackage{epsfig,color} % for .tex version of figures if we go that way + +\usepackage{makeidx} +\makeindex + +\begin{document} + +\title{Report Title} + +\author{A. N. Author} + +\maketitle + +\begin{abstract} +there is no abstract +\end{abstract} + +\tableofcontents +\listoffigures + +\chapter{Introduction} + +The introduction is short. + +\index{Acknowledgements} + +\section{Acknowledgements} + +The Acknowledgements are shown as well. + +\index{Getting the Report} + +\input{getReport} + +\end{document} +""") + +test.write(['docs','getReport.tex'], +r""" +To get a hard copy of this report call me. + +\begin{figure}[htbp] +\begin{center} +\input{Fig1.tex} % testing figure variant that uses TeX labeling +\caption{Zone and Node indexing} +\label{fig1} +\end{center} +\end{figure} + +All done now. + +%\bibliographystyle{unsrt} +%\bibliography{test} +\newpage + +\printindex +""") + +# makeindex will write status messages to stderr (grrr...), so ignore it. +test.run(arguments = '.', stderr=None) + + +# All (?) the files we expect will get created in the subdir +# (mybuild/docs) and not in the srcdir (docs). +files = [ + 'docs/test.aux', + 'docs/test.idx', + 'docs/test.ilg', + 'docs/test.ind', + 'docs/test.lof', + 'docs/test.log', + 'docs/test.pdf', + 'docs/test.toc', + 'docs/Fig1.pdf' +] + +for f in files: + test.must_exist([ f]) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/newglossary.py b/test/TEX/newglossary.py new file mode 100644 index 000000000..12c68a73a --- /dev/null +++ b/test/TEX/newglossary.py @@ -0,0 +1,158 @@ +#!/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__" + +""" +Validate that use of \newglossary in TeX source files causes SCons to +be aware of the necessary created glossary files. + +Test configuration contributed by Robert Managan. +""" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test("Could not find latex; skipping test(s).\n") + +gloss = os.system('kpsewhich glossaries.sty') +if not gloss==0: + test.skip_test("glossaries.sty not installed; skipping test(s).\n") + +test.write('SConstruct', """\ +import os +env = Environment() +env.PDF('newglossary', 'newglossary.tex') +""") + +test.write('newglossary.tex', r""" +\documentclass{report} + +% for glossary +\newlength{\symcol} +\newlength{\symw} +\newcommand{\symtab}[1]{\setlength{\symcol}{1.3cm}\settowidth{\symw}{\ensuremath{#1}}\advance\symcol by -\symw\hspace{\symcol}} +\newcommand{\newsym}[5]{\newglossaryentry{#1}{name=\ensuremath{#2},description={\symtab{#2}{#4}},parent={#5},sort={#3}}} +\newcommand{\newacronymf}[3]{\newglossaryentry{#1}{name={#2},description={#3},first={#2}}} + +\usepackage[acronym]{glossaries} +\newglossary[symlog]{symbol}{symi}{symo}{Symbols} +\newglossaryentry{nix}{ + name={Nix}, + description={Version 5} +} +\newglossary[deflog]{definition}{defi}{defo}{Definitions} +\newglossaryentry{defPower}{name=Ddyn,type={definition},description={def of 1 dynamic power consumption},sort={DP}} + +\newacronym{gnu}{GNU}{GNU's Not UNIX} +\makeglossaries +\glstoctrue +%\loadglsentries[\acronymtype]{chapters/acronyms} +\loadglsentries[symbol]{symbols} +%\loadglsentries[definition]{defns} + + +\begin{document} + +Here is a symbol: \gls{dynPower} and a glossary entry \gls{mel} + +Acronyms \gls{gnu} and glossary entries \gls{nix}. + +a definition \gls{defPower} + +\glossarystyle{index} +\printglossary[type=symbol] +\printglossary[type=acronym] +\printglossary[type=main] +\printglossary[type=definition] +\glossarystyle{super} + +\end{document}""") + + +test.write('symbols.tex', r""" +\newglossaryentry{mel}{name={Microelectronic Fundamentals},description={\nopostdesc},sort=d} +\newsym{dynPower}{P_{dyn}}{P}{Dynamic power consumption}{mel} + +%\newcommand{\newsym}[5]{\newglossaryentry{#1}{name=\ensuremath{#2},description={\symtab{#2}{#4}},parent={#5},sort={#3}}} +""") + +test.run(arguments = '.', stderr=None) + +test.must_exist(test.workpath('newglossary.acn')) +test.must_exist(test.workpath('newglossary.acr')) +test.must_exist(test.workpath('newglossary.alg')) +test.must_exist(test.workpath('newglossary.aux')) +test.must_exist(test.workpath('newglossary.defi')) +test.must_exist(test.workpath('newglossary.deflog')) +test.must_exist(test.workpath('newglossary.defo')) +test.must_exist(test.workpath('newglossary.fls')) +test.must_exist(test.workpath('newglossary.glg')) +test.must_exist(test.workpath('newglossary.glo')) +test.must_exist(test.workpath('newglossary.gls')) +test.must_exist(test.workpath('newglossary.ist')) +test.must_exist(test.workpath('newglossary.log')) +test.must_exist(test.workpath('newglossary.pdf')) +test.must_exist(test.workpath('newglossary.symi')) +test.must_exist(test.workpath('newglossary.symlog')) +test.must_exist(test.workpath('newglossary.symo')) + +test.run(arguments = '-c .') + +x = "Could not remove 'newglossary.aux': No such file or directory" +test.must_not_contain_any_line(test.stdout(), [x]) + +test.must_not_exist(test.workpath('newglossary.acn')) +test.must_not_exist(test.workpath('newglossary.acr')) +test.must_not_exist(test.workpath('newglossary.alg')) +test.must_not_exist(test.workpath('newglossary.defi')) +test.must_not_exist(test.workpath('newglossary.deflog')) +test.must_not_exist(test.workpath('newglossary.defo')) +test.must_not_exist(test.workpath('newglossary.aux')) +test.must_not_exist(test.workpath('newglossary.fls')) +test.must_not_exist(test.workpath('newglossary.glg')) +test.must_not_exist(test.workpath('newglossary.glo')) +test.must_not_exist(test.workpath('newglossary.gls')) +test.must_not_exist(test.workpath('newglossary.ist')) +test.must_not_exist(test.workpath('newglossary.log')) +test.must_not_exist(test.workpath('newglossary.pdf')) +test.must_not_exist(test.workpath('newglossary.symi')) +test.must_not_exist(test.workpath('newglossary.symlog')) +test.must_not_exist(test.workpath('newglossary.symo')) + +test.pass_test() + + + + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/nomencl.py b/test/TEX/nomencl.py new file mode 100644 index 000000000..1c121c023 --- /dev/null +++ b/test/TEX/nomencl.py @@ -0,0 +1,112 @@ +#!/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__" + +""" +Validate that use of \nomencl in TeX source files causes SCons to +be aware of the necessary created glossary files. + +Test configuration contributed by Robert Managan. +""" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test("Could not find latex; skipping test(s).\n") + +nomencl = os.system('kpsewhich nomencl.sty') +if not nomencl==0: + test.skip_test("nomencl.sty not installed; skipping test(s).\n") + +test.write('SConstruct', """\ +import os +env = Environment(tools = ['pdftex']) +env.PDF('nomencl', 'nomencl.tex') +""") + +test.write('nomencl.tex', r""" +\documentclass{article} + +\usepackage[refpage]{nomencl} + +%handle old version of nomencl.sty +\ifdefined\makenomenclature +\makenomenclature +\else +\makeglossary +\fi + +\begin{document} + +A nomenclature entry \nomenclature{gnu}{an animal or software group} +and another\nomenclature{nix}{not sure}. + +%handle old version of nomencl.sty +\ifdefined\printnomenclature +\printnomenclature +\else +\printglossary +\fi +\end{document} +""") + +test.run(arguments = '.', stderr=None) + +test.must_exist(test.workpath('nomencl.aux')) +test.must_exist(test.workpath('nomencl.fls')) +#test.must_exist(test.workpath('nomencl.nlg')) # old version of nomencl.sty generates .glg, .glo, and .gls +#test.must_exist(test.workpath('nomencl.nlo')) +#test.must_exist(test.workpath('nomencl.nls')) +test.must_exist(test.workpath('nomencl.log')) +test.must_exist(test.workpath('nomencl.pdf')) + +test.run(arguments = '-c .') + +x = "Could not remove 'nomencl.aux': No such file or directory" +test.must_not_contain_any_line(test.stdout(), [x]) + +test.must_not_exist(test.workpath('nomencl.aux')) +test.must_not_exist(test.workpath('nomencl.fls')) +#test.must_not_exist(test.workpath('nomencl.nlg')) +#test.must_not_exist(test.workpath('nomencl.nlo')) +#test.must_not_exist(test.workpath('nomencl.nls')) +test.must_not_exist(test.workpath('nomencl.log')) +test.must_not_exist(test.workpath('nomencl.pdf')) + +test.pass_test() + + + + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/rename_result.py b/test/TEX/rename_result.py new file mode 100644 index 000000000..f061e2620 --- /dev/null +++ b/test/TEX/rename_result.py @@ -0,0 +1,79 @@ +#!/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__" + +""" +Validate that we can rename the output from latex to the +target name provided by the user. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test('could not find latex; skipping test\n') + +test.write('SConstruct', """ +import os +foo = Environment() +foo['TEXINPUTS'] = [ 'subdir', os.environ.get('TEXINPUTS', '') ] +foo.DVI(target = 'foobar.dvi', source = 'foo.ltx') +foo.PDF(target = 'bar.xyz', source = 'bar.ltx') +""" % locals()) + +test.write('foo.ltx', r""" +\documentclass{letter} +\begin{document} +This is the foo.ltx file. +\end{document} +""") + +test.write('bar.ltx', r""" +\documentclass{letter} +\begin{document} +This is the bar.ltx file. +\end{document} +""") + +test.run(arguments = '.', stderr = None) + +test.must_exist('foobar.dvi') +test.must_not_exist('foo.dvi') + +test.must_exist('bar.xyz') +test.must_not_exist('bar.pdf') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/subdir-as-include.py b/test/TEX/subdir-as-include.py new file mode 100755 index 000000000..8b897cad6 --- /dev/null +++ b/test/TEX/subdir-as-include.py @@ -0,0 +1,78 @@ +#!/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__" + +""" +This is an obscure test case. When + 1) a file without a suffix is included in a TeX build and + 2) there is a directory with the same name as that file, +verify that a TypeError is not thrown upon trying to recursively scan +the contents of includes. The TypeError indicates that the directory +with the same name was trying to be scanned as the include file, which +it clearly is not. +""" + +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +test.subdir('inc') + +test.write('SConstruct', """\ +import os + +env = Environment() +env.DVI('root.tex') +""") + +test.write('root.tex', +r"""\documentclass{article} +\begin{document} +\input{inc} +\end{document} +""") + +test.write('inc.tex', +r"""Hello World. +""") + +test.run(arguments = '.') + +test.must_exist(test.workpath('root.dvi')) +test.must_exist(test.workpath('root.log')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/subdir-input.py b/test/TEX/subdir-input.py new file mode 100644 index 000000000..8c7febe1e --- /dev/null +++ b/test/TEX/subdir-input.py @@ -0,0 +1,96 @@ +#!/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__" + +""" +Verify that we execute TeX in a subdirectory (if that's where the document +resides) by checking that all the auxiliary files get created there and +not in the top-level directory. + +Also check that we find files + +Test case courtesy Joel B. Mohler. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +pdflatex = test.where_is('pdflatex') +if not pdflatex: + test.skip_test("Could not find 'pdflatex'; skipping test.\n") + +test.subdir('sub') + +test.write('SConstruct', """\ +import os +env = Environment(TOOLS = ['tex', 'pdftex']) +env.PDF( 'sub/x.tex' ) +env.DVI( 'sub/x.tex' ) +""") + +test.write(['sub', 'x.tex'], +r"""\documentclass{article} +\begin{document} +Hi there. +\input{y} +\end{document} +""") + +test.write(['sub', 'y.tex'], """\ +Sub-document 1 +""") + +test.run(arguments = '.') + +test.must_exist(['sub', 'x.aux']) +test.must_exist(['sub', 'x.dvi']) +test.must_exist(['sub', 'x.log']) +test.must_exist(['sub', 'x.pdf']) + +test.must_not_exist('x.aux') +test.must_not_exist('x.dvi') +test.must_not_exist('x.log') +test.must_not_exist('x.pdf') + +test.up_to_date(arguments = '.') + +test.write(['sub', 'y.tex'], """\ +Sub-document 2 +""") + +test.not_up_to_date(arguments = '.') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/subdir_variantdir_include.py b/test/TEX/subdir_variantdir_include.py new file mode 100644 index 000000000..7af37334f --- /dev/null +++ b/test/TEX/subdir_variantdir_include.py @@ -0,0 +1,141 @@ +#!/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__" + +""" +Verify that we execute TeX in a subdirectory (if that's where the document +resides) by checking that all the auxiliary files get created there and +not in the top-level directory. Test this when variantDir is used + +Also check that we find files + +Test case courtesy Joel B. Mohler. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +#test.verbose_set(2) + +latex = test.where_is('latex') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +pdflatex = test.where_is('pdflatex') +if not pdflatex: + test.skip_test("Could not find 'pdflatex'; skipping test.\n") + +test.subdir('docs') +test.subdir(['docs','sub']) +test.subdir(['docs','sub','sub2']) + +test.write('SConstruct', """\ +import os +env = Environment(TOOLS = ['tex', 'pdftex']) + +env.VariantDir('build', 'docs',duplicate=0) +env.SConscript('build/SConscript', exports = ['env']) +""") + +test.write(['docs','SConscript'], """\ +Import('env') + +env.PDF( 'sub/x.tex' ) +env.DVI( 'sub/x.tex' ) +""") + +test.write(['docs','sub', 'x.tex'], +r"""\documentclass{article} +\usepackage{makeidx} +\makeindex +\begin{document} +Hi there. +\index{info} +\include{sub2/y} +\printindex{} +\end{document} +""") + +test.write(['docs','sub','sub2','y.tex'], """\ +Sub-document 1 +""") + +#test.run(arguments = '.') +test.run(arguments = '.', stderr=None, stdout=None) + +test.must_exist(['build', 'sub', 'x.aux']) +test.must_exist(['build', 'sub', 'x.dvi']) +test.must_exist(['build', 'sub', 'x.fls']) +test.must_exist(['build', 'sub', 'x.idx']) +test.must_exist(['build', 'sub', 'x.ilg']) +test.must_exist(['build', 'sub', 'x.ind']) +test.must_exist(['build', 'sub', 'x.log']) +test.must_exist(['build', 'sub', 'x.pdf']) + +test.must_exist(['build', 'sub', 'sub2', 'y.aux']) + +test.must_not_exist('x.aux') +test.must_not_exist('x.dvi') +test.must_not_exist('x.idx') +test.must_not_exist('x.ilg') +test.must_not_exist('x.ind') +test.must_not_exist('x.log') +test.must_not_exist('x.pdf') + +test.must_not_exist(['docs', 'x.aux']) +test.must_not_exist(['docs', 'x.dvi']) +test.must_not_exist(['docs', 'x.idx']) +test.must_not_exist(['docs', 'x.ilg']) +test.must_not_exist(['docs', 'x.ind']) +test.must_not_exist(['docs', 'x.log']) +test.must_not_exist(['docs', 'x.pdf']) + +test.must_not_exist(['docs', 'sub', 'x.aux']) +test.must_not_exist(['docs', 'sub', 'x.dvi']) +test.must_not_exist(['docs', 'sub', 'x.idx']) +test.must_not_exist(['docs', 'sub', 'x.ilg']) +test.must_not_exist(['docs', 'sub', 'x.ind']) +test.must_not_exist(['docs', 'sub', 'x.log']) +test.must_not_exist(['docs', 'sub', 'x.pdf']) + +test.must_not_exist(['docs', 'sub', 'sub2', 'y.aux']) + +test.up_to_date(arguments = '.', stderr=None, stdout=None) + +test.write(['docs','sub', 'sub2', 'y.tex'], """\ +Sub-document 2 +""") + +test.not_up_to_date(arguments = '.') +#test.up_to_date(arguments = '.', stderr=None, stdout=None) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/subdir_variantdir_include2.py b/test/TEX/subdir_variantdir_include2.py new file mode 100644 index 000000000..4dbc4d259 --- /dev/null +++ b/test/TEX/subdir_variantdir_include2.py @@ -0,0 +1,146 @@ +#!/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__" + +""" +Verify that we execute TeX in a subdirectory (if that's where the document +resides) by checking that all the auxiliary files get created there and +not in the top-level directory. Test this when variantDir is used +Add use of \include and \includegraphics from within the included file + +Also check that we find files + +Test case courtesy Joel B. Mohler. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +#test.verbose_set(2) + +latex = test.where_is('latex') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +pdflatex = test.where_is('pdflatex') +if not pdflatex: + test.skip_test("Could not find 'pdflatex'; skipping test.\n") + +test.subdir('docs') +test.subdir(['docs','content']) +test.subdir(['docs','fig']) + +test.write('SConstruct', """\ +import os +env = Environment(TOOLS = ['tex', 'pdftex']) + +env.VariantDir('build', 'docs', duplicate=0) +pdf = env.PDF('build/main.tex') +""") + +test.write(['docs','main.tex'], +r"""\documentclass{article} +\usepackage{makeidx} +\makeindex +\begin{document} +Hi there. +\index{info} +\include{content/chapter} +\printindex{} +\end{document} +""") + +test.write(['docs','content','chapter.tex'], """\ +Sub-document 1 +\input{content/subchap} + +""") + +test.write(['docs','content','subchap.tex'], """\ +Sub-chapter 2 + +""") + +#test.run(arguments = '.') +#test.run(arguments = '.', stderr=None, stdout=None) + +# next line tests that side effect nodes get disambiguated +# and their directories created in a variantDir before +# the builder tries to populate them and fails +test.run(arguments = 'build/main.pdf', stderr=None, stdout=None) + +test.must_exist(['build', 'main.aux']) +test.must_exist(['build', 'main.fls']) +test.must_exist(['build', 'main.idx']) +test.must_exist(['build', 'main.ilg']) +test.must_exist(['build', 'main.ind']) +test.must_exist(['build', 'main.log']) +test.must_exist(['build', 'main.pdf']) + +test.must_exist(['build', 'content', 'chapter.aux']) + +test.must_not_exist('main.aux') +test.must_not_exist('main.dvi') +test.must_not_exist('main.idx') +test.must_not_exist('main.ilg') +test.must_not_exist('main.ind') +test.must_not_exist('main.log') +test.must_not_exist('main.pdf') + +test.must_not_exist(['docs', 'main.aux']) +test.must_not_exist(['docs', 'main.dvi']) +test.must_not_exist(['docs', 'main.idx']) +test.must_not_exist(['docs', 'main.ilg']) +test.must_not_exist(['docs', 'main.ind']) +test.must_not_exist(['docs', 'main.log']) +test.must_not_exist(['docs', 'main.pdf']) + +test.must_not_exist(['docs', 'content', 'main.aux']) +test.must_not_exist(['docs', 'content', 'main.dvi']) +test.must_not_exist(['docs', 'content', 'main.idx']) +test.must_not_exist(['docs', 'content', 'main.ilg']) +test.must_not_exist(['docs', 'content', 'main.ind']) +test.must_not_exist(['docs', 'content', 'main.log']) +test.must_not_exist(['docs', 'content', 'main.pdf']) + +test.must_not_exist(['docs', 'content', 'chapter.aux']) + +test.up_to_date(arguments = '.', stderr=None, stdout=None) + +test.write(['docs','content', 'subchap.tex'], """\ +Sub-document 2a +""") + +test.not_up_to_date(arguments = '.') +#test.up_to_date(arguments = '.', stderr=None, stdout=None) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/subdir_variantdir_input.py b/test/TEX/subdir_variantdir_input.py new file mode 100644 index 000000000..efc069267 --- /dev/null +++ b/test/TEX/subdir_variantdir_input.py @@ -0,0 +1,135 @@ +#!/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__" + +""" +Verify that we execute TeX in a subdirectory (if that's where the document +resides) by checking that all the auxiliary files get created there and +not in the top-level directory. Test this when variantDir is used + +Also check that we find files + +Test case courtesy Joel B. Mohler. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +#test.verbose_set(2) + +latex = test.where_is('latex') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +pdflatex = test.where_is('pdflatex') +if not pdflatex: + test.skip_test("Could not find 'pdflatex'; skipping test.\n") + +test.subdir('docs') +test.subdir(['docs','sub']) + +test.write('SConstruct', """\ +import os +env = Environment(TOOLS = ['tex', 'pdftex']) + +env.VariantDir('build', 'docs',duplicate=0) +env.SConscript('build/SConscript', exports = ['env']) +""") + +test.write(['docs','SConscript'], """\ +Import('env') + +env.PDF( 'sub/x.tex' ) +env.DVI( 'sub/x.tex' ) +""") + +test.write(['docs','sub', 'x.tex'], +r"""\documentclass{article} +\usepackage{makeidx} +\makeindex +\begin{document} +Hi there. +\index{info} +\input{y} +\printindex{} +\end{document} +""") + +test.write(['docs','sub', 'y.tex'], """\ +Sub-document 1 +""") + +#test.run(arguments = '.') +test.run(arguments = '.', stderr=None, stdout=None) + +test.must_exist(['build', 'sub', 'x.aux']) +test.must_exist(['build', 'sub', 'x.dvi']) +test.must_exist(['build', 'sub', 'x.idx']) +test.must_exist(['build', 'sub', 'x.ilg']) +test.must_exist(['build', 'sub', 'x.ind']) +test.must_exist(['build', 'sub', 'x.log']) +test.must_exist(['build', 'sub', 'x.pdf']) + +test.must_not_exist('x.aux') +test.must_not_exist('x.dvi') +test.must_not_exist('x.idx') +test.must_not_exist('x.ilg') +test.must_not_exist('x.ind') +test.must_not_exist('x.log') +test.must_not_exist('x.pdf') + +test.must_not_exist(['docs', 'x.aux']) +test.must_not_exist(['docs', 'x.dvi']) +test.must_not_exist(['docs', 'x.idx']) +test.must_not_exist(['docs', 'x.ilg']) +test.must_not_exist(['docs', 'x.ind']) +test.must_not_exist(['docs', 'x.log']) +test.must_not_exist(['docs', 'x.pdf']) + +test.must_not_exist(['docs', 'sub', 'x.aux']) +test.must_not_exist(['docs', 'sub', 'x.dvi']) +test.must_not_exist(['docs', 'sub', 'x.idx']) +test.must_not_exist(['docs', 'sub', 'x.ilg']) +test.must_not_exist(['docs', 'sub', 'x.ind']) +test.must_not_exist(['docs', 'sub', 'x.log']) +test.must_not_exist(['docs', 'sub', 'x.pdf']) + +test.up_to_date(arguments = '.', stderr=None, stdout=None) + +test.write(['docs','sub', 'y.tex'], """\ +Sub-document 2 +""") + +test.not_up_to_date(arguments = '.') +#test.up_to_date(arguments = '.', stderr=None, stdout=None) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/synctex.py b/test/TEX/synctex.py new file mode 100644 index 000000000..867063a8c --- /dev/null +++ b/test/TEX/synctex.py @@ -0,0 +1,89 @@ +#!/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__" + +""" +Validate that use of -synctex command option causes SCons to +be aware of the created synctex.gz file. + +Test configuration contributed by Robert Managan. +""" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test("Could not find latex; skipping test(s).\n") + +test.write('SConstruct', """\ +import os +env = Environment() +env.AppendUnique(PDFLATEXFLAGS = '-synctex=1') +env.PDF('mysync', 'mysync.tex') +""") + +test.write('mysync.tex', r""" +\documentclass{article} + +\begin{document} + +This is a simple test of the synctex.gz file. + +\end{document} +""") + +test.run(arguments = '.', stderr=None) + +test.must_exist(test.workpath('mysync.synctex.gz')) +test.must_exist(test.workpath('mysync.aux')) +test.must_exist(test.workpath('mysync.fls')) +test.must_exist(test.workpath('mysync.log')) +test.must_exist(test.workpath('mysync.pdf')) + +test.run(arguments = '-c .') + +x = "Could not remove 'mysync.aux': No such file or directory" +test.must_not_contain_any_line(test.stdout(), [x]) + +test.must_not_exist(test.workpath('mysync.synctex.gz')) +test.must_not_exist(test.workpath('mysync.aux')) +test.must_not_exist(test.workpath('mysync.fls')) +test.must_not_exist(test.workpath('mysync.log')) +test.must_not_exist(test.workpath('mysync.pdf')) + +test.pass_test() + + + + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/usepackage.py b/test/TEX/usepackage.py new file mode 100644 index 000000000..637956a1a --- /dev/null +++ b/test/TEX/usepackage.py @@ -0,0 +1,75 @@ +#!/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__" + +""" +Validate that we can set the LATEX string to our own utility, that +the produced .dvi, .aux and .log files get removed by the -c option, +and that we can use this to wrap calls to the real latex utility. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test('could not find latex; skipping test\n') + +test.write('SConstruct', """ +import os +foo = Environment() +foo['TEXINPUTS'] = [ 'subdir', os.environ.get('TEXINPUTS', '') ] +foo.DVI(target = 'foo.dvi', source = 'foo.ltx') +""" % locals()) + +test.write('foo.ltx', r""" +\documentclass{letter} +\usepackage{bar} +\begin{document} +This is the foo.ltx file. +\end{document} +""") + +test.write('bar.sty', "\n") + +test.run(arguments = 'foo.dvi', stderr = None) + +test.write('bar.sty', "\n\n\n") + +test.not_up_to_date(arguments = 'foo.dvi', stderr = None) + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/variant_dir.py b/test/TEX/variant_dir.py new file mode 100644 index 000000000..99c35236e --- /dev/null +++ b/test/TEX/variant_dir.py @@ -0,0 +1,266 @@ +#!/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 creation of a fully-featured TeX document (with bibliography +and index) in a variant_dir. + +Test courtesy Rob Managan. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +if not latex: + test.skip_test("Could not find 'latex'; skipping test.\n") + +test.subdir(['docs']) + + +test.write(['SConstruct'], """\ +import os + +env = Environment(TOOLS = ['tex', 'latex', 'dvipdf']) +Export(['env']) + +SConscript(os.path.join('docs', 'SConscript'), + variant_dir=os.path.join('mybuild','docs'), + duplicate=1) +""") + + +test.write(['docs', 'SConscript'], """\ +Import('env') + +test_dvi = env.DVI(source='test.tex') +testpdf = env.PDF(source=test_dvi) +""") + + +test.write(['docs', 'Fig1.ps'], """\ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: Fig1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Apr 25 09:56:11 2006 +%%For: managan@mangrove.llnl.gov (Rob Managan) +%%BoundingBox: 0 0 98 98 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def + +end +save +newpath 0 98 moveto 0 0 lineto 98 0 lineto 98 98 lineto closepath clip newpath +-24.9 108.2 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/sc {scale} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/tr {translate} bind def + /DrawEllipse { + /endangle exch def + /startangle exch def + /yrad exch def + /xrad exch def + /y exch def + /x exch def + /savematrix mtrx currentmatrix def + x y tr xrad yrad sc 0 0 1 startangle endangle arc + closepath + savematrix setmatrix + } def + +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit + 0.06299 0.06299 sc +% +% Fig objects follow +% +7.500 slw +% Ellipse +n 1170 945 766 766 0 360 DrawEllipse gs col0 s gr + +$F2psEnd +rs +""") + + +test.write(['docs', 'Fig1.tex'], +r"""\begin{picture}(0,0)% +\includegraphics{Fig1.ps}% +\end{picture}% +\setlength{\unitlength}{4144sp}% +% +\begingroup\makeatletter\ifx\SetFigFont\undefined% +\gdef\SetFigFont#1#2#3#4#5{% + \reset@font\fontsize{#1}{#2pt}% + \fontfamily{#3}\fontseries{#4}\fontshape{#5}% + \selectfont}% +\fi\endgroup% +\begin{picture}(1548,1546)(397,-879) +\put(856,-196){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{\rmdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}center $r_0$}% +}}} +\end{picture} +""") + + +test.write(['docs', 'test.bib'], """\ +%% This BibTeX bibliography file was created using BibDesk. +%% http://bibdesk.sourceforge.net/ + + +%% Created for Rob Managan at 2006-11-15 12:53:16 -0800 + + +%% Saved with string encoding Western (ASCII) + + + +@techreport{Managan:2006fk, + Author = {Robert Managan}, + Date-Added = {2006-11-15 12:51:30 -0800}, + Date-Modified = {2006-11-15 12:52:35 -0800}, + Institution = {none}, + Month = {November}, + Title = {A Test Paper}, + Year = {2006}} +""") + + +test.write(['docs', 'test.tex'], +r"""\documentclass{report} + +\usepackage{graphicx} +\usepackage{epsfig,color} % for .tex version of figures if we go that way + +\usepackage{makeidx} +\makeindex + +\begin{document} + +\title{Report Title} + +\author{A. N. Author} + +\maketitle + +\begin{abstract} +there is no abstract +\end{abstract} + +\tableofcontents +\listoffigures + +\chapter{Introduction} + +The introduction is short. + +\index{Acknowledgements} + +\section{Acknowledgements} + +The Acknowledgements are show as well \cite{Managan:2006fk}. + +\index{Getting the Report} + +To get a hard copy of this report call me. + +\begin{figure}[htbp] +\begin{center} +\input{Fig1.tex} % testing figure variant that uses TeX labeling +\caption{Zone and Node indexing} +\label{fig1} +\end{center} +\end{figure} + +All done now. + +\bibliographystyle{unsrt} +\bibliography{test} +\newpage + +\printindex + +\end{document} +""") + + +# makeindex will write status messages to stderr (grrr...), so ignore it. +test.run(arguments = '.', stderr=None) + + +# All (?) the files we expect will get created in the variant_dir +# (mybuild/docs) and not in the srcdir (docs). +files = [ + 'test.aux', + 'test.bbl', + 'test.blg', + 'test.dvi', + 'test.idx', + 'test.ilg', + 'test.ind', + 'test.lof', + 'test.log', + 'test.pdf', + 'test.toc', +] + +for f in files: + test.must_exist(['mybuild', 'docs', f]) + test.must_not_exist(['docs', f]) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/variant_dir_bibunit.py b/test/TEX/variant_dir_bibunit.py new file mode 100644 index 000000000..ce2c24e26 --- /dev/null +++ b/test/TEX/variant_dir_bibunit.py @@ -0,0 +1,279 @@ +#!/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 creation of a fully-featured TeX document (with bibunit +driven bibliographies) in a variant_dir. + +Also test that the target can be named differently than what +Latex produces by default. + +Test courtesy Rob Managan. +""" + +import TestSCons +import os + +test = TestSCons.TestSCons() + +latex = test.where_is('pdflatex') +bibtex = test.where_is('bibtex') +if not latex or not bibtex: + test.skip_test("Could not find 'latex' or 'bibtex'; skipping test.\n") + +bibunits = os.system('kpsewhich bibunits.sty') +if not bibunits==0: + test.skip_test("bibunits.sty not installed; skipping test(s).\n") + +test.subdir(['src']) + + +test.write(['SConstruct'], """\ +import os + +env = Environment() +Export(['env']) + +env.SConscript(os.path.join('src', 'SConscript'), + variant_dir='build', + duplicate=0) +""") + + +test.write(['src', 'SConscript'], """\ +Import('env') + +env.PDF('units.tex') +""") + + +test.write(['src', 'units.tex'], +r""" +\documentclass{article} +\usepackage{bibunits} +\begin{document} +\begin{bibunit}[plain] +some text \cite{lamport:1994} more text more citations +2 +\putbib[units] +\end{bibunit} +some text between the units +\begin{bibunit}[abbrv] +some text \cite{gnu:1998} more text more citations 2 +\putbib[units] +\end{bibunit} + +some text between the units +\begin{bibunit}[abbrv] +some text \cite{gnu:1999} more text more citations 3 +\putbib[units] +\end{bibunit} + +some text between the units +\begin{bibunit}[abbrv] +some text \cite{gnu:1998} more text more citations 4 +\putbib[units] +\end{bibunit} + +some text between the units +\begin{bibunit}[abbrv] +some text \cite{gnu:2000} more text more citations 5 +\putbib[units] +\end{bibunit} + +some text between the units +\begin{bibunit}[abbrv] +some text \cite{gnu:1998} more text more citations 6 +\putbib[units] +\end{bibunit} + +some text between the units +\begin{bibunit}[abbrv] +some text \cite{gnu:2001} more text more citations 7 +\putbib[units] +\end{bibunit} + +some text between the units +\begin{bibunit}[abbrv] +some text more \cite{gnu:2002} text more citations 8 +\putbib[units] +\end{bibunit} + +some text between the units +\begin{bibunit}[abbrv] +some text more text more citations 9 +\putbib[units] +\end{bibunit} + +some text between the units +\begin{bibunit}[abbrv] +some text \cite{gnu:1998} more text more citations 10 +\putbib[units] +\end{bibunit} + +some text between the units +\begin{bibunit}[abbrv] +some text \cite{gnu:2003} more text more citations 11 +\putbib[units] +\end{bibunit} + + +after the last unit another ref \cite{gnu:1998} and then a second \cite{gnu:2003} +\bibliographystyle{unsrt} +\bibliography{units} +\end{document} +""") + + +test.write(['src', 'units.bib'], """\ +%% This BibTeX bibliography file was created using BibDesk. +%% http://bibdesk.sourceforge.net/ + +@techreport{gnu:1998, + Author = {A. N. Author}, + Date-Added = {2006-11-15 12:51:30 -0800}, + Date-Modified = {2006-11-15 12:52:35 -0800}, + Institution = {none}, + Month = {November}, + Title = {A Test Paper}, + Year = {1998}} +@techreport{gnu:1999, + Author = {A. N. Author}, + Date-Added = {2006-11-15 12:51:30 -0800}, + Date-Modified = {2006-11-15 12:52:35 -0800}, + Institution = {none}, + Month = {November}, + Title = {A Test Paper 1}, + Year = {1999}} +@techreport{gnu:2000, + Author = {A. N. Author}, + Date-Added = {2006-11-15 12:51:30 -0800}, + Date-Modified = {2006-11-15 12:52:35 -0800}, + Institution = {none}, + Month = {November}, + Title = {A Test Paper 2}, + Year = {2000}} +@techreport{gnu:2001, + Author = {A. N. Author}, + Date-Added = {2006-11-15 12:51:30 -0800}, + Date-Modified = {2006-11-15 12:52:35 -0800}, + Institution = {none}, + Month = {November}, + Title = {A Test Paper 3}, + Year = {2001}} +@techreport{gnu:2002, + Author = {A. N. Author}, + Date-Added = {2006-11-15 12:51:30 -0800}, + Date-Modified = {2006-11-15 12:52:35 -0800}, + Institution = {none}, + Month = {November}, + Title = {A Test Paper 4}, + Year = {2002}} +@techreport{gnu:2003, + Author = {A. N. Author}, + Date-Added = {2006-11-15 12:51:30 -0800}, + Date-Modified = {2006-11-15 12:52:35 -0800}, + Institution = {none}, + Month = {November}, + Title = {A Test Paper 5}, + Year = {2003}} +@techreport{lamport:1994, + Author = {A. N. Lamport}, + Date-Added = {2006-11-15 12:51:30 -0800}, + Date-Modified = {2006-11-15 12:52:35 -0800}, + Institution = {none}, + Month = {November}, + Title = {A Test Paper}, + Year = {1994}} +""") + + + +#test.run(arguments = '.', stderr=None) +test.run(arguments = '.') + + +# All (?) the files we expect will get created in the variant_dir +# (build/docs) and not in the srcdir (src). +files = [ +'bu.aux', +'bu1.aux', +'bu1.bbl', +'bu1.blg', +'bu10.aux', +'bu10.bbl', +'bu10.blg', +'bu11.aux', +'bu11.bbl', +'bu11.blg', +'bu2.aux', +'bu2.bbl', +'bu2.blg', +'bu3.aux', +'bu3.bbl', +'bu3.blg', +'bu4.aux', +'bu4.bbl', +'bu4.blg', +'bu5.aux', +'bu5.bbl', +'bu5.blg', +'bu6.aux', +'bu6.bbl', +'bu6.blg', +'bu7.aux', +'bu7.bbl', +'bu7.blg', +'bu8.aux', +'bu8.bbl', +'bu8.blg', +'bu9.aux', +'bu9.bbl', +'bu9.blg', +'units.aux', +'units.bbl', +'units.blg', +'units.fls', +'units.log', +'units.pdf', +] + +for f in files: + test.must_exist(['build', f]) + test.must_not_exist(['src', f]) + +test.run(arguments = '-c') + +for f in files: + test.must_not_exist(['build', f]) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/variant_dir_dup0.py b/test/TEX/variant_dir_dup0.py new file mode 100644 index 000000000..25205f8b5 --- /dev/null +++ b/test/TEX/variant_dir_dup0.py @@ -0,0 +1,335 @@ +#!/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 creation of a fully-featured TeX document (with bibliography +and index) in a variant_dir. + +Also test that the target can be named differently than what +Latex produces by default. + +Test courtesy Rob Managan. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +dvipdf = test.where_is('dvipdf') +makeindex = test.where_is('makeindex') +bibtex = test.where_is('bibtex') +if not latex or not makeindex or not bibtex or not dvipdf: + test.skip_test("Could not find 'latex', 'makeindex', 'bibtex', or dvipdf; skipping test.\n") + +test.subdir(['docs']) + + +test.write(['SConstruct'], """\ +import os + +env = Environment(TOOLS = ['tex', 'latex', 'dvipdf']) +Export(['env']) + +SConscript(os.path.join('docs', 'SConscript'), + variant_dir=os.path.join('mybuild','docs'), + duplicate=0) +""") + + +test.write(['docs', 'SConscript'], """\ +Import('env') + +test_dvi = env.DVI(source='test.tex') +test2_dvi = env.DVI(target='result',source='test2.tex') +testpdf = env.PDF(target='pdfoutput',source=test_dvi) +test2pdf = env.PDF(target='pdfoutput.xyz',source=test2_dvi) +""") + + +test.write(['docs', 'Fig1.ps'], """\ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: Fig1.fig +%%Creator: fig2dev Version 3.2 Patchlevel 4 +%%CreationDate: Tue Apr 25 09:56:11 2006 +%%BoundingBox: 0 0 98 98 +%%Magnification: 1.0000 +%%EndComments +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def + +end +save +newpath 0 98 moveto 0 0 lineto 98 0 lineto 98 98 lineto closepath clip newpath +-24.9 108.2 translate +1 -1 scale + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/sc {scale} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/tr {translate} bind def + /DrawEllipse { + /endangle exch def + /startangle exch def + /yrad exch def + /xrad exch def + /y exch def + /x exch def + /savematrix mtrx currentmatrix def + x y tr xrad yrad sc 0 0 1 startangle endangle arc + closepath + savematrix setmatrix + } def + +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +$F2psBegin +10 setmiterlimit + 0.06299 0.06299 sc +% +% Fig objects follow +% +7.500 slw +% Ellipse +n 1170 945 766 766 0 360 DrawEllipse gs col0 s gr + +$F2psEnd +rs +""") + + +test.write(['docs', 'Fig1.tex'], +r"""\begin{picture}(0,0)% +\includegraphics{Fig1.ps}% +\end{picture}% +\setlength{\unitlength}{4144sp}% +% +\begingroup\makeatletter\ifx\SetFigFont\undefined% +\gdef\SetFigFont#1#2#3#4#5{% + \reset@font\fontsize{#1}{#2pt}% + \fontfamily{#3}\fontseries{#4}\fontshape{#5}% + \selectfont}% +\fi\endgroup% +\begin{picture}(1548,1546)(397,-879) +\put(856,-196){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{\rmdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}center $r_0$}% +}}} +\end{picture} +""") + + +test.write(['docs', 'test.bib'], """\ +%% This BibTeX bibliography file was created using BibDesk. +%% http://bibdesk.sourceforge.net/ + +%% Saved with string encoding Western (ASCII) + +@techreport{AnAuthor:2006fk, + Author = {A. N. Author}, + Date-Added = {2006-11-15 12:51:30 -0800}, + Date-Modified = {2006-11-15 12:52:35 -0800}, + Institution = {none}, + Month = {November}, + Title = {A Test Paper}, + Year = {2006}} +""") + + +test.write(['docs', 'test.tex'], +r"""\documentclass{report} + +\usepackage{graphicx} +\usepackage{epsfig,color} % for .tex version of figures if we go that way + +\usepackage{makeidx} +\makeindex + +\begin{document} + +\title{Report Title} + +\author{A. N. Author} + +\maketitle + +\begin{abstract} +there is no abstract +\end{abstract} + +\tableofcontents +\listoffigures + +\chapter{Introduction} + +The introduction is short. + +\index{Acknowledgements} + +\section{Acknowledgements} + +The Acknowledgements are show as well \cite{AnAuthor:2006fk}. + +\index{Getting the Report} + +To get a hard copy of this report call me. + +\begin{figure}[htbp] +\begin{center} +\input{Fig1.tex} % testing figure variant that uses TeX labeling +\caption{Zone and Node indexing} +\label{fig1} +\end{center} +\end{figure} + +All done now. + +\bibliographystyle{unsrt} +\bibliography{test} +\newpage + +\printindex + +\end{document} +""") + +test.write(['docs', 'test2.tex'], +r"""\documentclass{report} + +\usepackage{graphicx} +\usepackage{epsfig,color} % for .tex version of figures if we go that way + +\usepackage{makeidx} +\makeindex + +\begin{document} + +\title{Report Title} + +\author{A. N. Author} + +\maketitle + +\begin{abstract} +there is no abstract +\end{abstract} + +\tableofcontents +\listoffigures + +\chapter{Introduction} + +The introduction is short. + +\index{Acknowledgements} + +\section{Acknowledgements} + +The Acknowledgements are show as well \cite{AnAuthor:2006fk}. + +\index{Getting the Report} + +To get a hard copy of this report call me. + +\begin{figure}[htbp] +\begin{center} +\input{Fig1.tex} % testing figure variant that uses TeX labeling +\caption{Zone and Node indexing} +\label{fig1} +\end{center} +\end{figure} + +All done now. + +\bibliographystyle{unsrt} +\bibliography{test} +\newpage + +\printindex + +\end{document} +""") + + +# makeindex will write status messages to stderr (grrr...), so ignore it. +test.run(arguments = '.', stderr=None) + + +# All (?) the files we expect will get created in the variant_dir +# (mybuild/docs) and not in the srcdir (docs). +files = [ + 'test.aux', + 'test.bbl', + 'test.blg', + 'test.dvi', + 'test.idx', + 'test.ilg', + 'test.ind', + 'test.lof', + 'test.log', + 'test.toc', + 'test2.aux', + 'test2.bbl', + 'test2.blg', + 'test2.idx', + 'test2.ilg', + 'test2.ind', + 'test2.lof', + 'test2.log', + 'test2.toc', + 'result.dvi', + 'pdfoutput.pdf', + 'pdfoutput.xyz' +] + +for f in files: + test.must_exist(['mybuild', 'docs', f]) + test.must_not_exist(['docs', f]) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEX/variant_dir_newglossary.py b/test/TEX/variant_dir_newglossary.py new file mode 100644 index 000000000..8604270cd --- /dev/null +++ b/test/TEX/variant_dir_newglossary.py @@ -0,0 +1,109 @@ +#!/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__" + +""" +Validate the use of \newglossary in TeX source files in conjuction +with variant_dir. + +Test configuration contributed by Kendrick Boyd. +""" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') + +if not latex: + test.skip_test("Could not find latex; skipping test(s).\n") + +gloss = os.system('kpsewhich glossaries.sty') +if gloss!=0: + test.skip_test("glossaries.sty not installed; skipping test(s).\n") + + +test.subdir(['src']) + +test.write(['SConstruct'], r""" +import os + +env = Environment(TOOLS = ['tex', 'latex']) +Export(['env']) + +SConscript(os.path.join('src','SConscript'), variant_dir='build/', duplicate=1) +""") + +test.write(['src', 'SConscript'], r""" +Import('env') + +test_pdf = env.PDF(source='test.tex') + +""") + +test.write(['src', 'test.tex'], r""" +\documentclass{report} + +\usepackage{glossaries} + +\newglossary[ntg]{notation}{nts}{nto}{List of Notation} + +\makeglossary + +\newglossaryentry{pi}{type=notation, name={$\pi$}, description={ratio + of circumference to diameter of a circle}} + +\begin{document} + +\glsaddall + +\printglossary[type=notation, style=list] + +\end{document} +""") + +test.run(arguments = '.', stderr = None) + +files = [ + 'test.aux', + 'test.fls', + 'test.glg', + 'test.glo', + 'test.gls', + 'test.ist', + 'test.log', + 'test.ntg', + 'test.nto', + 'test.nts', + 'test.pdf', +] + +for f in files: + test.must_exist(['build',f]) + test.must_not_exist(['src',f]) + + +test.pass_test() diff --git a/test/TEX/variant_dir_style_dup0.py b/test/TEX/variant_dir_style_dup0.py new file mode 100644 index 000000000..711086f62 --- /dev/null +++ b/test/TEX/variant_dir_style_dup0.py @@ -0,0 +1,190 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test creation of a fully-featured TeX document (with bibliography +and index) in a variant_dir. + +Also test that the target can be named differently than what +Latex produces by default. + +Also test that style files can be found when the tex file is generated +and duplicate=0 is used with variant dir + +Test courtesy Rob Managan. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +latex = test.where_is('latex') +dvipdf = test.where_is('dvipdf') +makeindex = test.where_is('makeindex') +bibtex = test.where_is('bibtex') +if not latex or not makeindex or not bibtex or not dvipdf: + test.skip_test("Could not find 'latex', 'makeindex', 'bibtex', or 'dvipdf'; skipping test.\n") + +test.subdir(['docs']) + + +test.write(['SConstruct'], """\ +import os + +env = Environment(tools = ['tex', 'latex', 'dvipdf']) +copy_latex = Builder(action=Copy('$TARGET', '$SOURCE'), + suffix='.tex', + src_suffix='.src') +env.Append( BUILDERS={'CopyLatex' : copy_latex} ) +# +# tell latex where to find the style file. +# these files are normally system files but since the .tex file is generated +# the latex builder really does not know where the source file that the +# latex file was built from is located. +# +env['TEXINPUTS'] = 'docs' + +Export(['env']) + +SConscript(os.path.join('docs', 'SConscript'), + variant_dir=os.path.join('mybuild','docs'), + duplicate=0) +""") + + +test.write(['docs', 'SConscript'], """\ +import os +Import('env') + +latex_file = env.CopyLatex('test2.src') +test2_dvi = env.DVI(target='result',source='test2.tex') +test2pdf = env.PDF(target='pdfoutput.xyz',source=test2_dvi) +""") + + +test.write(['docs', 'test.bib'], r""" +% This BibTeX bibliography file was created using BibDesk. +% http://bibdesk.sourceforge.net/ + +@techreport{AnAuthor:2006fk, + Author = {A. N. Author}, + Date-Added = {2006-11-15 12:51:30 -0800}, + Date-Modified = {2006-11-15 12:52:35 -0800}, + Institution = {none}, + Month = {November}, + Title = {A Test Paper}, + Year = {2006}} +""") + +test.write(['docs', 'noweb.sty'], """\ +% empty style file + +""") + + +test.write(['docs', 'test2.src'], +r""" +\documentclass{report} + +\usepackage{graphicx} +\usepackage{epsfig,color} % for .tex version of figures if we go that way + +\usepackage{makeidx} +\usepackage{noweb} +\makeindex + +\begin{document} + +\title{Report Title} + +\author{A. N. Author} + +\maketitle + +\begin{abstract} +there is no abstract +\end{abstract} + +\tableofcontents +\listoffigures + +\chapter{Introduction} + +The introduction is short. + +\index{Acknowledgements} + +\section{Acknowledgements} + +The Acknowledgements are show as well \cite{AnAuthor:2006fk}. + +\index{Getting the Report} + +To get a hard copy of this report call me. + +All done now. + +\bibliographystyle{unsrt} +\bibliography{test} +\newpage + +\printindex + +\end{document} +""") + + +# makeindex will write status messages to stderr (grrr...), so ignore it. +test.run(arguments = '.', stderr=None) + + +# All (?) the files we expect will get created in the variant_dir +# (mybuild/docs) and not in the srcdir (docs). +files = [ + 'test2.aux', + 'test2.bbl', + 'test2.blg', + 'test2.idx', + 'test2.ilg', + 'test2.ind', + 'test2.log', + 'test2.toc', + 'result.dvi', + 'pdfoutput.xyz' +] + +for f in files: + test.must_exist(['mybuild', 'docs', f]) + test.must_not_exist(['docs', f]) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: |