Added fix for TeX includes with same name as subdirs.
[scons.git] / test / TEX / subdir_variantdir_input.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
54 test.write('SConstruct', """\
55 import os
56 env = Environment(TOOLS = ['tex', 'pdftex'],ENV = {'PATH' : os.environ['PATH']})
57
58 env.VariantDir('build', 'docs',duplicate=0)
59 env.SConscript('build/SConscript', exports = ['env'])
60 """)
61
62 test.write(['docs','SConscript'], """\
63 Import('env')
64
65 env.PDF( 'sub/x.tex' )
66 env.DVI( 'sub/x.tex' )
67 """)
68
69 test.write(['docs','sub', 'x.tex'],
70 r"""\documentclass{article}
71 \usepackage{makeidx}
72 \makeindex
73 \begin{document}
74 Hi there.
75 \index{info}
76 \input{y}
77 \printindex{}
78 \end{document}
79 """)
80
81 test.write(['docs','sub', 'y.tex'], """\
82 Sub-document 1
83 """)
84
85 #test.run(arguments = '.')
86 test.run(arguments = '.', stderr=None, stdout=None)
87
88 test.must_exist(['build', 'sub', 'x.aux'])
89 test.must_exist(['build', 'sub', 'x.dvi'])
90 test.must_exist(['build', 'sub', 'x.idx'])
91 test.must_exist(['build', 'sub', 'x.ilg'])
92 test.must_exist(['build', 'sub', 'x.ind'])
93 test.must_exist(['build', 'sub', 'x.log'])
94 test.must_exist(['build', 'sub', 'x.pdf'])
95
96 test.must_not_exist('x.aux')
97 test.must_not_exist('x.dvi')
98 test.must_not_exist('x.idx')
99 test.must_not_exist('x.ilg')
100 test.must_not_exist('x.ind')
101 test.must_not_exist('x.log')
102 test.must_not_exist('x.pdf')
103
104 test.must_not_exist(['docs', 'x.aux'])
105 test.must_not_exist(['docs', 'x.dvi'])
106 test.must_not_exist(['docs', 'x.idx'])
107 test.must_not_exist(['docs', 'x.ilg'])
108 test.must_not_exist(['docs', 'x.ind'])
109 test.must_not_exist(['docs', 'x.log'])
110 test.must_not_exist(['docs', 'x.pdf'])
111
112 test.must_not_exist(['docs', 'sub', 'x.aux'])
113 test.must_not_exist(['docs', 'sub', 'x.dvi'])
114 test.must_not_exist(['docs', 'sub', 'x.idx'])
115 test.must_not_exist(['docs', 'sub', 'x.ilg'])
116 test.must_not_exist(['docs', 'sub', 'x.ind'])
117 test.must_not_exist(['docs', 'sub', 'x.log'])
118 test.must_not_exist(['docs', 'sub', 'x.pdf'])
119
120 test.up_to_date(arguments = '.', stderr=None, stdout=None)
121
122 test.write(['docs','sub', 'y.tex'], """\
123 Sub-document 2
124 """)
125
126 test.not_up_to_date(arguments = '.')
127 #test.up_to_date(arguments = '.', stderr=None, stdout=None)
128
129 test.pass_test()
130
131 # Local Variables:
132 # tab-width:4
133 # indent-tabs-mode:nil
134 # End:
135 # vim: set expandtab tabstop=4 shiftwidth=4: