diff options
Diffstat (limited to 'test/TEX')
-rw-r--r-- | test/TEX/LATEX.py | 15 | ||||
-rw-r--r-- | test/TEX/PDFLATEX.py | 6 | ||||
-rw-r--r-- | test/TEX/PDFTEX.py | 6 | ||||
-rw-r--r-- | test/TEX/TEX.py | 8 | ||||
-rw-r--r-- | test/TEX/dryrun.py | 67 |
5 files changed, 89 insertions, 13 deletions
diff --git a/test/TEX/LATEX.py b/test/TEX/LATEX.py index 0636109..bb034be 100644 --- a/test/TEX/LATEX.py +++ b/test/TEX/LATEX.py @@ -45,8 +45,10 @@ test = TestSCons.TestSCons() test.write('mylatex.py', r""" import sys import os -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') +import getopt +cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:', []) +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') @@ -112,9 +114,10 @@ ENV = { 'PATH' : os.environ['PATH'], foo = Environment(ENV = ENV) latex = foo.Dictionary('LATEX') makeindex = foo.Dictionary('MAKEINDEX') +python_path = r'%(_python_)s' bar = Environment(ENV = ENV, - LATEX = r'%(_python_)s wrapper.py ' + latex, - MAKEINDEX = r' wrapper.py ' + makeindex) + 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') @@ -130,7 +133,7 @@ This is the %s LaTeX file. """ makeindex = r""" -\documentclass{letter} +\documentclass{report} \usepackage{makeidx} \makeindex \begin{document} @@ -141,7 +144,7 @@ This is the %s LaTeX file. """ latex1 = r""" -\documentclass{letter} +\documentclass{report} \usepackage{makeidx} \makeindex \begin{document} diff --git a/test/TEX/PDFLATEX.py b/test/TEX/PDFLATEX.py index e1cf00e..11ada7b 100644 --- a/test/TEX/PDFLATEX.py +++ b/test/TEX/PDFLATEX.py @@ -45,8 +45,10 @@ test = TestSCons.TestSCons() test.write('mypdflatex.py', r""" import sys import os -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') +import getopt +cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:', []) +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') diff --git a/test/TEX/PDFTEX.py b/test/TEX/PDFTEX.py index ad77b8a..cde6015 100644 --- a/test/TEX/PDFTEX.py +++ b/test/TEX/PDFTEX.py @@ -45,8 +45,10 @@ test = TestSCons.TestSCons() test.write('mypdftex.py', r""" import sys import os -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') +import getopt +cmd_opts, arg = getopt.getopt(sys.argv[2:], 'i:', []) +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') diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py index eaea49a..5a0daec 100644 --- a/test/TEX/TEX.py +++ b/test/TEX/TEX.py @@ -45,8 +45,10 @@ test = TestSCons.TestSCons() test.write('mytex.py', r""" import sys import os -base_name = os.path.splitext(sys.argv[1])[0] -infile = open(sys.argv[1], 'rb') +import getopt +cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:', []) +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') @@ -175,7 +177,7 @@ Run \texttt{latex}, then \texttt{bibtex}, then \texttt{latex} twice again \cite{ test.run(stderr = None) output_lines = string.split(test.stdout(), '\n') - reruns = filter(lambda x: string.find(x, 'latex rerun.tex') != -1, output_lines) + reruns = filter(lambda x: string.find(x, 'latex -interaction=nonstopmode rerun.tex') != -1, output_lines) if len(reruns) != 2: print "Expected 2 latex calls, got %s:" % len(reruns) print string.join(reruns, '\n') diff --git a/test/TEX/dryrun.py b/test/TEX/dryrun.py new file mode 100644 index 0000000..80458af --- /dev/null +++ b/test/TEX/dryrun.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +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 os +import os.path +import string +import sys +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 +ENV = { 'PATH' : os.environ['PATH'] } +foo = Environment(ENV = ENV) +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 foo.ltx ... +"""), stderr = None) + + +test.pass_test() |