Expanded SCons.Scanner.LaTeX.comment_re to not break on \%
[scons.git] / test / TEX / eps_graphics.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 Test creation of a Tex document with nested includes in a 
29 subdir that needs to create a fig.pdf.
30
31 Test courtesy Rob Managan.
32 """
33
34 import TestSCons
35
36 test = TestSCons.TestSCons()
37
38 latex = test.where_is('latex')
39 epstopdf = test.where_is('epstopdf')
40 if not latex:
41     test.skip_test("Could not find 'latex'; skipping test.\n")
42
43 if not epstopdf:
44     test.skip_test("Could not find 'epstopdf'; skipping test.\n")
45
46 test.subdir(['docs'])
47
48
49 test.write(['SConstruct'], """\
50 import os
51
52 env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
53
54 test = env.DVI(source='docs/test.tex')
55 """)
56
57
58 test.write(['docs','Fig1.eps'], """\
59 %!PS-Adobe-2.0 EPSF-2.0
60 %%Title: Fig1.fig
61 %%Creator: fig2dev Version 3.2 Patchlevel 4
62 %%CreationDate: Tue Apr 25 09:56:11 2006
63 %%For: managan@mangrove.llnl.gov (Rob Managan)
64 %%BoundingBox: 0 0 98 98
65 %%Magnification: 1.0000
66 %%EndComments
67 /$F2psDict 200 dict def
68 $F2psDict begin
69 $F2psDict /mtrx matrix put
70 /col-1 {0 setgray} bind def
71 /col0 {0.000 0.000 0.000 srgb} bind def
72
73 end
74 save
75 newpath 0 98 moveto 0 0 lineto 98 0 lineto 98 98 lineto closepath clip newpath
76 -24.9 108.2 translate
77 1 -1 scale
78
79 /cp {closepath} bind def
80 /ef {eofill} bind def
81 /gr {grestore} bind def
82 /gs {gsave} bind defThe Oxygen Isotopic Composition of Captured Solar Wind: First Results\rfrom the GENESIS Mission
83 /rs {restore} bind def
84 /l {lineto} bind def
85 /m {moveto} bind def
86 /rm {rmoveto} bind def
87 /n {newpath} bind def
88 /s {stroke} bind def
89 /slc {setlinecap} bind def
90 /slj {setlinejoin} bind def
91 /slw {setlinewidth} bind def
92 /srgb {setrgbcolor} bind def
93 /sc {scale} bind def
94 /sf {setfont} bind def
95 /scf {scalefont} bind def
96 /tr {translate} bind def
97  /DrawEllipse {
98         /endangle exch def
99         /startangle exch def
100         /yrad exch def
101         /xrad exch def
102         /y exch def
103         /x exch def
104         /savematrix mtrx currentmatrix def
105         x y tr xrad yrad sc 0 0 1 startangle endangle arc
106         closepath
107         savematrix setmatrix
108         } def
109
110 /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
111 /$F2psEnd {$F2psEnteredState restore end} def
112
113 $F2psBegin
114 10 setmiterlimit
115  0.06299 0.06299 sc
116 %
117 % Fig objects follow
118
119 7.500 slw
120 % Ellipse
121 n 1170 945 766 766 0 360 DrawEllipse gs col0 s gr
122
123 $F2psEnd
124 rs
125 """)
126
127
128
129 test.write(['docs','test.tex'],
130 r"""\documentclass{report}
131
132 \usepackage{graphicx}
133 \usepackage{epsfig,color} % for .tex version of figures if we go that way
134
135 \begin{document}
136  
137 \title{Report Title}
138
139 \author{A. N. Author}
140  
141 \maketitle 
142  
143 \begin{abstract}
144 there is no abstract
145 \end{abstract}
146
147 \chapter{Introduction}
148
149 The introduction is short.
150
151 \section{Acknowledgements}
152
153 The Acknowledgements are shown as well.  
154
155 To get a hard copy of this report call me.
156
157 \begin{figure}[htbp]
158 \begin{center}
159 \includegraphics{Fig1}
160 \caption{Zone and Node indexing}
161 \label{fig1}
162 \end{center}
163 \end{figure}
164
165 All done now.
166
167 \end{document}
168 """)
169
170 # makeindex will write status messages to stderr (grrr...), so ignore it.
171 test.run(arguments = '.', stderr=None)
172
173
174 # All (?) the files we expect will get created in the subdir
175 # (mybuild/docs) and not in the srcdir (docs).
176 files = [
177     'docs/test.aux',
178     'docs/test.log',
179     'docs/test.dvi',
180 ]
181
182 for f in files:
183     test.must_exist([ f])
184
185 test.must_not_exist(['docs/Fig1.pdf',])
186
187 test.pass_test()
188
189 # Local Variables:
190 # tab-width:4
191 # indent-tabs-mode:nil
192 # End:
193 # vim: set expandtab tabstop=4 shiftwidth=4: