Expanded SCons.Scanner.LaTeX.comment_re to not break on \%
[scons.git] / test / TEX / multi-run.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
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.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Validate that both .tex and .ltx files can handle a LaTeX-style
29 bibliography (by calling $BIBTEX to generate a .bbl file) and
30 correctly re-run to resolve undefined references.
31
32 Also verifies that package warnings are caught and re-run as needed.
33 """
34
35 import TestSCons
36
37 test = TestSCons.TestSCons()
38
39 tex = test.where_is('tex')
40 latex = test.where_is('latex')
41
42 if not tex and not latex:
43     test.skip_test("Could not find tex or latex; skipping test(s).\n")
44
45 test.subdir('work1', 'work2', 'work3', 'work4')
46
47
48 input_file = r"""
49 \documentclass{article}
50
51 \begin{document}
52 As stated in \cite{X}, this is a bug-a-boo.
53 \bibliography{fooref}
54 \bibliographystyle{plain}
55 \end{document}
56 """
57
58 input_file2 = r"""
59 \documentclass{article}
60 \begin{document}
61 Hello world.
62 % \bibliography{fooref}
63 % \bibliographystyle{plain}
64 \end{document}
65 """
66
67 input_file3 = r"""
68 \documentclass{article}
69 \usepackage{longtable}
70
71 \begin{document}
72 As stated in the last paper, this is a bug-a-boo.
73 here is some more junk and another table
74 here is some more junk and another table
75
76 \begin{longtable}[l]{rlll}
77          Isotope  &\multicolumn{1}{c}{Abar}  &Name\\
78 \\
79          1001    &1.0078    &Proton        &$p$\\
80          1002    &2.0141    &Deuterium     &$d$\\
81          1003    &3.0170    &Tritium       &$t$\\
82          2003    &3.0160    &Helium 3      &He$^3$\\
83          2004    &4.0026    &Helium 4      &He$^{4}$\\
84 \end{longtable}
85
86 and a closing comment
87
88  These parameters and arrays are filled in when the parameter \textbf{iftnrates}
89    is set to 1:
90
91 \begin{longtable}[l]{ll}
92 \\
93 \textbf{nxxxx}     &Total number of particles made by xxxx reaction\\
94 \textbf{pxxxx}     &Total number of particles made by xxxx reaction\\
95 \textbf{nxxxxx}    &Total number of particles made by xxxxx reaction\\
96 \textbf{nxxxx}     &Total number of particles made by xxxx reaction\\
97 \textbf{pxxxx}     &Total number of particles made by xxxx reaction\\
98 \textbf{nxxxx}     &Total number of particles made by xxxx reaction\\
99 \textbf{pxxxx}     &Total number of particles made by xxxx reaction\\
100 \textbf{nxxxxx}    &Total number of particles made by xxxxx reaction\\
101 \textbf{nxxxx}     &Total number of particles made by xxxx reaction\\
102 \textbf{pxxxx}     &Total number of particles made by xxxx reaction\\
103 \\
104 \textbf{rnxxxx}    &Regional total of particles made by xxxx reaction\\
105 \textbf{rpxxxx}    &Regional total of particles made by xxxx reaction\\
106 \textbf{rnxxxxx}   &Regional total of particles made by xxxxx reaction\\
107 \textbf{rnxxxx}    &Regional total of particles made by xxxx reaction\\
108 \textbf{rpxxxx}    &Regional total of particles made by xxxx reaction\\
109 \textbf{rnxxxx}    &Regional total of particles made by xxxx reaction\\
110 \textbf{rpxxxx}    &Regional total of particles made by xxxx reaction\\
111 \textbf{rnxxxxx}   &Regional total of particles made by xxxxx reaction\\
112 \textbf{rnxxxx}    &Regional total of particles made by xxxx reaction\\
113 \textbf{rpxxxx}    &Regional total of particles made by xxxx reaction\\
114 \\
115 \textbf{reactot}(r)     &Total number of reactions for reaction r\\
116 \textbf{reacreg}(r,ir)  &Total number of reactions for reaction r in region ir\\
117 \end{longtable}
118
119
120 \end{document}
121 """
122
123 bibfile = r"""
124 @Article{X,
125   author =       "Mr. X",
126   title =        "A determination of bug-a-boo-ness",
127   journal =      "Journal of B.a.B.",
128   year =         1920,
129   volume =       62,
130   pages =        291
131 }
132 """
133
134 if tex:
135
136     test.write(['work1', 'SConstruct'], """\
137 import os
138 env = Environment(tools = ['pdftex', 'dvipdf', 'tex', 'latex'],
139                   ENV = {'PATH' : os.environ['PATH']})
140 env.DVI( "foo.tex" )
141 env.PDF( "foo.tex" )
142 """)
143
144     test.write(['work1', 'foo.tex'], input_file)
145     test.write(['work1', 'fooref.bib'], bibfile)
146
147     test.run(chdir = 'work1', arguments = '.')
148
149     test.must_exist(['work1', 'foo.bbl'])
150
151     foo_log = test.read(['work1', 'foo.log'])
152     test.must_not_contain_any_line(foo_log, ['undefined references'], 'foo.log')
153
154     test.write(['work3', 'SConstruct'], """\
155 import os
156 env = Environment(tools = ['tex', 'latex'],
157                   ENV = {'PATH' : os.environ['PATH']})
158 env.DVI( "foo3.tex" )
159 """)
160
161     test.write(['work3', 'foo3.tex'], input_file3)
162
163     test.run(chdir = 'work3', arguments = '.')
164
165     foo_log = test.read(['work3', 'foo3.log'])
166     test.must_not_contain_any_line(foo_log, ['Rerun LaTeX'], 'foo3.log')
167
168
169
170 if latex:
171
172     test.write(['work2', 'SConstruct'], """\
173 import os
174 env = Environment(tools = ['dvi', 'pdf', 'pdftex', 'dvipdf', 'pdflatex', 'tex', 'latex'],
175                   ENV = {'PATH' : os.environ['PATH']})
176 env.DVI( "foo.ltx" )
177 env.PDF( "foo.ltx" )
178 """)
179
180     test.write(['work2', 'foo.ltx'], input_file)
181     test.write(['work2', 'fooref.bib'], bibfile)
182
183     test.run(chdir = 'work2', arguments = '.')
184
185     test.must_exist(['work2', 'foo.bbl'])
186
187     foo_log = test.read(['work2', 'foo.log'])
188     test.must_not_contain_any_line(foo_log, ['undefined references'], 'foo.log')
189
190     test.write(['work3', 'SConstruct'], """\
191 import os
192 env = Environment(tools = ['pdftex', 'dvipdf', 'tex', 'latex'],
193                   ENV = {'PATH' : os.environ['PATH']})
194 env.DVI( "foo3.tex" )
195 env.PDF( "foo3.tex" )
196 """)
197
198     test.write(['work3', 'foo3.tex'], input_file3)
199
200     test.run(chdir = 'work3', arguments = '.')
201
202     foo_log = test.read(['work3', 'foo3.log'])
203     test.must_not_contain_any_line(foo_log, ['Rerun LaTeX'], 'foo3.log')
204
205
206     test.write(['work4', 'SConstruct'], """\
207 import os
208 env = Environment(tools = ['tex', 'latex'],
209                   ENV = {'PATH' : os.environ['PATH']})
210 env.DVI( "foo.ltx" )
211 """)
212     test.write(['work4', 'foo.ltx'], input_file2)
213
214     test.run(chdir = 'work4', arguments = '.')
215
216     test.up_to_date(chdir = 'work4', arguments = '.')
217
218
219 test.pass_test()
220
221 # Local Variables:
222 # tab-width:4
223 # indent-tabs-mode:nil
224 # End:
225 # vim: set expandtab tabstop=4 shiftwidth=4: