3 # Copyright (c) 2001, 2002, 2003 Steven Knight
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 'work1', ['work1', 'src'],
35 'work2', ['work2', 'src'])
37 opts = "-Y " + test.workpath('repository')
40 test.write(['repository', 'SConstruct'], r"""
41 BuildDir('build0', 'src', duplicate=0)
42 BuildDir('build1', 'src', duplicate=1)
43 SConscript('build0/SConscript')
44 SConscript('build1/SConscript')
47 test.write(['repository', 'src', 'SConscript'], r"""
48 def cat(env, source, target):
49 target = str(target[0])
50 source = map(str, source)
51 print 'cat(%s) > %s' % (source, target)
52 f = open(target, "wb")
54 f.write(open(src, "rb").read())
57 env = Environment(BUILDERS={'Build':Builder(action=cat)})
58 env.Build('aaa.mid', 'aaa.in')
59 env.Build('bbb.mid', 'bbb.in')
60 env.Build('ccc.mid', 'ccc.in')
61 env.Build('output', ['aaa.mid', 'bbb.mid', 'ccc.mid'])
64 test.write(['repository', 'src', 'aaa.in'], "repository/src/aaa.in\n")
65 test.write(['repository', 'src', 'bbb.in'], "repository/src/bbb.in\n")
66 test.write(['repository', 'src', 'ccc.in'], "repository/src/ccc.in\n")
68 # Make the entire repository non-writable, so we'll detect
69 # if we try to write into it accidentally.
70 test.writable('repository', 0)
73 test.run(chdir = 'work1', options = opts, arguments = '.')
75 test.fail_test(test.read(['work1', 'build0', 'output']) !=
76 """repository/src/aaa.in
81 test.fail_test(os.path.exists('work1/build0/aaa.in'))
82 test.fail_test(os.path.exists('work1/build0/bbb.in'))
83 test.fail_test(os.path.exists('work1/build0/ccc.in'))
84 test.fail_test(not os.path.exists('work1/build0/aaa.mid'))
85 test.fail_test(not os.path.exists('work1/build0/bbb.mid'))
86 test.fail_test(not os.path.exists('work1/build0/ccc.mid'))
88 test.fail_test(test.read(['work1', 'build1', 'output']) !=
89 """repository/src/aaa.in
94 test.fail_test(not os.path.exists('work1/build1/aaa.in'))
95 test.fail_test(not os.path.exists('work1/build1/bbb.in'))
96 test.fail_test(not os.path.exists('work1/build1/ccc.in'))
97 test.fail_test(not os.path.exists('work1/build1/aaa.mid'))
98 test.fail_test(not os.path.exists('work1/build1/bbb.mid'))
99 test.fail_test(not os.path.exists('work1/build1/ccc.mid'))
101 test.up_to_date(chdir = 'work1', options = opts, arguments = '.')
104 test.write(['work1', 'src', 'bbb.in'], "work1/src/bbb.in\n")
106 test.run(chdir = 'work1', options = opts, arguments = '.')
108 test.fail_test(test.read(['work1', 'build0', 'output']) !=
109 """repository/src/aaa.in
111 repository/src/ccc.in
114 test.fail_test(os.path.exists('work1/build0/aaa.in'))
115 test.fail_test(os.path.exists('work1/build0/bbb.in'))
116 test.fail_test(os.path.exists('work1/build0/ccc.in'))
117 test.fail_test(not os.path.exists('work1/build0/aaa.mid'))
118 test.fail_test(not os.path.exists('work1/build0/bbb.mid'))
119 test.fail_test(not os.path.exists('work1/build0/ccc.mid'))
121 test.fail_test(test.read(['work1', 'build1', 'output']) !=
122 """repository/src/aaa.in
124 repository/src/ccc.in
127 test.fail_test(not os.path.exists('work1/build1/aaa.in'))
128 test.fail_test(not os.path.exists('work1/build1/bbb.in'))
129 test.fail_test(not os.path.exists('work1/build1/ccc.in'))
130 test.fail_test(not os.path.exists('work1/build1/aaa.mid'))
131 test.fail_test(not os.path.exists('work1/build1/bbb.mid'))
132 test.fail_test(not os.path.exists('work1/build1/ccc.mid'))
134 test.up_to_date(chdir = 'work1', options = opts, arguments = '.')
136 # Now build the stuff in the repository,
137 # and redo the above steps in a fresh work directory.
138 test.writable('repository', 1)
140 test.run(chdir = 'repository', arguments = '.')
142 test.writable('repository', 0)
145 test.run(chdir = 'work2', options = opts, arguments = '.')
147 test.fail_test(os.path.exists('work2/build0/aaa.in'))
148 test.fail_test(os.path.exists('work2/build0/bbb.in'))
149 test.fail_test(os.path.exists('work2/build0/ccc.in'))
150 test.fail_test(os.path.exists('work2/build0/aaa.mid'))
151 test.fail_test(os.path.exists('work2/build0/bbb.mid'))
152 test.fail_test(os.path.exists('work2/build0/ccc.mid'))
153 test.fail_test(os.path.exists('work2/build0/output'))
155 test.fail_test(not os.path.exists('work2/build1/aaa.in'))
156 test.fail_test(not os.path.exists('work2/build1/bbb.in'))
157 test.fail_test(not os.path.exists('work2/build1/ccc.in'))
158 test.fail_test(os.path.exists('work2/build1/aaa.mid'))
159 test.fail_test(os.path.exists('work2/build1/bbb.mid'))
160 test.fail_test(os.path.exists('work2/build1/ccc.mid'))
161 test.fail_test(os.path.exists('work2/build1/output'))
163 test.up_to_date(chdir = 'work2', options = opts, arguments = '.')
166 test.write(['work2', 'src', 'bbb.in'], "work2/src/bbb.in\n")
168 test.run(chdir = 'work2', options = opts, arguments = '.')
170 test.fail_test(test.read(['work2', 'build0', 'output']) !=
171 """repository/src/aaa.in
173 repository/src/ccc.in
176 test.fail_test(os.path.exists('work2/build0/aaa.in'))
177 test.fail_test(os.path.exists('work2/build0/bbb.in'))
178 test.fail_test(os.path.exists('work2/build0/ccc.in'))
179 test.fail_test(os.path.exists('work2/build0/aaa.mid'))
180 test.fail_test(not os.path.exists('work2/build0/bbb.mid'))
181 test.fail_test(os.path.exists('work2/build0/ccc.mid'))
183 test.fail_test(test.read(['work2', 'build1', 'output']) !=
184 """repository/src/aaa.in
186 repository/src/ccc.in
189 test.fail_test(not os.path.exists('work2/build1/aaa.in'))
190 test.fail_test(not os.path.exists('work2/build1/bbb.in'))
191 test.fail_test(not os.path.exists('work2/build1/ccc.in'))
192 test.fail_test(os.path.exists('work2/build1/aaa.mid'))
193 test.fail_test(not os.path.exists('work2/build1/bbb.mid'))
194 test.fail_test(os.path.exists('work2/build1/ccc.mid'))
196 test.up_to_date(chdir = 'work2', options = opts, arguments = '.')