Variables cleanup: core
[scons.git] / test / TEX / multi-run.py
blob29b8f1fdaf11a7ac083659cb57cc7d04cf164fd5
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 """
27 Validate that both .tex and .ltx files can handle a LaTeX-style
28 bibliography (by calling $BIBTEX to generate a .bbl file) and
29 correctly re-run to resolve undefined references.
31 Also verifies that package warnings are caught and re-run as needed.
32 """
34 import TestSCons
36 test = TestSCons.TestSCons()
38 tex = test.where_is('tex')
39 latex = test.where_is('latex')
40 if not all((tex, latex)):
41 test.skip_test("Could not find 'tex' and/or 'latex'; skipping test(s).\n")
43 test.subdir('work1', 'work2', 'work3', 'work4')
46 input_file = r"""
47 \documentclass{article}
49 \begin{document}
50 As stated in \cite{X}, this is a bug-a-boo.
51 \bibliography{fooref}
52 \bibliographystyle{plain}
53 \end{document}
54 """
56 input_file2 = r"""
57 \documentclass{article}
58 \begin{document}
59 Hello world.
60 % \bibliography{fooref}
61 % \bibliographystyle{plain}
62 \end{document}
63 """
65 input_file3 = r"""
66 \documentclass{article}
67 \usepackage{longtable}
69 \begin{document}
70 As stated in the last paper, this is a bug-a-boo.
71 here is some more junk and another table
72 here is some more junk and another table
74 \begin{longtable}[l]{rlll}
75 Isotope &\multicolumn{1}{c}{Abar} &Name\\
77 1001 &1.0078 &Proton &$p$\\
78 1002 &2.0141 &Deuterium &$d$\\
79 1003 &3.0170 &Tritium &$t$\\
80 2003 &3.0160 &Helium 3 &He$^3$\\
81 2004 &4.0026 &Helium 4 &He$^{4}$\\
82 \end{longtable}
84 and a closing comment
86 These parameters and arrays are filled in when the parameter \textbf{iftnrates}
87 is set to 1:
89 \begin{longtable}[l]{ll}
91 \textbf{nxxxx} &Total number of particles made by xxxx reaction\\
92 \textbf{pxxxx} &Total number of particles made by xxxx reaction\\
93 \textbf{nxxxxx} &Total number of particles made by xxxxx reaction\\
94 \textbf{nxxxx} &Total number of particles made by xxxx reaction\\
95 \textbf{pxxxx} &Total number of particles made by xxxx 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{nxxxxx} &Total number of particles made by xxxxx reaction\\
99 \textbf{nxxxx} &Total number of particles made by xxxx reaction\\
100 \textbf{pxxxx} &Total number of particles made by xxxx reaction\\
102 \textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\
103 \textbf{rpxxxx} &Regional total of particles made by xxxx reaction\\
104 \textbf{rnxxxxx} &Regional total of particles made by xxxxx reaction\\
105 \textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\
106 \textbf{rpxxxx} &Regional total of particles made by xxxx 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{rnxxxxx} &Regional total of particles made by xxxxx reaction\\
110 \textbf{rnxxxx} &Regional total of particles made by xxxx reaction\\
111 \textbf{rpxxxx} &Regional total of particles made by xxxx reaction\\
113 \textbf{reactot}(r) &Total number of reactions for reaction r\\
114 \textbf{reacreg}(r,ir) &Total number of reactions for reaction r in region ir\\
115 \end{longtable}
118 \end{document}
121 bibfile = r"""
122 @Article{X,
123 author = "Mr. X",
124 title = "A determination of bug-a-boo-ness",
125 journal = "Journal of B.a.B.",
126 year = 1920,
127 volume = 62,
128 pages = 291
132 # TODO: check is useless: we already bailed at top if tex not found.
133 # Should we split test into plain and -live instead?
134 if tex:
136 test.write(['work1', 'SConstruct'], """\
137 import os
138 env = Environment(tools = ['pdftex', 'dvipdf', 'tex', 'latex'])
139 env.DVI( "foo.tex" )
140 env.PDF( "foo.tex" )
141 """)
143 test.write(['work1', 'foo.tex'], input_file)
144 test.write(['work1', 'fooref.bib'], bibfile)
146 test.run(chdir = 'work1', arguments = '.')
148 test.must_exist(['work1', 'foo.bbl'])
150 foo_log = test.read(['work1', 'foo.log'], mode='r')
151 test.must_not_contain_any_line(foo_log, ['undefined references'], 'foo.log')
153 test.write(['work3', 'SConstruct'], """\
154 import os
155 env = Environment(tools = ['tex', 'latex'],
156 ENV = {'PATH' : os.environ['PATH']})
157 env.DVI( "foo3.tex" )
158 """)
160 test.write(['work3', 'foo3.tex'], input_file3)
162 test.run(chdir = 'work3', arguments = '.')
164 foo_log = test.read(['work3', 'foo3.log'], mode='r')
165 test.must_not_contain_any_line(foo_log, ['Rerun LaTeX'], 'foo3.log')
169 # TODO: split this test? this check is useless after skip above
170 if latex:
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 """)
180 test.write(['work2', 'foo.ltx'], input_file)
181 test.write(['work2', 'fooref.bib'], bibfile)
183 test.run(chdir = 'work2', arguments = '.')
185 test.must_exist(['work2', 'foo.bbl'])
187 foo_log = test.read(['work2', 'foo.log'], mode='r')
188 test.must_not_contain_any_line(foo_log, ['undefined references'], 'foo.log')
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 """)
198 test.write(['work3', 'foo3.tex'], input_file3)
200 test.run(chdir = 'work3', arguments = '.')
202 foo_log = test.read(['work3', 'foo3.log'], mode='r')
203 test.must_not_contain_any_line(foo_log, ['Rerun LaTeX'], 'foo3.log')
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)
214 test.run(chdir = 'work4', arguments = '.')
216 test.up_to_date(chdir = 'work4', arguments = '.')
219 test.pass_test()
221 # Local Variables:
222 # tab-width:4
223 # indent-tabs-mode:nil
224 # End:
225 # vim: set expandtab tabstop=4 shiftwidth=4: