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 open(target, "wb").write(open(source, "rb").read())
54 Build = Builder(action=copy)
55 env = Environment(BUILDERS={'Build':Build}, BBB='bbb')
56 env.Build('aaa.mid', 'aaa.in')
57 env.Build('aaa.out', 'aaa.mid')
61 VariantDir('build', 'src')
62 SConscript('build/SConscript')
65 test.write(['repository', 'src', 'SConscript'], r"""
66 def bbb_copy(env, source, target):
67 target = str(target[0])
69 open(target, "wb").write(open('build/bbb.1', "rb").read())
72 env.Build('bbb.1', 'bbb.0')
74 env.Command('bbb.2', 'bbb.x', bbb_copy)
75 env.Depends('bbb.2', 'bbb.1')
78 test.write(['repository', 'aaa.in'], "repository/aaa.in\n")
79 test.write(['repository', 'src', 'bbb.0'], "repository/src/bbb.0\n")
80 test.write(['repository', 'src', 'bbb.x'], "repository/src/bbb.x\n")
83 test.run(chdir = 'repository', options = opts, arguments = '.')
85 test.fail_test(test.read(repository_aaa_out) != "repository/aaa.in\n")
86 test.fail_test(test.read(repository_build_bbb_2) != "repository/src/bbb.0\n")
88 test.up_to_date(chdir = 'repository', options = opts, arguments = '.')
90 # Make the entire repository non-writable, so we'll detect
91 # if we try to write into it accidentally.
92 test.writable('repository', 0)
95 test.run(chdir = 'work', options = opts, arguments = 'aaa.out build/bbb.2')
97 test.fail_test(os.path.exists(work_aaa_mid))
98 test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n")
99 test.fail_test(test.read(work_build_bbb_1) != "repository/src/bbb.0\n")
100 test.fail_test(os.path.exists(work_build_bbb_2))
103 test.write(['work', 'aaa.in'], "work/aaa.in\n")
106 test.run(chdir = 'work', options = opts, arguments = '.')
108 test.fail_test(test.read(work_aaa_mid) != "work/aaa.in\n")
109 test.fail_test(test.read(work_aaa_out) != "work/aaa.in\n")
111 test.up_to_date(chdir = 'work', options = opts, arguments = '.')
118 # indent-tabs-mode:nil
120 # vim: set expandtab tabstop=4 shiftwidth=4: