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__"
31 test
= TestSCons
.TestSCons()
33 _python_
= TestSCons
._python
_
35 test
.subdir('sub1', 'sub2', 'sub3')
37 test
.write('build.py', r
"""
39 with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp:
43 test
.write('SConstruct', r
"""
44 DefaultEnvironment(tools=[])
46 env = Environment(tools=[])
47 env['BUILDERS']['B'] = Builder(action=r'%(_python_)s build.py $TARGET $SOURCES', multi=1)
48 Default(env.B(target = 'sub1/foo.out', source = 'sub1/foo.in'))
50 SConscript('sub2/SConscript')
51 Default(env.B(target = 'sub3/baz.out', source = 'sub3/baz.in'))
52 VariantDir('sub2b', 'sub2')
53 SConscript('sub2b/SConscript')
54 Default(env.B(target = 'sub2/xxx.out', source = 'xxx.in'))
55 SConscript('SConscript')
58 test
.write(['sub2', 'SConscript'], """
60 bar = env.B(target = 'bar.out', source = 'bar.in')
63 Default(env.B(target = '../bar.out', source = 'bar.in'))
67 test
.write(['sub1', 'foo.in'], "sub1/foo.in\n")
68 test
.write(['sub2', 'bar.in'], "sub2/bar.in\n")
69 test
.write(['sub3', 'baz.in'], "sub3/baz.in\n")
70 test
.write('xxx.in', "xxx.in\n")
72 test
.write('SConscript', """assert GetLaunchDir() == r'%s'\n"""%test
.workpath('sub1'))
73 test
.run(arguments
= '-U foo.out', chdir
= 'sub1')
75 test
.must_exist(test
.workpath('sub1', 'foo.out'))
76 test
.must_not_exist(test
.workpath('sub2', 'bar.out'))
77 test
.must_not_exist(test
.workpath('sub2b', 'bar.out'))
78 test
.must_not_exist(test
.workpath('sub3', 'baz.out'))
79 test
.must_not_exist(test
.workpath('bar.out'))
80 test
.must_not_exist(test
.workpath('sub2/xxx.out'))
82 test
.unlink(['sub1', 'foo.out'])
84 test
.write('SConscript', """\
85 env = Environment(tools=[], )
86 assert env.GetLaunchDir() == r'%s'
87 """%test
.workpath('sub1'))
88 test
.run(arguments
= '-U',
90 stderr
= "scons: *** No targets specified and no Default() targets found. Stop.\n",
92 test
.must_not_exist(test
.workpath('sub1', 'foo.out'))
93 test
.must_not_exist(test
.workpath('sub2', 'bar.out'))
94 test
.must_not_exist(test
.workpath('sub2b', 'bar.out'))
95 test
.must_not_exist(test
.workpath('sub3', 'baz.out'))
96 test
.must_not_exist(test
.workpath('bar.out'))
97 test
.must_not_exist(test
.workpath('sub2/xxx.out'))
100 if sys
.platform
== 'win32':
104 test
.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test
.workpath(sub2
))
105 test
.run(chdir
= sub2
, arguments
= '-U')
106 test
.must_not_exist(test
.workpath('sub1', 'foo.out'))
107 test
.must_exist(test
.workpath('sub2', 'bar.out'))
108 test
.must_exist(test
.workpath('sub2b', 'bar.out'))
109 test
.must_not_exist(test
.workpath('sub3', 'baz.out'))
110 test
.must_exist(test
.workpath('bar.out'))
111 test
.must_not_exist(test
.workpath('sub2/xxx.out'))
113 test
.unlink(['sub2', 'bar.out'])
114 test
.unlink(['sub2b', 'bar.out'])
115 test
.unlink('bar.out')
117 test
.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test
.workpath())
118 test
.run(arguments
='-U')
119 test
.must_exist(test
.workpath('sub1', 'foo.out'))
120 test
.must_not_exist(test
.workpath('sub2', 'bar.out'))
121 test
.must_not_exist(test
.workpath('sub2b', 'bar.out'))
122 test
.must_exist(test
.workpath('sub3', 'baz.out'))
123 test
.must_not_exist(test
.workpath('bar.out'))
124 test
.must_exist(test
.workpath('sub2/xxx.out'))
126 test
.unlink(['sub1', 'foo.out'])
127 test
.unlink(['sub3', 'baz.out'])
128 test
.unlink(['sub2', 'xxx.out'])
130 test
.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test
.workpath('sub3'))
131 test
.run(chdir
= 'sub3', arguments
='-U bar')
132 test
.must_not_exist(test
.workpath('sub1', 'foo.out'))
133 test
.must_exist(test
.workpath('sub2', 'bar.out'))
134 test
.must_exist(test
.workpath('sub2b', 'bar.out'))
135 test
.must_not_exist(test
.workpath('sub3', 'baz.out'))
136 test
.must_not_exist(test
.workpath('bar.out'))
137 test
.must_not_exist(test
.workpath('sub2/xxx.out'))
143 # indent-tabs-mode:nil
145 # vim: set expandtab tabstop=4 shiftwidth=4: