[ci skip] update generated files
[scons.git] / test / Climb / option--D.py
blob169678aef5ab5bc2472dde512963f6061c6ba6d8
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 import TestSCons
28 _python_ = TestSCons._python_
30 test = TestSCons.TestSCons()
32 test.subdir('sub1', 'sub2')
34 test.write('build.py', r"""
35 import sys
36 with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp:
37 ofp.write(ifp.read())
38 """)
40 test.write('SConstruct', """
41 DefaultEnvironment(tools=[])
42 import SCons.Defaults
43 B = Builder(action=r'%(_python_)s build.py $TARGET $SOURCES')
44 env = Environment(tools=[])
45 env['BUILDERS']['B'] = B
46 env.B(target = 'sub1/foo.out', source = 'sub1/foo.in')
47 Export('env')
48 SConscript('sub1/SConscript')
49 SConscript('sub2/SConscript')
50 """ % locals())
52 test.write(['sub1', 'SConscript'], """
53 Import('env')
54 env.B(target = 'foo.out', source = 'foo.in')
55 Default('.')
56 """)
58 test.write(['sub1', 'foo.in'], "sub1/foo.in")
60 test.write(['sub2', 'SConscript'], """
61 Import('env')
62 env.Alias('bar', env.B(target = 'bar.out', source = 'bar.in'))
63 Default('.')
65 """)
67 test.write(['sub2', 'bar.in'], "sub2/bar.in")
69 test.run(arguments = '-D', chdir = 'sub1')
71 test.must_match(['sub1', 'foo.out'], "sub1/foo.in")
72 test.must_match(['sub2', 'bar.out'], "sub2/bar.in")
74 test.unlink(['sub1', 'foo.out'])
75 test.unlink(['sub2', 'bar.out'])
77 test.run(arguments = '-D bar', chdir = 'sub1')
79 test.must_not_exist(test.workpath('sub1', 'foo.out'))
80 test.must_exist(test.workpath('sub2', 'bar.out'))
83 test.pass_test()
85 # Local Variables:
86 # tab-width:4
87 # indent-tabs-mode:nil
88 # End:
89 # vim: set expandtab tabstop=4 shiftwidth=4: