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 test
.subdir('repository', ['repository', 'src'],
34 'work', ['work', 'src'])
36 repository_aaa_out
= test
.workpath('repository', 'aaa.out')
37 repository_build_bbb_1
= test
.workpath('repository', 'build', 'bbb.1')
38 repository_build_bbb_2
= test
.workpath('repository', 'build', 'bbb.2')
39 work_aaa_mid
= test
.workpath('work', 'aaa.mid')
40 work_aaa_out
= test
.workpath('work', 'aaa.out')
41 work_build_bbb_1
= test
.workpath('work', 'build', 'bbb.1')
42 work_build_bbb_2
= test
.workpath('work', 'build', 'bbb.2')
44 opts
= "-Y " + test
.workpath('repository')
47 test
.write(['repository', 'SConstruct'], r
"""
48 def copy(env, source, target):
49 source = str(source[0])
50 target = str(target[0])
51 print('copy() < %s > %s' % (source, target))
52 with open(target, 'w') as ofp, open(source, 'r') as ifp:
55 Build = Builder(action=copy)
56 env = Environment(BUILDERS={'Build':Build}, BBB='bbb')
57 env.Build('aaa.mid', 'aaa.in')
58 env.Build('aaa.out', 'aaa.mid')
62 VariantDir('build', 'src')
63 SConscript('build/SConscript')
66 test
.write(['repository', 'src', 'SConscript'], r
"""
67 def bbb_copy(env, source, target):
68 target = str(target[0])
70 with open(target, 'w') as fo, open('build/bbb.1', 'r') as fi:
74 env.Build('bbb.1', 'bbb.0')
76 env.Command('bbb.2', 'bbb.x', bbb_copy)
77 env.Depends('bbb.2', 'bbb.1')
80 test
.write(['repository', 'aaa.in'], "repository/aaa.in\n")
81 test
.write(['repository', 'src', 'bbb.0'], "repository/src/bbb.0\n")
82 test
.write(['repository', 'src', 'bbb.x'], "repository/src/bbb.x\n")
85 test
.run(chdir
= 'repository', options
= opts
, arguments
= '.')
87 test
.must_match(repository_aaa_out
, "repository/aaa.in\n", mode
='r')
88 test
.must_match(repository_build_bbb_2
, "repository/src/bbb.0\n", mode
='r')
90 test
.up_to_date(chdir
= 'repository', options
= opts
, arguments
= '.')
92 # Make the entire repository non-writable, so we'll detect
93 # if we try to write into it accidentally.
94 test
.writable('repository', 0)
97 test
.run(chdir
= 'work', options
= opts
, arguments
= 'aaa.out build/bbb.2')
99 test
.fail_test(os
.path
.exists(work_aaa_mid
))
100 test
.must_match(work_aaa_out
, "repository/aaa.in\n", mode
='r')
101 test
.must_match(work_build_bbb_1
, "repository/src/bbb.0\n", mode
='r')
102 test
.fail_test(os
.path
.exists(work_build_bbb_2
))
105 test
.write(['work', 'aaa.in'], "work/aaa.in\n")
108 test
.run(chdir
= 'work', options
= opts
, arguments
= '.')
110 test
.must_match(work_aaa_mid
, "work/aaa.in\n", mode
='r')
111 test
.must_match(work_aaa_out
, "work/aaa.in\n", mode
='r')
113 test
.up_to_date(chdir
= 'work', options
= opts
, arguments
= '.')
120 # indent-tabs-mode:nil
122 # vim: set expandtab tabstop=4 shiftwidth=4: