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__"
30 test
= TestSCons
.TestSCons()
32 test
.subdir('work', 'repository', ['repository', 'src'])
34 work_aaa
= test
.workpath('work', 'aaa')
35 work_bbb
= test
.workpath('work', 'bbb')
36 work_ccc
= test
.workpath('work', 'ccc')
37 work_src_xxx
= test
.workpath('work', 'src', 'xxx')
38 work_src_yyy
= test
.workpath('work', 'src', 'yyy')
40 opts
= "-f " + test
.workpath('repository', 'SConstruct')
42 test
.write(['repository', 'SConstruct'], """\
44 def cat(env, source, target):
45 target = str(target[0])
46 with open(target, "wb") as ofp:
48 with open(str(src), "rb") as ifp:
51 env = Environment(BUILDERS={'Build':Builder(action=cat)})
52 env.Build('aaa.out', 'aaa.in')
53 env.Build('bbb.out', 'bbb.in')
54 env.Build('ccc.out', 'ccc.in')
55 SConscript('src/SConscript', "env")
56 """ % test
.workpath('repository'))
58 test
.write(['repository', 'src', 'SConscript'], """
60 env.Build('xxx.out', 'xxx.in')
61 env.Build('yyy.out', 'yyy.in')
64 test
.write(['repository', 'aaa.in'], "repository/aaa.in\n")
65 test
.write(['repository', 'bbb.in'], "repository/bbb.in\n")
66 test
.write(['repository', 'ccc.in'], "repository/ccc.in\n")
68 test
.write(['repository', 'src', 'xxx.in'], "repository/src/xxx.in\n")
69 test
.write(['repository', 'src', 'yyy.in'], "repository/src/yyy.in\n")
72 # Make the repository non-writable,
73 # so we'll detect if we try to write into it accidentally.
74 test
.writable('repository', 0)
77 test
.run(chdir
= 'work', options
= opts
, arguments
= 'aaa.out')
79 test
.must_match(['work', 'aaa.out'], "repository/aaa.in\n", mode
='r')
80 test
.fail_test(os
.path
.exists(test
.workpath('work', 'bbb.out')))
81 test
.fail_test(os
.path
.exists(test
.workpath('work', 'ccc.out')))
82 test
.fail_test(os
.path
.exists(test
.workpath('work', 'src', 'xxx.out')))
83 test
.fail_test(os
.path
.exists(test
.workpath('work', 'src', 'yyy.out')))
85 test
.run(chdir
= 'work', options
= opts
, arguments
= 'bbb.out src')
87 test
.must_match(['work', 'bbb.out'], "repository/bbb.in\n", mode
='r')
88 test
.fail_test(os
.path
.exists(test
.workpath('work', 'ccc.out')))
89 test
.must_match(['work', 'src', 'xxx.out'], "repository/src/xxx.in\n", mode
='r')
90 test
.must_match(['work', 'src', 'yyy.out'], "repository/src/yyy.in\n", mode
='r')
93 test
.run(chdir
= 'work', options
= opts
, arguments
= '.')
95 test
.must_match(['work', 'ccc.out'], "repository/ccc.in\n", mode
='r')
102 # indent-tabs-mode:nil
104 # vim: set expandtab tabstop=4 shiftwidth=4: