Expanded SCons.Scanner.LaTeX.comment_re to not break on \%
[scons.git] / test / TEX / subdir_variantdir_include.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
32 Also check that we find files
33
34 Test case courtesy Joel B. Mohler.
35 """
36
37 import TestSCons
38
39 test = TestSCons.TestSCons()
40
41 #test.verbose_set(2)
42
43 latex = test.where_is('latex')
44 if not latex:
45     test.skip_test("Could not find 'latex'; skipping test.\n")
46
47 pdflatex = test.where_is('pdflatex')
48 if not pdflatex:
49     test.skip_test("Could not find 'pdflatex'; skipping test.\n")
50
51 test.subdir('docs')
52 test.subdir(['docs','sub'])
53 test.subdir(['docs','sub','sub2'])
54
55 test.write('SConstruct', """\
56 import os
57 env = Environment(TOOLS = ['tex', 'pdftex'],ENV = {'PATH' : os.environ['PATH']})
58
59 env.VariantDir('build', 'docs',duplicate=0)
60 env.SConscript('build/SConscript', exports = ['env'])
61 """)
62
63 test.write(['docs','SConscript'], """\
64 Import('env')
65
66 env.PDF( 'sub/x.tex' )
67 env.DVI( 'sub/x.tex' )
68 """)
69
70 test.write(['docs','sub', 'x.tex'],
71 r"""\documentclass{article}
72 \usepackage{makeidx}
73 \makeindex
74 \begin{document}
75 Hi there.
76 \index{info}
77 \include{sub2/y}
78 \printindex{}
79 \end{document}
80 """)
81
82 test.write(['docs','sub','sub2','y.tex'], """\
83 Sub-document 1
84 """)
85
86 #test.run(arguments = '.')
87 test.run(arguments = '.', stderr=None, stdout=None)
88
89 test.must_exist(['build', 'sub', 'x.aux'])
90 test.must_exist(['build', 'sub', 'x.dvi'])
91 test.must_exist(['build', 'sub', 'x.fls'])
92 test.must_exist(['build', 'sub', 'x.idx'])
93 test.must_exist(['build', 'sub', 'x.ilg'])
94 test.must_exist(['build', 'sub', 'x.ind'])
95 test.must_exist(['build', 'sub', 'x.log'])
96 test.must_exist(['build', 'sub', 'x.pdf'])
97
98 test.must_exist(['build', 'sub', 'sub2', 'y.aux'])
99
100 test.must_not_exist('x.aux')
101 test.must_not_exist('x.dvi')
102 test.must_not_exist('x.idx')
103 test.must_not_exist('x.ilg')
104 test.must_not_exist('x.ind')
105 test.must_not_exist('x.log')
106 test.must_not_exist('x.pdf')
107
108 test.must_not_exist(['docs', 'x.aux'])
109 test.must_not_exist(['docs', 'x.dvi'])
110 test.must_not_exist(['docs', 'x.idx'])
111 test.must_not_exist(['docs', 'x.ilg'])
112 test.must_not_exist(['docs', 'x.ind'])
113 test.must_not_exist(['docs', 'x.log'])
114 test.must_not_exist(['docs', 'x.pdf'])
115
116 test.must_not_exist(['docs', 'sub', 'x.aux'])
117 test.must_not_exist(['docs', 'sub', 'x.dvi'])
118 test.must_not_exist(['docs', 'sub', 'x.idx'])
119 test.must_not_exist(['docs', 'sub', 'x.ilg'])
120 test.must_not_exist(['docs', 'sub', 'x.ind'])
121 test.must_not_exist(['docs', 'sub', 'x.log'])
122 test.must_not_exist(['docs', 'sub', 'x.pdf'])
123
124 test.must_not_exist(['docs', 'sub', 'sub2', 'y.aux'])
125
126 test.up_to_date(arguments = '.', stderr=None, stdout=None)
127
128 test.write(['docs','sub', 'sub2', 'y.tex'], """\
129 Sub-document 2
130 """)
131
132 test.not_up_to_date(arguments = '.')
133 #test.up_to_date(arguments = '.', stderr=None, stdout=None)
134
135 test.pass_test()
136
137 # Local Variables:
138 # tab-width:4
139 # indent-tabs-mode:nil
140 # End:
141 # vim: set expandtab tabstop=4 shiftwidth=4: