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__"
29 _python_
= TestSCons
._python
_
31 test
= TestSCons
.TestSCons()
35 test
.write('mytex.py', r
"""
39 cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', [])
40 base_name = os.path.splitext(arg[0])[0]
41 infile = open(arg[0], 'r')
42 out_file = open(base_name+'.dvi', 'w')
43 for l in infile.readlines():
49 test
.write('mylatex.py', r
"""
53 cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', [])
54 base_name = os.path.splitext(arg[0])[0]
55 infile = open(arg[0], 'r')
56 out_file = open(base_name+'.dvi', 'w')
57 for l in infile.readlines():
63 test
.write('mydvipdf.py', r
"""
67 cmd_opts, arg = getopt.getopt(sys.argv[1:], 'i:r:', [])
68 infile = open(arg[0], 'r')
69 out_file = open(arg[1], 'w')
70 for l in infile.readlines():
71 if l[:7] != '#dvipdf':
76 test
.write('SConstruct', """
77 env = Environment(TEX = r'%(_python_)s mytex.py',
78 LATEX = r'%(_python_)s mylatex.py',
79 DVIPDF = r'%(_python_)s mydvipdf.py',
80 tools=['latex', 'tex', 'dvipdf'])
81 dvi = env.DVI(target = 'test1.dvi', source = 'test1.tex')
82 env.DVI(target = 'test2.dvi', source = 'test2.tex')
83 env.PDF(target = 'test1.pdf', source = dvi)
84 env.PDF(target = 'test2.pdf', source = 'test2.dvi')
87 test
.write('test1.tex', r
"""This is a .dvi test.
92 test
.write('test2.tex', r
"""This is a .tex test.
97 test
.run(arguments
= '.', stderr
= None)
99 test
.must_match('test1.pdf', "This is a .dvi test.\n", mode
='r')
101 test
.must_match('test2.pdf', "This is a .tex test.\n", mode
='r')
105 dvipdf
= test
.where_is('dvipdf')
106 tex
= test
.where_is('tex')
110 test
.write("wrapper.py", """\
113 cmd = " ".join(sys.argv[1:])
114 open('%s', 'a').write("%%s\\n" %% cmd)
115 subprocess.run(cmd, shell=True)
116 """ % test
.workpath('wrapper.out').replace('\\', '\\\\'))
118 test
.write('SConstruct', """
120 foo = Environment(ENV = { 'PATH' : os.environ['PATH'] })
121 dvipdf = foo.Dictionary('DVIPDF')
122 bar = Environment(ENV = { 'PATH' : os.environ['PATH'] },
123 DVIPDF = r'%(_python_)s wrapper.py ' + dvipdf)
124 foo.PDF(target = 'foo.pdf',
125 source = foo.DVI(target = 'foo.dvi', source = 'foo.tex'))
126 bar.PDF(target = 'bar.pdf',
127 source = bar.DVI(target = 'bar.dvi', source = 'bar.tex'))
128 foo.PDF(target = 'xxx.pdf', source = 'xxx.tex')
132 This is the %s TeX file.
136 test
.write('foo.tex', tex
% 'foo.tex')
138 test
.write('xxx.tex', tex
% 'xxx.tex')
140 test
.write('bar.tex', tex
% 'bar.tex')
142 test
.run(arguments
= 'foo.pdf', stderr
= None)
144 test
.must_not_exist(test
.workpath('wrapper.out'))
146 test
.must_exist(test
.workpath('foo.pdf'))
148 test
.run(arguments
= 'xxx.pdf', stderr
= None)
150 test
.must_not_exist(test
.workpath('wrapper.out'))
152 test
.must_not_exist(test
.workpath('xxx.dvi'))
154 test
.run(arguments
= 'bar.pdf', stderr
= None)
156 test
.must_match('wrapper.out', "dvipdf bar.dvi bar.pdf\n")
158 test
.must_exist(test
.workpath('bar.pdf'))
164 # indent-tabs-mode:nil
166 # vim: set expandtab tabstop=4 shiftwidth=4: