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__"
28 Test fetching source files from CVS.
35 test = TestSCons.TestSCons()
37 cvs = test.where_is('cvs')
39 test.skip_test("Could not find 'cvs'; skipping test(s).\n")
41 test.subdir('CVS', 'import', ['import', 'sub'], 'work1', 'work2')
43 foo_aaa_in = os.path.join('foo', 'aaa.in')
44 foo_bbb_in = os.path.join('foo', 'bbb.in')
45 foo_ccc_in = os.path.join('foo', 'ccc.in')
46 foo_sub_ddd_in = os.path.join('foo', 'sub', 'ddd.in')
47 foo_sub_ddd_out = os.path.join('foo', 'sub', 'ddd.out')
48 foo_sub_eee_in = os.path.join('foo', 'sub', 'eee.in')
49 foo_sub_eee_out = os.path.join('foo', 'sub', 'eee.out')
50 foo_sub_fff_in = os.path.join('foo', 'sub', 'fff.in')
51 foo_sub_fff_out = os.path.join('foo', 'sub', 'fff.out')
52 foo_sub_all = os.path.join('foo', 'sub', 'all')
54 sub_SConscript = os.path.join('sub', 'SConscript')
55 sub_ddd_in = os.path.join('sub', 'ddd.in')
56 sub_ddd_out = os.path.join('sub', 'ddd.out')
57 sub_eee_in = os.path.join('sub', 'eee.in')
58 sub_eee_out = os.path.join('sub', 'eee.out')
59 sub_fff_in = os.path.join('sub', 'fff.in')
60 sub_fff_out = os.path.join('sub', 'fff.out')
61 sub_all = os.path.join('sub', 'all')
63 # Set up the CVS repository.
64 cvsroot = test.workpath('CVS')
66 os.environ['CVSROOT'] = cvsroot
67 test.run(program = cvs, arguments = 'init')
69 test.write(['import', 'aaa.in'], "import/aaa.in\n")
70 test.write(['import', 'bbb.in'], "import/bbb.in\n")
71 test.write(['import', 'ccc.in'], "import/ccc.in\n")
73 test.write(['import', 'sub', 'SConscript'], """\
75 env.Cat('ddd.out', 'ddd.in')
76 env.Cat('eee.out', 'eee.in')
77 env.Cat('fff.out', 'fff.in')
78 env.Cat('all', ['ddd.out', 'eee.out', 'fff.out'])
81 test.write(['import', 'sub', 'ddd.in'], "import/sub/ddd.in\n")
82 test.write(['import', 'sub', 'eee.in'], "import/sub/eee.in\n")
83 test.write(['import', 'sub', 'fff.in'], "import/sub/fff.in\n")
85 test.run(chdir = 'import',
87 arguments = '-q import -m import foo v v-r')
89 # Test the most straightforward CVS checkouts, using the module name.
90 test.write(['work1', 'SConstruct'], """
92 def cat(env, source, target):
93 target = str(target[0])
94 f = open(target, "wb")
96 f.write(open(str(src), "rb").read())
98 env = Environment(ENV = { 'PATH' : os.environ['PATH'],
99 'EDITOR' : os.environ.get('EDITOR', 'ed') },
100 BUILDERS={'Cat':Builder(action=cat)})
101 env.Prepend(CVSFLAGS='-Q')
102 env.Cat('aaa.out', 'foo/aaa.in')
103 env.Cat('bbb.out', 'foo/bbb.in')
104 env.Cat('ccc.out', 'foo/ccc.in')
105 env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
106 env.SourceCode('.', env.CVS(r'%(cvsroot)s'))
107 SConscript('foo/sub/SConscript', "env")
110 test.subdir(['work1', 'foo'])
111 test.write(['work1', 'foo', 'bbb.in'], "work1/foo/bbb.in\n")
113 test.subdir(['work1', 'foo', 'sub',])
114 test.write(['work1', 'foo', 'sub', 'eee.in'], "work1/foo/sub/eee.in\n")
116 test.run(chdir = 'work1',
118 stdout = test.wrap_stdout(read_str = """\
119 cvs -Q -d %(cvsroot)s co foo/sub/SConscript
122 cvs -Q -d %(cvsroot)s co foo/aaa.in
123 cat(["aaa.out"], ["%(foo_aaa_in)s"])
124 cat(["bbb.out"], ["%(foo_bbb_in)s"])
125 cvs -Q -d %(cvsroot)s co foo/ccc.in
126 cat(["ccc.out"], ["%(foo_ccc_in)s"])
127 cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
128 cvs -Q -d %(cvsroot)s co foo/sub/ddd.in
129 cat(["%(foo_sub_ddd_out)s"], ["%(foo_sub_ddd_in)s"])
130 cat(["%(foo_sub_eee_out)s"], ["%(foo_sub_eee_in)s"])
131 cvs -Q -d %(cvsroot)s co foo/sub/fff.in
132 cat(["%(foo_sub_fff_out)s"], ["%(foo_sub_fff_in)s"])
133 cat(["%(foo_sub_all)s"], ["%(foo_sub_ddd_out)s", "%(foo_sub_eee_out)s", "%(foo_sub_fff_out)s"])
136 # Checking things back out of CVS apparently messes with the line
137 # endings, so read the result files in non-binary mode.
139 test.must_match(['work1', 'all'],
140 "import/aaa.in\nwork1/foo/bbb.in\nimport/ccc.in\n",
143 test.must_match(['work1', 'foo', 'sub', 'all'],
144 "import/sub/ddd.in\nwork1/foo/sub/eee.in\nimport/sub/fff.in\n",
147 test.must_be_writable(test.workpath('work1', 'foo', 'sub', 'SConscript'))
148 test.must_be_writable(test.workpath('work1', 'foo', 'aaa.in'))
149 test.must_be_writable(test.workpath('work1', 'foo', 'ccc.in'))
150 test.must_be_writable(test.workpath('work1', 'foo', 'sub', 'ddd.in'))
151 test.must_be_writable(test.workpath('work1', 'foo', 'sub', 'fff.in'))
153 # Test CVS checkouts when the module name is specified.
154 test.write(['work2', 'SConstruct'], """
156 def cat(env, source, target):
157 target = str(target[0])
158 f = open(target, "wb")
160 f.write(open(str(src), "rb").read())
162 env = Environment(ENV = { 'PATH' : os.environ['PATH'],
163 'EDITOR' : os.environ.get('EDITOR', 'ed') },
164 BUILDERS={'Cat':Builder(action=cat)})
165 env.Prepend(CVSFLAGS='-q')
166 env.Cat('aaa.out', 'aaa.in')
167 env.Cat('bbb.out', 'bbb.in')
168 env.Cat('ccc.out', 'ccc.in')
169 env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
170 env.SourceCode('.', env.CVS(r'%(cvsroot)s', 'foo'))
171 SConscript('sub/SConscript', "env")
174 test.write(['work2', 'bbb.in'], "work2/bbb.in\n")
176 test.subdir(['work2', 'sub'])
177 test.write(['work2', 'sub', 'eee.in'], "work2/sub/eee.in\n")
179 test.run(chdir = 'work2',
181 stdout = test.wrap_stdout(read_str = """\
182 cvs -q -d %(cvsroot)s co -d sub foo/sub/SConscript
186 cvs -q -d %(cvsroot)s co -d . foo/aaa.in
188 cat(["aaa.out"], ["aaa.in"])
189 cat(["bbb.out"], ["bbb.in"])
190 cvs -q -d %(cvsroot)s co -d . foo/ccc.in
192 cat(["ccc.out"], ["ccc.in"])
193 cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
194 cvs -q -d %(cvsroot)s co -d sub foo/sub/ddd.in
196 cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
197 cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
198 cvs -q -d %(cvsroot)s co -d sub foo/sub/fff.in
200 cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
201 cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
204 # Checking things back out of CVS apparently messes with the line
205 # endings, so read the result files in non-binary mode.
207 test.must_match(['work2', 'all'],
208 "import/aaa.in\nwork2/bbb.in\nimport/ccc.in\n",
211 test.must_match(['work2', 'sub', 'all'],
212 "import/sub/ddd.in\nwork2/sub/eee.in\nimport/sub/fff.in\n",
215 test.must_be_writable(test.workpath('work2', 'sub', 'SConscript'))
216 test.must_be_writable(test.workpath('work2', 'aaa.in'))
217 test.must_be_writable(test.workpath('work2', 'ccc.in'))
218 test.must_be_writable(test.workpath('work2', 'sub', 'ddd.in'))
219 test.must_be_writable(test.workpath('work2', 'sub', 'fff.in'))
221 # Test checking out specific file name(s), and expanding
222 # the repository name with a variable.
223 test.subdir(['work3'])
225 test.write(['work3', 'SConstruct'], """\
227 def cat(env, source, target):
228 target = str(target[0])
229 f = open(target, "wb")
231 f.write(open(str(src), "rb").read())
233 env = Environment(ENV = { 'PATH' : os.environ['PATH'],
234 'EDITOR' : os.environ.get('EDITOR', 'ed') },
235 BUILDERS={'Cat':Builder(action=cat)},
237 env.Prepend(CVSFLAGS='-q')
238 env.Cat('aaa.out', 'aaa.in')
239 env.Cat('bbb.out', 'bbb.in')
240 env.Cat('ccc.out', 'ccc.in')
241 env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
242 cvs = env.CVS('$CVSROOT', 'foo')
243 #env.SourceCode('.', cvs)
244 env.SourceCode('aaa.in', cvs)
245 env.SourceCode('bbb.in', cvs)
246 env.SourceCode('ccc.in', cvs)
249 test.run(chdir = 'work3',
251 stdout = test.wrap_stdout(build_str = """\
252 cvs -q -d %(cvsroot)s co -d . foo/aaa.in
254 cat(["aaa.out"], ["aaa.in"])
255 cvs -q -d %(cvsroot)s co -d . foo/bbb.in
257 cat(["bbb.out"], ["bbb.in"])
258 cvs -q -d %(cvsroot)s co -d . foo/ccc.in
260 cat(["ccc.out"], ["ccc.in"])
261 cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
264 test.must_match(['work3', 'aaa.out'],
267 test.must_match(['work3', 'bbb.out'],
270 test.must_match(['work3', 'ccc.out'],
273 test.must_match(['work3', 'all'],
274 "import/aaa.in\nimport/bbb.in\nimport/ccc.in\n",
277 # Test CVS checkouts from a remote server (Tigris.org).
278 #test.subdir(['work4'])
280 #test.write(['work4', 'SConstruct'], """\
282 #env = Environment(ENV = { 'PATH' : os.environ['PATH'] })
283 ## We used to use the SourceForge server, but SourceForge has restrictions
284 ## that make them deny access on occasion. Leave the incantation here
285 ## in case we need to use it again some day.
286 ##cvs = env.CVS(':pserver:anonymous@cvs.sourceforge.net:/cvsroot/scons')
287 #cvs = env.CVS(':pserver:anoncvs@cvs.tigris.org:/cvs')
288 #env.SourceCode('.', cvs)
289 #env.Install('install', 'scons/SConstruct')
292 #test.run(chdir = 'work4', arguments = '.')
294 #test.must_exist(test.workpath('work4', 'install', 'SConstruct'))
301 # indent-tabs-mode:nil
303 # vim: set expandtab tabstop=4 shiftwidth=4: