5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Validate that we can set the PDFTEX string to our own utility, that
29 the produced .dvi, .aux and .log files get removed by the -c option,
30 and that we can use this to wrap calls to the real latex utility.
38 _python_ = TestSCons._python_
40 test = TestSCons.TestSCons()
44 test.write('mypdftex.py', r"""
48 cmd_opts, arg = getopt.getopt(sys.argv[2:], 'i:', [])
49 base_name = os.path.splitext(arg[0])[0]
50 infile = open(arg[0], 'rb')
51 pdf_file = open(base_name+'.pdf', 'wb')
52 aux_file = open(base_name+'.aux', 'wb')
53 log_file = open(base_name+'.log', 'wb')
54 for l in infile.readlines():
62 test.write('SConstruct', """
63 env = Environment(PDFTEX = r'%(_python_)s mypdftex.py', tools=['pdftex'])
64 env.PDF(target = 'test.pdf', source = 'test.tex')
67 test.write('test.tex', r"""This is a test.
71 test.run(arguments = 'test.pdf')
73 test.must_exist('test.pdf')
74 test.must_exist('test.aux')
75 test.must_exist('test.log')
77 test.run(arguments = '-c test.pdf')
79 test.must_not_exist('test.pdf')
80 test.must_not_exist('test.aux')
81 test.must_not_exist('test.log')
85 pdftex = test.where_is('pdftex')
89 test.write("wrapper.py", """import os
92 open('%s', 'wb').write("wrapper.py\\n")
93 os.system(string.join(sys.argv[1:], " "))
94 """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
96 test.write('SConstruct', """
98 ENV = { 'PATH' : os.environ['PATH'] }
99 foo = Environment(ENV = ENV)
100 pdftex = foo.Dictionary('PDFTEX')
101 bar = Environment(ENV = ENV, PDFTEX = r'%(_python_)s wrapper.py ' + pdftex)
102 foo.PDF(target = 'foo.pdf', source = 'foo.tex')
103 bar.PDF(target = 'bar', source = 'bar.tex')
107 This is the %s TeX file.
111 test.write('foo.tex', tex % 'foo.tex')
113 test.write('bar.tex', tex % 'bar.tex')
115 test.run(arguments = 'foo.pdf', stderr = None)
117 test.must_not_exist('wrapper.out')
119 test.must_exist('foo.pdf')
121 test.run(arguments = 'bar.pdf', stderr = None)
123 test.must_exist('wrapper.out')
125 test.must_exist('bar.pdf')