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__"
33 _python_ = TestSCons._python_
35 test = TestSCons.TestSCons()
39 test.write('mytex.py', r"""
42 base_name = os.path.splitext(sys.argv[1])[0]
43 infile = open(sys.argv[1], 'rb')
44 out_file = open(base_name+'.dvi', 'wb')
45 for l in infile.readlines():
51 test.write('mylatex.py', r"""
54 base_name = os.path.splitext(sys.argv[1])[0]
55 infile = open(sys.argv[1], 'rb')
56 out_file = open(base_name+'.dvi', 'wb')
57 for l in infile.readlines():
63 test.write('mydvips.py', r"""
66 infile = open(sys.argv[3], 'rb')
67 out_file = open(sys.argv[2], 'wb')
68 for l in infile.readlines():
74 test.write('SConstruct', """
75 env = Environment(TEX = r'%(_python_)s mytex.py',
76 LATEX = r'%(_python_)s mylatex.py',
77 DVIPS = r'%(_python_)s mydvips.py',
78 tools=['tex', 'latex', 'dvips'])
79 dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex')
80 env.PostScript(target = 'test1.ps', source = dvi)
81 env.PostScript(target = 'test2.ps', source = 'test2.tex')
82 env.PostScript(target = 'test3.ps', source = 'test3.ltx')
83 env.PostScript(target = 'test4.ps', source = 'test4.latex')
86 test.write('test1.tex', r"""This is a .dvi test.
91 test.write('test2.tex', r"""This is a .tex test.
96 test.write('test3.ltx', r"""This is a .ltx test.
101 test.write('test4.latex', r"""This is a .latex test.
106 test.run(arguments = '.', stderr = None)
108 test.fail_test(test.read('test1.ps') != "This is a .dvi test.\n")
110 test.fail_test(test.read('test2.ps') != "This is a .tex test.\n")
112 test.fail_test(test.read('test3.ps') != "This is a .ltx test.\n")
114 test.fail_test(test.read('test4.ps') != "This is a .latex test.\n")
118 dvips = test.where_is('dvips')
122 test.write("wrapper.py", """import os
125 cmd = string.join(sys.argv[1:], " ")
126 open('%s', 'ab').write("%%s\\n" %% cmd)
128 """ % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
130 test.write('SConstruct', """
132 ENV = { 'PATH' : os.environ['PATH'] }
133 foo = Environment(ENV = ENV)
134 dvips = foo.Dictionary('DVIPS')
135 bar = Environment(ENV = ENV, DVIPS = r'%(_python_)s wrapper.py ' + dvips)
136 foo.PostScript(target = 'foo.ps', source = 'foo.tex')
137 bar.PostScript(target = 'bar1', source = 'bar1.tex')
138 bar.PostScript(target = 'bar2', source = 'bar2.ltx')
139 bar.PostScript(target = 'bar3', source = 'bar3.latex')
143 This is the %s TeX file.
148 \documentclass{letter}
150 This is the %s LaTeX file.
154 test.write('foo.tex', tex % 'foo.tex')
155 test.write('bar1.tex', tex % 'bar1.tex')
156 test.write('bar2.ltx', latex % 'bar2.ltx')
157 test.write('bar3.latex', latex % 'bar3.latex')
159 test.run(arguments = 'foo.dvi', stderr = None)
161 test.fail_test(os.path.exists(test.workpath('wrapper.out')))
163 test.fail_test(not os.path.exists(test.workpath('foo.dvi')))
165 test.run(arguments = 'bar1.ps bar2.ps bar3.ps', stderr = None)
167 expect = """dvips -o bar1.ps bar1.dvi
168 dvips -o bar2.ps bar2.dvi
169 dvips -o bar3.ps bar3.dvi
172 test.fail_test(test.read('wrapper.out') != expect)
174 test.fail_test(not os.path.exists(test.workpath('bar1.ps')))
175 test.fail_test(not os.path.exists(test.workpath('bar2.ps')))
176 test.fail_test(not os.path.exists(test.workpath('bar3.ps')))