1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
#!/usr/bin/env python
#
# __COPYRIGHT__
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
Test fetching source files from CVS.
"""
import os
import TestSCons
test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
test.write('SConscript', """
Environment(tools = ['CVS']).CVS('')
""")
msg_cvs = """The CVS() factory is deprecated and there is no replacement."""
warn_cvs = test.deprecated_fatal('deprecated-build-dir', msg_cvs)
msg_sc = """SourceCode() has been deprecated and there is no replacement.
\tIf you need this function, please contact dev@scons.tigris.org."""
warn_sc = test.deprecated_wrap(msg_sc)
cvs = test.where_is('cvs')
if not cvs:
test.skip_test("Could not find 'cvs'; skipping remaining tests.\n")
test.subdir('CVS', 'import', ['import', 'sub'], 'work1', 'work2')
foo_aaa_in = os.path.join('foo', 'aaa.in')
foo_bbb_in = os.path.join('foo', 'bbb.in')
foo_ccc_in = os.path.join('foo', 'ccc.in')
foo_sub_ddd_in = os.path.join('foo', 'sub', 'ddd.in')
foo_sub_ddd_out = os.path.join('foo', 'sub', 'ddd.out')
foo_sub_eee_in = os.path.join('foo', 'sub', 'eee.in')
foo_sub_eee_out = os.path.join('foo', 'sub', 'eee.out')
foo_sub_fff_in = os.path.join('foo', 'sub', 'fff.in')
foo_sub_fff_out = os.path.join('foo', 'sub', 'fff.out')
foo_sub_all = os.path.join('foo', 'sub', 'all')
sub_SConscript = os.path.join('sub', 'SConscript')
sub_ddd_in = os.path.join('sub', 'ddd.in')
sub_ddd_out = os.path.join('sub', 'ddd.out')
sub_eee_in = os.path.join('sub', 'eee.in')
sub_eee_out = os.path.join('sub', 'eee.out')
sub_fff_in = os.path.join('sub', 'fff.in')
sub_fff_out = os.path.join('sub', 'fff.out')
sub_all = os.path.join('sub', 'all')
# Set up the CVS repository.
cvsroot = test.workpath('CVS')
os.environ['CVSROOT'] = cvsroot
test.run(program = cvs, arguments = 'init')
test.write(['import', 'aaa.in'], "import/aaa.in\n")
test.write(['import', 'bbb.in'], "import/bbb.in\n")
test.write(['import', 'ccc.in'], "import/ccc.in\n")
test.write(['import', 'sub', 'SConscript'], """\
Import("env")
env.Cat('ddd.out', 'ddd.in')
env.Cat('eee.out', 'eee.in')
env.Cat('fff.out', 'fff.in')
env.Cat('all', ['ddd.out', 'eee.out', 'fff.out'])
""")
test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n")
test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n")
test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n")
test.run(chdir = 'import',
program = cvs,
arguments = '-q import -m import foo v v-r')
# Test the most straightforward CVS checkouts, using the module name.
test.write(['work1', 'SConstruct'], """
SetOption('warn', 'deprecated-source-code')
import os
def cat(env, source, target):
target = str(target[0])
f = open(target, "wb")
for src in source:
f.write(open(str(src), "rb").read())
f.close()
env = Environment(ENV = { 'PATH' : os.environ['PATH'],
'EDITOR' : os.environ.get('EDITOR', 'ed') },
BUILDERS={'Cat':Builder(action=cat)})
env.Prepend(CVSFLAGS='-Q')
env.Cat('aaa.out', 'foo/aaa.in')
env.Cat('bbb.out', 'foo/bbb.in')
env.Cat('ccc.out', 'foo/ccc.in')
env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
env.SourceCode('.', env.CVS(r'%(cvsroot)s'))
SConscript('foo/sub/SConscript', "env")
""" % locals())
test.subdir(['work1', 'foo'])
test.write(['work1', 'foo', 'bbb.in'], "work1/foo/bbb.in\n")
test.subdir(['work1', 'foo', 'sub',])
test.write(['work1', 'foo', 'sub', 'eee.in'], "work1/foo/sub/eee.in\n")
read_str = """\
cvs -Q -d %(cvsroot)s co foo/sub/SConscript
""" % locals()
build_str = """\
cvs -Q -d %(cvsroot)s co foo/aaa.in
cat(["aaa.out"], ["%(foo_aaa_in)s"])
cat(["bbb.out"], ["%(foo_bbb_in)s"])
cvs -Q -d %(cvsroot)s co foo/ccc.in
cat(["ccc.out"], ["%(foo_ccc_in)s"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
cvs -Q -d %(cvsroot)s co foo/sub/ddd.in
cat(["%(foo_sub_ddd_out)s"], ["%(foo_sub_ddd_in)s"])
cat(["%(foo_sub_eee_out)s"], ["%(foo_sub_eee_in)s"])
cvs -Q -d %(cvsroot)s co foo/sub/fff.in
cat(["%(foo_sub_fff_out)s"], ["%(foo_sub_fff_in)s"])
cat(["%(foo_sub_all)s"], ["%(foo_sub_ddd_out)s", "%(foo_sub_eee_out)s", "%(foo_sub_fff_out)s"])
""" % locals()
stdout = test.wrap_stdout(read_str = read_str, build_str = build_str)
test.run(chdir = 'work1',
arguments = '.',
stdout = TestSCons.re_escape(stdout),
stderr = warn_cvs + warn_sc)
# Checking things back out of CVS apparently messes with the line
# endings, so read the result files in non-binary mode.
test.must_match(['work1', 'all'],
"import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n",
mode='r')
test.must_match(['work1', 'foo', 'sub', 'all'],
"import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n",
mode='r')
test.must_be_writable(test.workpath('work1', 'foo', 'sub', 'SConscript'))
test.must_be_writable(test.workpath('work1', 'foo', 'aaa.in'))
test.must_be_writable(test.workpath('work1', 'foo', 'ccc.in'))
test.must_be_writable(test.workpath('work1', 'foo', 'sub', 'ddd.in'))
test.must_be_writable(test.workpath('work1', 'foo', 'sub', 'fff.in'))
# Test CVS checkouts when the module name is specified.
test.write(['work2', 'SConstruct'], """
SetOption('warn', 'deprecated-source-code')
import os
def cat(env, source, target):
target = str(target[0])
f = open(target, "wb")
for src in source:
f.write(open(str(src), "rb").read())
f.close()
env = Environment(ENV = { 'PATH' : os.environ['PATH'],
'EDITOR' : os.environ.get('EDITOR', 'ed') },
BUILDERS={'Cat':Builder(action=cat)})
env.Prepend(CVSFLAGS='-q')
env.Cat('aaa.out', 'aaa.in')
env.Cat('bbb.out', 'bbb.in')
env.Cat('ccc.out', 'ccc.in')
env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
env.SourceCode('.', env.CVS(r'%(cvsroot)s', 'foo'))
SConscript('sub/SConscript', "env")
""" % locals())
test.write(['work2', 'bbb.in'], "work2/bbb.in\n")
test.subdir(['work2', 'sub'])
test.write(['work2', 'sub', 'eee.in'], "work2/sub/eee.in\n")
read_str = """\
cvs -q -d %(cvsroot)s co -d sub foo/sub/SConscript
U sub/SConscript
""" % locals()
build_str = """\
cvs -q -d %(cvsroot)s co -d . foo/aaa.in
U ./aaa.in
cat(["aaa.out"], ["aaa.in"])
cat(["bbb.out"], ["bbb.in"])
cvs -q -d %(cvsroot)s co -d . foo/ccc.in
U ./ccc.in
cat(["ccc.out"], ["ccc.in"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
cvs -q -d %(cvsroot)s co -d sub foo/sub/ddd.in
U sub/ddd.in
cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
cvs -q -d %(cvsroot)s co -d sub foo/sub/fff.in
U sub/fff.in
cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
""" % locals()
stdout = test.wrap_stdout(read_str = read_str, build_str = build_str)
test.run(chdir = 'work2',
arguments = '.',
stdout = TestSCons.re_escape(stdout),
stderr = warn_cvs + warn_sc)
# Checking things back out of CVS apparently messes with the line
# endings, so read the result files in non-binary mode.
test.must_match(['work2', 'all'],
"import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n",
mode='r')
test.must_match(['work2', 'sub', 'all'],
"import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n",
mode='r')
test.must_be_writable(test.workpath('work2', 'sub', 'SConscript'))
test.must_be_writable(test.workpath('work2', 'aaa.in'))
test.must_be_writable(test.workpath('work2', 'ccc.in'))
test.must_be_writable(test.workpath('work2', 'sub', 'ddd.in'))
test.must_be_writable(test.workpath('work2', 'sub', 'fff.in'))
# Test checking out specific file name(s), and expanding
# the repository name with a variable.
test.subdir(['work3'])
test.write(['work3', 'SConstruct'], """\
SetOption('warn', 'deprecated-source-code')
import os
def cat(env, source, target):
target = str(target[0])
f = open(target, "wb")
for src in source:
f.write(open(str(src), "rb").read())
f.close()
env = Environment(ENV = { 'PATH' : os.environ['PATH'],
'EDITOR' : os.environ.get('EDITOR', 'ed') },
BUILDERS={'Cat':Builder(action=cat)},
CVSROOT=r'%s')
env.Prepend(CVSFLAGS='-q')
env.Cat('aaa.out', 'aaa.in')
env.Cat('bbb.out', 'bbb.in')
env.Cat('ccc.out', 'ccc.in')
env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
cvs = env.CVS('$CVSROOT', 'foo')
env.SourceCode('aaa.in', cvs)
env.SourceCode('bbb.in', cvs)
env.SourceCode('ccc.in', cvs)
""" % cvsroot)
build_str = """\
cvs -q -d %(cvsroot)s co -d . foo/aaa.in
U ./aaa.in
cat(["aaa.out"], ["aaa.in"])
cvs -q -d %(cvsroot)s co -d . foo/bbb.in
U ./bbb.in
cat(["bbb.out"], ["bbb.in"])
cvs -q -d %(cvsroot)s co -d . foo/ccc.in
U ./ccc.in
cat(["ccc.out"], ["ccc.in"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
""" % locals()
stdout = test.wrap_stdout(build_str = build_str)
test.run(chdir = 'work3',
arguments = '.',
stdout = TestSCons.re_escape(stdout),
stderr = warn_cvs + 3*warn_sc)
test.must_match(['work3', 'aaa.out'],
"import/aaa.in\n",
mode='r')
test.must_match(['work3', 'bbb.out'],
"import/bbb.in\n",
mode='r')
test.must_match(['work3', 'ccc.out'],
"import/ccc.in\n",
mode='r')
test.must_match(['work3', 'all'],
"import/aaa.in\nimport/bbb.in\nimport/ccc.in\n",
mode='r')
# Test CVS checkouts from a remote server (Tigris.org).
#test.subdir(['work4'])
#
#test.write(['work4', 'SConstruct'], """\
#SetOption('warn', 'deprecated-source-code')
#import os
#env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
## We used to use the SourceForge server, but SourceForge has restrictions
## that make them deny access on occasion. Leave the incantation here
## in case we need to use it again some day.
##cvs = env.CVS(':pserver:anonymous@cvs.sourceforge.net:/cvsroot/scons')
#cvs = env.CVS(':pserver:anoncvs@cvs.tigris.org:/cvs')
#env.SourceCode('.', cvs)
#env.Install('install', 'scons/SConstruct')
#""")
#
#test.run(chdir = 'work4', arguments = '.')
#
#test.must_exist(test.workpath('work4', 'install', 'SConstruct'))
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
|