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__"
28 Test that the -u option only builds targets at or below
29 the current directory.
37 test = TestSCons.TestSCons()
40 'sub2', ['sub2', 'dir'],
42 'sub4', ['sub4', 'dir'])
44 test.write('SConstruct', """
45 def cat(env, source, target):
46 target = str(target[0])
47 source = map(str, source)
48 f = open(target, "wb")
50 f.write(open(src, "rb").read())
53 env.Append(BUILDERS = {'Cat' : Builder(action=cat)})
54 env.Cat(target = 'sub1/f1a.out', source = 'sub1/f1a.in')
55 env.Cat(target = 'sub1/f1b.out', source = 'sub1/f1b.in')
57 SConscript('sub2/SConscript')
58 f3 = env.Cat(target = 'sub3/f3.out', source = 'sub3/f3.in')
59 env.Alias('my_alias', f3)
60 BuildDir('build', 'sub4')
61 SConscript('build/SConscript')
64 test.write(['sub2', 'SConscript'], """
66 env.Cat(target = 'f2a.out', source = 'f2a.in')
67 env.Cat(target = 'dir/f2b.out', source = 'dir/f2b.in')
70 test.write(['sub4', 'SConscript'], """
72 env.Cat(target = 'f4a.out', source = 'f4a.in')
73 f4b_in = File('dir/f4b.in')
76 f4b_in.is_pseudo_derived()
77 env.Cat(target = 'dir/f4b.out', source = f4b_in)
80 test.write(['sub1', 'f1a.in'], "sub1/f1a.in")
81 test.write(['sub1', 'f1b.in'], "sub1/f1b.in")
82 test.write(['sub2', 'f2a.in'], "sub2/f2a.in")
83 test.write(['sub2', 'dir', 'f2b.in'], "sub2/dir/f2b.in")
84 test.write(['sub3', 'f3.in'], "sub3/f3.in")
85 test.write(['sub4', 'f4a.in'], "sub4/f4a.in")
86 test.write(['sub4', 'dir', 'f4b.in'], "sub4/dir/f4b.in")
88 # Verify that we only build the specified local argument.
89 test.run(chdir = 'sub1', arguments = '-u f1a.out')
91 test.must_match(['sub1', 'f1a.out'], "sub1/f1a.in")
92 test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out'))
93 test.must_not_exist(test.workpath('sub2', 'f2a.out'))
94 test.must_not_exist(test.workpath('sub2', 'dir', 'f2b.out'))
95 test.must_not_exist(test.workpath('sub3', 'f3.out'))
96 test.must_not_exist(test.workpath('sub4', 'f4a.out'))
97 test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out'))
98 test.must_not_exist(test.workpath('build', 'f4a.out'))
99 test.must_not_exist(test.workpath('build', 'dir', 'f4b.out'))
101 # Verify that we build everything at or below our current directory.
102 test.run(chdir = 'sub2', arguments = '-u')
104 test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out'))
105 test.must_match(['sub2', 'f2a.out'], "sub2/f2a.in")
106 test.must_match(['sub2', 'dir', 'f2b.out'], "sub2/dir/f2b.in")
107 test.must_not_exist(test.workpath('sub3', 'f3.out'))
108 test.must_not_exist(test.workpath('sub4', 'f4a.out'))
109 test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out'))
110 test.must_not_exist(test.workpath('build', 'f4a.out'))
111 test.must_not_exist(test.workpath('build', 'dir', 'f4b.out'))
113 # Verify that we build a specified alias, regardless of where.
114 test.run(chdir = 'sub2', arguments = '-u my_alias')
116 test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out'))
117 test.must_match(['sub3', 'f3.out'], "sub3/f3.in")
118 test.must_not_exist(test.workpath('sub4', 'f4a.out'))
119 test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out'))
120 test.must_not_exist(test.workpath('build', 'f4a.out'))
121 test.must_not_exist(test.workpath('build', 'dir', 'f4b.out'))
123 # Verify that we build things in a linked BuildDir.
124 f4a_in = os.path.join('build', 'f4a.in')
125 f4a_out = os.path.join('build', 'f4a.out')
126 f4b_in = os.path.join('build', 'dir', 'f4b.in')
127 f4b_out = os.path.join('build', 'dir', 'f4b.out')
128 test.run(chdir = 'sub4',
130 stdout = "scons: Entering directory `%s'\n" % test.workpath() + \
131 test.wrap_stdout("""\
132 scons: building associated BuildDir targets: build
135 scons: `sub4' is up to date.
136 """ % (f4b_out, f4b_in, f4a_out, f4a_in)))
138 test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out'))
139 test.must_not_exist(test.workpath('sub4', 'f4a.out'))
140 test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out'))
141 test.must_match(['build', 'f4a.out'], "sub4/f4a.in")
142 test.must_match(['build', 'dir', 'f4b.out'], "sub4/dir/f4b.in")
144 # Make sure explicit targets beginning with ../ get built.
145 test.subdir('sub6', ['sub6', 'dir'])
147 test.write(['sub6', 'SConstruct'], """\
148 def cat(env, source, target):
149 target = str(target[0])
150 source = map(str, source)
151 f = open(target, "wb")
153 f.write(open(src, "rb").read())
155 env = Environment(BUILDERS={'Cat':Builder(action=cat)})
156 env.Cat('f1.out', 'f1.in')
157 env.Cat('f2.out', 'f2.in')
158 SConscript('dir/SConscript', "env")
161 test.write(['sub6', 'f1.in'], "f1.in\n")
162 test.write(['sub6', 'f2.in'], "f2.in\n")
164 test.write(['sub6', 'dir', 'SConscript'], """\
166 env.Cat('f3.out', 'f3.in')
167 env.Cat('f4.out', 'f4.in')
170 test.write(['sub6', 'dir', 'f3.in'], "f3.in\n")
171 test.write(['sub6', 'dir', 'f4.in'], "f4.in\n")
173 test.run(chdir = 'sub6/dir', arguments = '-u ../f2.out')
175 test.must_not_exist(test.workpath('sub6', 'f1.out'))
176 test.must_exist(test.workpath('sub6', 'f2.out'))
177 test.must_not_exist(test.workpath('sub6', 'dir', 'f3.out'))
178 test.must_not_exist(test.workpath('sub6', 'dir', 'f4.out'))