Variables cleanup: core
[scons.git] / test / TEX / multiple_include.py
blob8817c940314801277b011cb6e13fba195320e418
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 Test creation of a fully-featured TeX document (with bibliography
28 and index) in a variant_dir.
30 Test courtesy Rob Managan.
31 """
33 import TestSCons
35 test = TestSCons.TestSCons()
37 latex = test.where_is('latex')
38 if not latex:
39 test.skip_test("Could not find 'latex'; skipping test.\n")
41 epstopdf = test.where_is('epstopdf')
42 if not epstopdf:
43 test.skip_test("Could not find 'epstopdf'; skipping test.\n")
45 makeindex = test.where_is('makeindex')
46 if not makeindex:
47 test.skip_test("Could not find 'makeindex'; skipping test.\n")
49 test.subdir(['docs'])
52 test.write(['SConstruct'], """\
53 import os
55 env = Environment()
57 env.PDF('Fig1.ps')
58 test = env.PDF(source='test.tex')
59 """)
62 test.write(['Fig1.ps'], """\
63 %!PS-Adobe-2.0 EPSF-2.0
64 %%Title: Fig1.fig
65 %%Creator: fig2dev Version 3.2 Patchlevel 4
66 %%CreationDate: Tue Apr 25 09:56:11 2006
67 %%For: managan@mangrove.llnl.gov (Rob Managan)
68 %%BoundingBox: 0 0 98 98
69 %%Magnification: 1.0000
70 %%EndComments
71 /$F2psDict 200 dict def
72 $F2psDict begin
73 $F2psDict /mtrx matrix put
74 /col-1 {0 setgray} bind def
75 /col0 {0.000 0.000 0.000 srgb} bind def
77 end
78 save
79 newpath 0 98 moveto 0 0 lineto 98 0 lineto 98 98 lineto closepath clip newpath
80 -24.9 108.2 translate
81 1 -1 scale
83 /cp {closepath} bind def
84 /ef {eofill} bind def
85 /gr {grestore} bind def
86 /gs {gsave} bind def
87 /rs {restore} bind def
88 /l {lineto} bind def
89 /m {moveto} bind def
90 /rm {rmoveto} bind def
91 /n {newpath} bind def
92 /s {stroke} bind def
93 /slc {setlinecap} bind def
94 /slj {setlinejoin} bind def
95 /slw {setlinewidth} bind def
96 /srgb {setrgbcolor} bind def
97 /sc {scale} bind def
98 /sf {setfont} bind def
99 /scf {scalefont} bind def
100 /tr {translate} bind def
101 /DrawEllipse {
102 /endangle exch def
103 /startangle exch def
104 /yrad exch def
105 /xrad exch def
106 /y exch def
107 /x exch def
108 /savematrix mtrx currentmatrix def
109 x y tr xrad yrad sc 0 0 1 startangle endangle arc
110 closepath
111 savematrix setmatrix
112 } def
114 /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
115 /$F2psEnd {$F2psEnteredState restore end} def
117 $F2psBegin
118 10 setmiterlimit
119 0.06299 0.06299 sc
121 % Fig objects follow
123 7.500 slw
124 % Ellipse
125 n 1170 945 766 766 0 360 DrawEllipse gs col0 s gr
127 $F2psEnd
129 """)
132 test.write(['Fig1.tex'],
133 r"""\begin{picture}(0,0)%
134 \includegraphics{Fig1}%
135 \end{picture}%
136 \setlength{\unitlength}{4144sp}%
138 \begingroup\makeatletter\ifx\SetFigFont\undefined%
139 \gdef\SetFigFont#1#2#3#4#5{%
140 \reset@font\fontsize{#1}{#2pt}%
141 \fontfamily{#3}\fontseries{#4}\fontshape{#5}%
142 \selectfont}%
143 \fi\endgroup%
144 \begin{picture}(1548,1546)(397,-879)
145 \put(856,-196){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{\rmdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}center $r_0$}%
147 \end{picture}
148 """)
151 test.write(['test.tex'],
152 r"""\documentclass{report}
154 \usepackage{graphicx}
155 \usepackage{epsfig,color} % for .tex version of figures if we go that way
157 \usepackage{makeidx}
158 \makeindex
160 \begin{document}
162 \title{Report Title}
164 \author{A. N. Author}
166 \maketitle
168 \begin{abstract}
169 there is no abstract
170 \end{abstract}
172 \tableofcontents
173 \listoffigures
175 \chapter{Introduction}
177 The introduction is short.
179 \index{Acknowledgements}
181 \section{Acknowledgements}
183 The Acknowledgements are shown as well.
185 \index{Getting the Report}
187 \input{getReport}
189 \end{document}
190 """)
192 test.write(['getReport.tex'],
193 r"""
194 To get a hard copy of this report call me.
196 \begin{figure}[htbp]
197 \begin{center}
198 \input{Fig1.tex} % testing figure variant that uses TeX labeling
199 \caption{Zone and Node indexing}
200 \label{fig1}
201 \end{center}
202 \end{figure}
204 All done now.
206 %\bibliographystyle{unsrt}
207 %\bibliography{test}
208 \newpage
210 \printindex
211 """)
213 # makeindex will write status messages to stderr (grrr...), so ignore it.
214 test.run(arguments = '.', stderr=None)
217 # All (?) the files we expect will get created in the variant_dir
218 # (mybuild/docs) and not in the srcdir (docs).
219 files = [
220 'test.aux',
221 'test.idx',
222 'test.ilg',
223 'test.ind',
224 'test.lof',
225 'test.log',
226 'test.pdf',
227 'test.toc',
228 'Fig1.pdf'
231 for f in files:
232 test.must_exist([ f])
235 test.pass_test()
237 # Local Variables:
238 # tab-width:4
239 # indent-tabs-mode:nil
240 # End:
241 # vim: set expandtab tabstop=4 shiftwidth=4: