Back out post-2.0 code changes from trunk: r4643, r4642 r4640, r4637.
[scons.git] / test / TEX / subdir_variantdir_include2.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 Verify that we execute TeX in a subdirectory (if that's where the document
29 resides) by checking that all the auxiliary files get created there and
30 not in the top-level directory. Test this when variantDir is used
31 Add use of \include and \includegraphics from within the included file
32
33 Also check that we find files
34
35 Test case courtesy Joel B. Mohler.
36 """
37
38 import TestSCons
39
40 test = TestSCons.TestSCons()
41
42 #test.verbose_set(2)
43
44 latex = test.where_is('latex')
45 if not latex:
46     test.skip_test("Could not find 'latex'; skipping test.\n")
47
48 pdflatex = test.where_is('pdflatex')
49 if not pdflatex:
50     test.skip_test("Could not find 'pdflatex'; skipping test.\n")
51
52 test.subdir('docs')
53 test.subdir(['docs','content'])
54 test.subdir(['docs','fig'])
55
56 test.write('SConstruct', """\
57 import os
58 env = Environment(TOOLS = ['tex', 'pdftex'],ENV = {'PATH' : os.environ['PATH']})
59
60 env.VariantDir('build', 'docs', duplicate=0)
61 graph = env.PDF('build/fig/graph.eps')
62 pdf = env.PDF('build/main.tex')
63 Depends(pdf, graph)
64 """)
65
66 test.write(['docs','main.tex'],
67 r"""\documentclass{article}
68 \usepackage{makeidx}
69 \usepackage{graphicx}
70 \makeindex
71 \begin{document}
72 Hi there.
73 \index{info}
74 \include{content/chapter}
75 \printindex{}
76 \end{document}
77 """)
78
79 test.write(['docs','content','chapter.tex'], """\
80 Sub-document 1
81 \input{content/subchap}
82
83 """)
84
85 test.write(['docs','content','subchap.tex'], """\
86 Sub-chapter 2
87
88 """)
89
90 test.write(['docs','fig','graph.eps'], """\
91 %!PS-Adobe-2.0 EPSF-2.0
92 %%Title: Fig1.fig
93 %%Creator: fig2dev Version 3.2 Patchlevel 4
94 %%CreationDate: Tue Apr 25 09:56:11 2006
95 %%For: managan@mangrove.llnl.gov (Rob Managan)
96 %%BoundingBox: 0 0 98 98
97 %%Magnification: 1.0000
98 %%EndComments
99 /$F2psDict 200 dict def
100 $F2psDict begin
101 $F2psDict /mtrx matrix put
102 /col-1 {0 setgray} bind def
103 /col0 {0.000 0.000 0.000 srgb} bind def
104
105 end
106 save
107 newpath 0 98 moveto 0 0 lineto 98 0 lineto 98 98 lineto closepath clip newpath
108 -24.9 108.2 translate
109 1 -1 scale
110
111 /gr {grestore} bind def
112 /gs {gsave} bind def
113 /rs {restore} bind def
114 /n {newpath} bind def
115 /s {stroke} bind def
116 /slw {setlinewidth} bind def
117 /srgb {setrgbcolor} bind def
118 /sc {scale} bind def
119 /sf {setfont} bind def
120 /scf {scalefont} bind def
121 /tr {translate} bind def
122  /DrawEllipse {
123         /endangle exch def
124         /startangle exch def
125         /yrad exch def
126         /xrad exch def
127         /y exch def
128         /x exch def
129         /savematrix mtrx currentmatrix def
130         x y tr xrad yrad sc 0 0 1 startangle endangle arc
131         closepath
132         savematrix setmatrix
133         } def
134
135 /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
136 /$F2psEnd {$F2psEnteredState restore end} def
137
138 $F2psBegin
139 10 setmiterlimit
140  0.06299 0.06299 sc
141 %
142 % Fig objects follow
143
144 7.500 slw
145 % Ellipse
146 n 1170 945 766 766 0 360 DrawEllipse gs col0 s gr
147
148 $F2psEnd
149 rs
150 """)
151
152 #test.run(arguments = '.')
153 test.run(arguments = '.', stderr=None, stdout=None)
154
155 test.must_exist(['build', 'main.aux'])
156 test.must_exist(['build', 'main.fls'])
157 test.must_exist(['build', 'main.idx'])
158 test.must_exist(['build', 'main.ilg'])
159 test.must_exist(['build', 'main.ind'])
160 test.must_exist(['build', 'main.log'])
161 test.must_exist(['build', 'main.pdf'])
162
163 test.must_exist(['build', 'content', 'chapter.aux'])
164
165 test.must_not_exist('main.aux')
166 test.must_not_exist('main.dvi')
167 test.must_not_exist('main.idx')
168 test.must_not_exist('main.ilg')
169 test.must_not_exist('main.ind')
170 test.must_not_exist('main.log')
171 test.must_not_exist('main.pdf')
172
173 test.must_not_exist(['docs', 'main.aux'])
174 test.must_not_exist(['docs', 'main.dvi'])
175 test.must_not_exist(['docs', 'main.idx'])
176 test.must_not_exist(['docs', 'main.ilg'])
177 test.must_not_exist(['docs', 'main.ind'])
178 test.must_not_exist(['docs', 'main.log'])
179 test.must_not_exist(['docs', 'main.pdf'])
180
181 test.must_not_exist(['docs', 'content', 'main.aux'])
182 test.must_not_exist(['docs', 'content', 'main.dvi'])
183 test.must_not_exist(['docs', 'content', 'main.idx'])
184 test.must_not_exist(['docs', 'content', 'main.ilg'])
185 test.must_not_exist(['docs', 'content', 'main.ind'])
186 test.must_not_exist(['docs', 'content', 'main.log'])
187 test.must_not_exist(['docs', 'content', 'main.pdf'])
188
189 test.must_not_exist(['docs', 'content', 'chapter.aux'])
190
191 test.up_to_date(arguments = '.', stderr=None, stdout=None)
192
193 test.write(['docs','content', 'subchap.tex'], """\
194 Sub-document 2
195 """)
196
197 test.not_up_to_date(arguments = '.')
198 #test.up_to_date(arguments = '.', stderr=None, stdout=None)
199
200 test.pass_test()
201
202 # Local Variables:
203 # tab-width:4
204 # indent-tabs-mode:nil
205 # End:
206 # vim: set expandtab tabstop=4 shiftwidth=4: