added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / Ignore.py
blob053f785a0ebf15912f06967a6bbdfd6026244c2f
1 #!/usr/bin/env python
3 # __COPYRIGHT__
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:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
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.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
27 import os.path
29 import TestSCons
31 _python_ = TestSCons._python_
33 test = TestSCons.TestSCons()
35 test.subdir('subdir')
37 test.write('build.py', r"""
38 import sys
39 with open(sys.argv[2], 'rb') as afp2, open(sys.argv[3], 'rb') as afp3:
40 contents = afp2.read() + afp3.read()
41 with open(sys.argv[1], 'wb') as f:
42 for arg in sys.argv[2:]:
43 with open(arg, 'rb') as ifp:
44 f.write(ifp.read())
45 """)
47 SUBDIR_f3_out = os.path.join('$SUBDIR', 'f3.out')
48 SUBDIR_f3b_in = os.path.join('$SUBDIR', 'f3b.in')
50 test.write('SConstruct', """\
51 Foo = Builder(action = r'%(_python_)s build.py $TARGET $SOURCES')
52 Bar = Builder(action = r'%(_python_)s build.py $TARGET $SOURCES')
53 env = Environment(BUILDERS = { 'Foo' : Foo, 'Bar' : Bar }, SUBDIR='subdir')
54 env.Foo(target = 'f1.out', source = ['f1a.in', 'f1b.in'])
55 Ignore(target = 'f1.out', dependency = 'f1b.in')
56 SConscript('subdir/SConscript', "env")
57 env.Foo(target = 'subdir/f3.out', source = ['subdir/f3a.in', 'subdir/f3b.in'])
58 env.Ignore(target = r'%(SUBDIR_f3_out)s', dependency = r'%(SUBDIR_f3b_in)s')
59 """ % locals())
61 test.write(['subdir', 'SConscript'], """
62 Import("env")
63 env.Bar(target = 'f2.out', source = ['f2a.in', 'f2b.in'])
64 env.Ignore('f2.out', 'f2a.in')
65 """)
67 test.write('f1a.in', "f1a.in\n")
68 test.write('f1b.in', "f1b.in\n")
70 test.write(['subdir', 'f2a.in'], "subdir/f2a.in\n")
71 test.write(['subdir', 'f2b.in'], "subdir/f2b.in\n")
73 test.write(['subdir', 'f3a.in'], "subdir/f3a.in\n")
74 test.write(['subdir', 'f3b.in'], "subdir/f3b.in\n")
76 test.run(arguments = '.')
78 test.must_match('f1.out', "f1a.in\nf1b.in\n")
79 test.must_match(['subdir', 'f2.out'], "subdir/f2a.in\nsubdir/f2b.in\n")
80 test.must_match(['subdir', 'f3.out'], "subdir/f3a.in\nsubdir/f3b.in\n")
82 test.up_to_date(arguments = '.')
84 test.write('f1b.in', "f1b.in 2\n")
85 test.write(['subdir', 'f2a.in'], "subdir/f2a.in 2\n")
86 test.write(['subdir', 'f3b.in'], "subdir/f3b.in 2\n")
88 test.up_to_date(arguments = '.')
90 test.must_match('f1.out', "f1a.in\nf1b.in\n")
91 test.must_match(['subdir', 'f2.out'], "subdir/f2a.in\nsubdir/f2b.in\n")
92 test.must_match(['subdir', 'f3.out'], "subdir/f3a.in\nsubdir/f3b.in\n")
94 test.write('f1a.in', "f1a.in 2\n")
95 test.write(['subdir', 'f2b.in'], "subdir/f2b.in 2\n")
96 test.write(['subdir', 'f3a.in'], "subdir/f3a.in 2\n")
98 test.run(arguments = '.')
100 test.must_match('f1.out', "f1a.in 2\nf1b.in 2\n")
101 test.must_match(['subdir', 'f2.out'], "subdir/f2a.in 2\nsubdir/f2b.in 2\n")
102 test.must_match(['subdir', 'f3.out'], "subdir/f3a.in 2\nsubdir/f3b.in 2\n")
104 test.up_to_date(arguments = '.')
107 test.write('SConstruct', """\
108 env = Environment()
109 file1 = File('file1')
110 file2 = File('file2')
111 env.Ignore(file1, [[file2, 'file3']])
112 """)
114 test.up_to_date(arguments = '.')
116 test.pass_test()
118 # Local Variables:
119 # tab-width:4
120 # indent-tabs-mode:nil
121 # End:
122 # vim: set expandtab tabstop=4 shiftwidth=4: