Added fix for TeX includes with same name as subdirs.
[scons.git] / test / Ignore.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 import os.path
28
29 import TestSCons
30
31 _python_ = TestSCons._python_
32
33 test = TestSCons.TestSCons()
34
35 test.subdir('subdir')
36
37 test.write('build.py', r"""
38 import sys
39 contents = open(sys.argv[2], 'rb').read() + open(sys.argv[3], 'rb').read()
40 file = open(sys.argv[1], 'wb')
41 for arg in sys.argv[2:]:
42     file.write(open(arg, 'rb').read())
43 file.close()
44 """)
45
46 SUBDIR_f3_out = os.path.join('$SUBDIR', 'f3.out')
47 SUBDIR_f3b_in = os.path.join('$SUBDIR', 'f3b.in')
48
49 test.write('SConstruct', """\
50 Foo = Builder(action = r'%(_python_)s build.py $TARGET $SOURCES')
51 Bar = Builder(action = r'%(_python_)s build.py $TARGET $SOURCES')
52 env = Environment(BUILDERS = { 'Foo' : Foo, 'Bar' : Bar }, SUBDIR='subdir')
53 env.Foo(target = 'f1.out', source = ['f1a.in', 'f1b.in'])
54 Ignore(target = 'f1.out', dependency = 'f1b.in')
55 SConscript('subdir/SConscript', "env")
56 env.Foo(target = 'subdir/f3.out', source = ['subdir/f3a.in', 'subdir/f3b.in'])
57 env.Ignore(target = r'%(SUBDIR_f3_out)s', dependency = r'%(SUBDIR_f3b_in)s')
58 """ % locals())
59
60 test.write(['subdir', 'SConscript'], """
61 Import("env")
62 env.Bar(target = 'f2.out', source = ['f2a.in', 'f2b.in'])
63 env.Ignore('f2.out', 'f2a.in')
64 """)
65
66 test.write('f1a.in', "f1a.in\n")
67 test.write('f1b.in', "f1b.in\n")
68
69 test.write(['subdir', 'f2a.in'], "subdir/f2a.in\n")
70 test.write(['subdir', 'f2b.in'], "subdir/f2b.in\n")
71
72 test.write(['subdir', 'f3a.in'], "subdir/f3a.in\n")
73 test.write(['subdir', 'f3b.in'], "subdir/f3b.in\n")
74
75 test.run(arguments = '.')
76
77 test.must_match('f1.out', "f1a.in\nf1b.in\n")
78 test.must_match(['subdir', 'f2.out'], "subdir/f2a.in\nsubdir/f2b.in\n")
79 test.must_match(['subdir', 'f3.out'], "subdir/f3a.in\nsubdir/f3b.in\n")
80
81 test.up_to_date(arguments = '.')
82
83 test.write('f1b.in', "f1b.in 2\n")
84 test.write(['subdir', 'f2a.in'], "subdir/f2a.in 2\n")
85 test.write(['subdir', 'f3b.in'], "subdir/f3b.in 2\n")
86
87 test.up_to_date(arguments = '.')
88
89 test.must_match('f1.out', "f1a.in\nf1b.in\n")
90 test.must_match(['subdir', 'f2.out'], "subdir/f2a.in\nsubdir/f2b.in\n")
91 test.must_match(['subdir', 'f3.out'], "subdir/f3a.in\nsubdir/f3b.in\n")
92
93 test.write('f1a.in', "f1a.in 2\n")
94 test.write(['subdir', 'f2b.in'], "subdir/f2b.in 2\n")
95 test.write(['subdir', 'f3a.in'], "subdir/f3a.in 2\n")
96
97 test.run(arguments = '.')
98
99 test.must_match('f1.out', "f1a.in 2\nf1b.in 2\n")
100 test.must_match(['subdir', 'f2.out'], "subdir/f2a.in 2\nsubdir/f2b.in 2\n")
101 test.must_match(['subdir', 'f3.out'], "subdir/f3a.in 2\nsubdir/f3b.in 2\n")
102
103 test.up_to_date(arguments = '.')
104
105 #
106 test.write('SConstruct', """\
107 env = Environment()
108 file1 = File('file1')
109 file2 = File('file2')
110 env.Ignore(file1, [[file2, 'file3']])
111 """)
112
113 test.up_to_date(arguments = '.')
114
115 test.pass_test()
116
117 # Local Variables:
118 # tab-width:4
119 # indent-tabs-mode:nil
120 # End:
121 # vim: set expandtab tabstop=4 shiftwidth=4: