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__"
29 test
= TestSCons
.TestSCons()
31 test
.write('foo.py', "foo = 4\n")
34 test
.write('SConstruct', """\
37 from collections import UserList
41 print("SConstruct "+ os.getcwd())
42 SConscript('SConscript')
46 x3,x4 = SConscript('SConscript1', "x1 x2")
47 assert x3 == "SConscript1 x3", x3
48 assert x4 == "SConscript1 x4", x4
50 (x3,x4) = SConscript('SConscript2', ["x1","x2"])
51 assert x3 == "SConscript2 x3", x3
52 assert x4 == "SConscript2 x4", x4
55 SConscript('SConscript3')
57 assert x1 == "SConscript3 x1", x1
58 assert x2 == "SConscript3 x2", x2
63 SConscript('SConscript4')
65 assert x1 == "SConscript4 x1", x1
66 assert x2 == "SConscript4 x2", x2
68 subdir = Dir('subdir')
69 script = File('SConscript', subdir)
70 foo = SConscript(script)
71 assert foo == "subdir/SConscript foo"
73 SConscript('SConscript5')
77 x9 = SConscript('SConscript6', UserList(["x7", "x8"]))
78 assert x9 == "SConscript6 x9", x9
80 SConscript('SConscript7')
84 test
.write('SConscript', """\
85 # os should not be automatically imported:
86 assert "os" not in globals()
89 print("SConscript " + os.getcwd())
92 test
.write('SConscript1', """
94 assert x1 == "SConstruct x1", x1
95 assert x2 == "SConstruct x2", x2
103 test
.write('SConscript2', """\
105 assert x1 == "SConstruct x1", x1
106 assert x2 == "SConstruct x2", x2
107 x3 = "SConscript2 x3"
108 x4 = "SConscript2 x4"
113 test
.write('SConscript3', """\
115 assert x1 == "SConstruct x1", x1
116 assert x2 == "SConstruct x2", x2
117 x1 = "SConscript3 x1"
118 x2 = "SConscript3 x2"
120 x5 = SConscript('SConscript31', "x1")
122 assert x5 == "SConscript31 x5", x5
123 assert x6 == "SConscript31 x6", x6
129 test
.write('SConscript31', """\
131 assert x1 == "SConscript3 x1", x1
132 assert x2 == "SConstruct x2", x2
133 x5 = "SConscript31 x5"
134 x6 = "SConscript31 x6"
140 test
.write('SConscript4', """\
142 assert x1 == "SConstruct x1", x1
143 assert x2 == "SConstruct x2", x2
144 x1 = "SConscript4 x1"
145 x2 = "SConscript4 x2"
150 test
.subdir('subdir')
151 test
.write(['subdir', 'SConscript'], """\
152 foo = 'subdir/SConscript foo'
157 test
.write('SConscript5', """\
158 B = Builder(action = 'B')
161 S = Scanner(function = scan)
166 test
.write('SConscript6', """\
168 assert x7 == "SConstruct x7", x7
169 assert x8 == "SConstruct x8", x8
170 x9 = "SConscript6 x9"
175 test
.write('SConscript7', """\
176 result1 = ((1, 3), -4)
177 result2 = ((2, 3), -4)
178 assert result1 == SConscript(Split('foo/SConscript bar/SConscript'))
179 assert result1 == SConscript(['foo/SConscript', 'bar/SConscript'])
180 assert result1 == SConscript([File('foo/SConscript'), File('bar/SConscript')])
181 assert result1 == SConscript(dirs = Split('foo bar'))
182 assert result1 == SConscript(dirs = ['foo', 'bar'])
183 assert result2 == SConscript(dirs = Split('foo bar'), name = 'subscript')
184 assert result2 == SConscript(dirs = ['foo', 'bar'], name = 'subscript')
185 assert result1 == SConscript(dirs = ['foo', Dir('bar')])
186 assert result2 == SConscript(dirs = [Dir('foo'), 'bar'], name = 'subscript')
187 assert 5 == SConscript('w s/SConscript')
188 assert (-4, 5) == SConscript(['bar/SConscript', 'w s/SConscript'])
192 assert (3, 2) == SConscript(dirs = 'baz', exports = "x1 x2")
193 assert (3, 2) == SConscript('baz/SConscript', 'x1', exports = 'x2')
194 assert (3, 2) == SConscript('baz/SConscript', exports = 'x1 x2')
197 fooscript
= "x = %d; y = 3; Return('x y')\n"
198 barscript
= "x = -4; Return('x')\n"
200 test
.subdir('foo', 'bar', 'baz', 'w s')
201 test
.write(['foo', 'SConscript'], fooscript
% 1)
202 test
.write(['foo', 'subscript'], fooscript
% 2)
203 test
.write(['bar', 'SConscript'], barscript
)
204 test
.write(['bar', 'subscript'], barscript
)
205 test
.write(['baz', 'SConscript'], """\
210 test
.write(['w s', 'SConscript'], "x = 5; Return('x')\n")
213 wpath
= test
.workpath()
215 test
.run(arguments
= ".",
216 stdout
= test
.wrap_stdout(read_str
= 'SConstruct %s\nSConscript %s\n' % (wpath
, wpath
),
217 build_str
= "scons: `.' is up to date.\n"))
223 # indent-tabs-mode:nil
225 # vim: set expandtab tabstop=4 shiftwidth=4: