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
+_python_ = TestSCons._python_
test = TestSCons.TestSCons()
test.write('mylatex.py', r"""
import sys
import os
-base_name = os.path.splitext(sys.argv[1])[0]
-infile = open(sys.argv[1], 'rb')
+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')
""")
test.write('SConstruct', """
-env = Environment(LATEX = r'%s mylatex.py', tools=['latex'])
+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')
-""" % python)
+""" % locals())
test.write('test1.ltx', r"""This is a .ltx test.
\end
if latex:
test.write("wrapper.py", """import os
-import string
import sys
open('%s', 'wb').write("wrapper.py\\n")
-os.system(string.join(sys.argv[1:], " "))
-""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
+os.system(" ".join(sys.argv[1:]))
+""" % test.workpath('wrapper.out').replace('\\', '\\\\'))
test.write('SConstruct', """
import os
foo = Environment(ENV = ENV)
latex = foo.Dictionary('LATEX')
makeindex = foo.Dictionary('MAKEINDEX')
+python_path = r'%(_python_)s'
bar = Environment(ENV = ENV,
- LATEX = r'%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')
bar.DVI(target = 'makeindex', source = 'makeindex.tex')
foo.DVI(target = 'latexi', source = 'latexi.tex')
-""" % python)
+""" % locals())
latex = r"""
\documentclass{letter}
"""
makeindex = r"""
-\documentclass{letter}
+\documentclass{report}
\usepackage{makeidx}
\makeindex
\begin{document}
"""
latex1 = r"""
-\documentclass{letter}
+\documentclass{report}
\usepackage{makeidx}
-\makeindex
+\input{latexinputfile}
\begin{document}
\index{info}
This is the %s LaTeX file.
"""
latex2 = r"""
+\makeindex
+"""
+
+ latex3 = r"""
\index{include}
-This is the include file.
+This is the include file. mod %s
\printindex{}
"""
test.subdir('subdir')
test.write('latexi.tex', latex1 % 'latexi.tex');
- test.write([ 'subdir', 'latexincludefile.tex'], latex2)
+ 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('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: