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.
27 Test how we handle SConscript calls when using a Repository.
31 from TestSCons
import TestSCons
42 ['rep2', 'src', 'sub'])
44 workpath_rep1
= test
.workpath('rep1')
45 workpath_rep2
= test
.workpath('rep2')
47 test
.write(['work', 'SConstruct'], """
49 SConscript('src/SConscript')
52 test
.write(['rep1', 'src', 'SConscript'], """\
53 def cat(env, source, target):
54 target = str(target[0])
55 with open(target, "w") as ofp:
57 with open(str(src), "r") as ifp:
60 env = Environment(BUILDERS={'Cat':Builder(action=cat)})
61 env.Cat(target = 'foo', source = ['aaa.in', 'bbb.in', 'ccc.in'])
64 test
.write(['rep1', 'src', 'aaa.in'], "rep1/src/aaa.in\n")
65 test
.write(['rep1', 'src', 'bbb.in'], "rep1/src/bbb.in\n")
66 test
.write(['rep1', 'src', 'ccc.in'], "rep1/src/ccc.in\n")
68 # Make the rep1 non-writable,
69 # so we'll detect if we try to write into it accidentally.
70 test
.writable('rep1', 0)
72 test
.run(chdir
= 'work', arguments
= ".")
74 test
.must_match(['work', 'src', 'foo'], """\
80 test
.up_to_date(chdir
= 'work', arguments
= ".")
83 test
.write(['rep2', 'build', 'SConstruct'], """
84 env = Environment(REPOSITORY = r'%s')
85 env.Repository('$REPOSITORY')
86 SConscript('src/SConscript')
89 test
.write(['rep2', 'src', 'SConscript'], """\
90 def cat(env, source, target):
91 target = str(target[0])
92 with open(target, "w") as ofp:
94 with open(str(src), "r") as ifp:
97 env = Environment(BUILDERS={'Cat':Builder(action=cat)})
98 env.Cat(target = 'foo', source = ['aaa.in', 'bbb.in', 'ccc.in'])
99 SConscript('sub/SConscript')
102 test
.write(['rep2', 'src', 'sub', 'SConscript'], """\
105 test
.write(['rep2', 'src', 'aaa.in'], "rep2/src/aaa.in\n")
106 test
.write(['rep2', 'src', 'bbb.in'], "rep2/src/bbb.in\n")
107 test
.write(['rep2', 'src', 'ccc.in'], "rep2/src/ccc.in\n")
109 test
.run(chdir
= 'rep2/build', arguments
= ".")
111 test
.must_match(['rep2', 'build', 'src', 'foo'], """\
122 # indent-tabs-mode:nil
124 # vim: set expandtab tabstop=4 shiftwidth=4: