| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Smoke tests for gclient.py. | 6 """Smoke tests for gclient.py. |
| 7 | 7 |
| 8 Shell out 'gclient' and run basic conformance tests. | 8 Shell out 'gclient' and run basic conformance tests. |
| 9 | 9 |
| 10 This test assumes GClientSmokeBase.URL_BASE is valid. | 10 This test assumes GClientSmokeBase.URL_BASE is valid. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 cwd = self.root_dir | 37 cwd = self.root_dir |
| 38 if COVERAGE: | 38 if COVERAGE: |
| 39 # Don't use the wrapper script. | 39 # Don't use the wrapper script. |
| 40 cmd_base = ['coverage', 'run', '-a', GCLIENT_PATH + '.py'] | 40 cmd_base = ['coverage', 'run', '-a', GCLIENT_PATH + '.py'] |
| 41 else: | 41 else: |
| 42 cmd_base = [GCLIENT_PATH] | 42 cmd_base = [GCLIENT_PATH] |
| 43 process = subprocess.Popen(cmd_base + cmd, cwd=cwd, env=self.env, | 43 process = subprocess.Popen(cmd_base + cmd, cwd=cwd, env=self.env, |
| 44 stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 44 stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
| 45 shell=sys.platform.startswith('win')) | 45 shell=sys.platform.startswith('win')) |
| 46 (stdout, stderr) = process.communicate() | 46 (stdout, stderr) = process.communicate() |
| 47 return (stdout, stderr, process.returncode) | 47 return (stdout.replace('\r\n', '\n'), stderr.replace('\r\n', '\n'), |
| 48 process.returncode) |
| 48 | 49 |
| 49 | 50 |
| 50 class GClientSmoke(GClientSmokeBase): | 51 class GClientSmoke(GClientSmokeBase): |
| 51 def testHelp(self): | 52 def testHelp(self): |
| 52 """testHelp: make sure no new command was added.""" | 53 """testHelp: make sure no new command was added.""" |
| 53 result = self.gclient(['help']) | 54 result = self.gclient(['help']) |
| 54 self.assertEquals(1197, len(result[0])) | 55 self.assertEquals(1197, len(result[0])) |
| 55 self.assertEquals(0, len(result[1])) | 56 self.assertEquals(0, len(result[1])) |
| 56 self.assertEquals(0, result[2]) | 57 self.assertEquals(0, result[2]) |
| 57 | 58 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 74 self.check(res, self.gclient(['sync'])) | 75 self.check(res, self.gclient(['sync'])) |
| 75 self.check(res, self.gclient(['update'])) | 76 self.check(res, self.gclient(['update'])) |
| 76 | 77 |
| 77 def testConfig(self): | 78 def testConfig(self): |
| 78 p = join(self.root_dir, '.gclient') | 79 p = join(self.root_dir, '.gclient') |
| 79 def test(cmd, expected): | 80 def test(cmd, expected): |
| 80 if os.path.exists(p): | 81 if os.path.exists(p): |
| 81 os.remove(p) | 82 os.remove(p) |
| 82 results = self.gclient(cmd) | 83 results = self.gclient(cmd) |
| 83 self.check(('', '', 0), results) | 84 self.check(('', '', 0), results) |
| 84 self.checkString(expected, open(p, 'rb').read()) | 85 self.checkString(expected, open(p, 'rU').read()) |
| 85 | 86 |
| 86 test(['config', self.svn_base + 'trunk/src/'], | 87 test(['config', self.svn_base + 'trunk/src/'], |
| 87 'solutions = [\n' | 88 'solutions = [\n' |
| 88 ' { "name" : "src",\n' | 89 ' { "name" : "src",\n' |
| 89 ' "url" : "svn://127.0.0.1/svn/trunk/src",\n' | 90 ' "url" : "svn://127.0.0.1/svn/trunk/src",\n' |
| 90 ' "custom_deps" : {\n' | 91 ' "custom_deps" : {\n' |
| 91 ' },\n' | 92 ' },\n' |
| 92 ' "safesync_url": ""\n' | 93 ' "safesync_url": ""\n' |
| 93 ' },\n]\n') | 94 ' },\n]\n') |
| 94 | 95 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 # TODO(maruel): safesync. | 131 # TODO(maruel): safesync. |
| 131 self.gclient(['config', self.svn_base + 'trunk/src/']) | 132 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 132 # Test unversioned checkout. | 133 # Test unversioned checkout. |
| 133 results = self.gclient(['sync', '--deps', 'mac']) | 134 results = self.gclient(['sync', '--deps', 'mac']) |
| 134 logging.debug(results[0]) | 135 logging.debug(results[0]) |
| 135 out = results[0].splitlines(False) | 136 out = results[0].splitlines(False) |
| 136 self.assertEquals(17, len(out)) | 137 self.assertEquals(17, len(out)) |
| 137 self.checkString('', results[1]) | 138 self.checkString('', results[1]) |
| 138 self.assertEquals(0, results[2]) | 139 self.assertEquals(0, results[2]) |
| 139 tree = mangle_svn_tree( | 140 tree = mangle_svn_tree( |
| 140 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[-1]), | 141 ('trunk/src', 'src', self.FAKE_REPOS.svn_revs[-1]), |
| 141 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), | 142 ('trunk/third_party/foo', 'src/third_party/foo', |
| 142 self.FAKE_REPOS.svn_revs[1]), | 143 self.FAKE_REPOS.svn_revs[1]), |
| 143 (join('trunk', 'other'), join('src', 'other'), | 144 ('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]), |
| 144 self.FAKE_REPOS.svn_revs[2]), | |
| 145 ) | 145 ) |
| 146 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' | 146 tree['src/svn_hooked1'] = 'svn_hooked1' |
| 147 self.assertTree(tree) | 147 self.assertTree(tree) |
| 148 | 148 |
| 149 # Manually remove svn_hooked1 before synching to make sure it's not | 149 # Manually remove svn_hooked1 before synching to make sure it's not |
| 150 # recreated. | 150 # recreated. |
| 151 os.remove(join(self.root_dir, 'src', 'svn_hooked1')) | 151 os.remove(join(self.root_dir, 'src', 'svn_hooked1')) |
| 152 | 152 |
| 153 # Test incremental versioned sync: sync backward. | 153 # Test incremental versioned sync: sync backward. |
| 154 results = self.gclient(['sync', '--revision', 'src@1', '--deps', 'mac', | 154 results = self.gclient(['sync', '--revision', 'src@1', '--deps', 'mac', |
| 155 '--delete_unversioned_trees']) | 155 '--delete_unversioned_trees']) |
| 156 logging.debug(results[0]) | 156 logging.debug(results[0]) |
| 157 out = results[0].splitlines(False) | 157 out = results[0].splitlines(False) |
| 158 self.assertEquals(19, len(out)) | 158 self.assertEquals(19, len(out)) |
| 159 self.checkString('', results[1]) | 159 self.checkString('', results[1]) |
| 160 self.assertEquals(0, results[2]) | 160 self.assertEquals(0, results[2]) |
| 161 tree = mangle_svn_tree( | 161 tree = mangle_svn_tree( |
| 162 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[1]), | 162 ('trunk/src', 'src', self.FAKE_REPOS.svn_revs[1]), |
| 163 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), | 163 ('trunk/third_party/foo', 'src/third_party/fpp', |
| 164 self.FAKE_REPOS.svn_revs[2]), | 164 self.FAKE_REPOS.svn_revs[2]), |
| 165 (join('trunk', 'other'), join('src', 'other'), | 165 ('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]), |
| 166 self.FAKE_REPOS.svn_revs[2]), | 166 ('trunk/third_party/foo', 'src/third_party/prout', |
| 167 (join('trunk', 'third_party', 'foo'), | |
| 168 join('src', 'third_party', 'prout'), | |
| 169 self.FAKE_REPOS.svn_revs[2]), | 167 self.FAKE_REPOS.svn_revs[2]), |
| 170 ) | 168 ) |
| 171 self.assertTree(tree) | 169 self.assertTree(tree) |
| 172 # Test incremental sync: delete-unversioned_trees isn't there. | 170 # Test incremental sync: delete-unversioned_trees isn't there. |
| 173 results = self.gclient(['sync', '--deps', 'mac']) | 171 results = self.gclient(['sync', '--deps', 'mac']) |
| 174 logging.debug(results[0]) | 172 logging.debug(results[0]) |
| 175 out = results[0].splitlines(False) | 173 out = results[0].splitlines(False) |
| 176 self.assertEquals(21, len(out)) | 174 self.assertEquals(21, len(out)) |
| 177 self.checkString('', results[1]) | 175 self.checkString('', results[1]) |
| 178 self.assertEquals(0, results[2]) | 176 self.assertEquals(0, results[2]) |
| 179 tree = mangle_svn_tree( | 177 tree = mangle_svn_tree( |
| 180 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[2]), | 178 ('trunk/src', 'src', self.FAKE_REPOS.svn_revs[2]), |
| 181 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), | 179 ('trunk/third_party/foo', 'src/third_party/fpp', |
| 182 self.FAKE_REPOS.svn_revs[2]), | 180 self.FAKE_REPOS.svn_revs[2]), |
| 183 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), | 181 ('trunk/third_party/foo', 'src/third_party/foo', |
| 184 self.FAKE_REPOS.svn_revs[1]), | 182 self.FAKE_REPOS.svn_revs[1]), |
| 185 (join('trunk', 'other'), join('src', 'other'), | 183 ('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]), |
| 186 self.FAKE_REPOS.svn_revs[2]), | 184 ('trunk/third_party/foo', 'src/third_party/prout', |
| 187 (join('trunk', 'third_party', 'foo'), | |
| 188 join('src', 'third_party', 'prout'), | |
| 189 self.FAKE_REPOS.svn_revs[2]), | 185 self.FAKE_REPOS.svn_revs[2]), |
| 190 ) | 186 ) |
| 191 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' | 187 tree['src/svn_hooked1'] = 'svn_hooked1' |
| 192 self.assertTree(tree) | 188 self.assertTree(tree) |
| 193 | 189 |
| 194 def testSyncIgnoredSolutionName(self): | 190 def testSyncIgnoredSolutionName(self): |
| 195 """TODO(maruel): This will become an error soon.""" | 191 """TODO(maruel): This will become an error soon.""" |
| 196 self.gclient(['config', self.svn_base + 'trunk/src/']) | 192 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 197 results = self.gclient(['sync', '--deps', 'mac', '-r', 'invalid@1']) | 193 results = self.gclient(['sync', '--deps', 'mac', '-r', 'invalid@1']) |
| 198 out = results[0].splitlines(False) | 194 out = results[0].splitlines(False) |
| 199 self.assertEquals(17, len(out)) | 195 self.assertEquals(17, len(out)) |
| 200 self.checkString('Please fix your script, having invalid --revision flags ' | 196 self.checkString('Please fix your script, having invalid --revision flags ' |
| 201 'will soon considered an error.\n', results[1]) | 197 'will soon considered an error.\n', results[1]) |
| 202 self.assertEquals(0, results[2]) | 198 self.assertEquals(0, results[2]) |
| 203 tree = mangle_svn_tree( | 199 tree = mangle_svn_tree( |
| 204 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[2]), | 200 ('trunk/src', 'src', self.FAKE_REPOS.svn_revs[2]), |
| 205 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), | 201 ('trunk/third_party/foo', 'src/third_party/foo', |
| 206 self.FAKE_REPOS.svn_revs[1]), | 202 self.FAKE_REPOS.svn_revs[1]), |
| 207 (join('trunk', 'other'), join('src', 'other'), | 203 ('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]), |
| 208 self.FAKE_REPOS.svn_revs[2]), | |
| 209 ) | 204 ) |
| 210 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' | 205 tree['src/svn_hooked1'] = 'svn_hooked1' |
| 211 self.assertTree(tree) | 206 self.assertTree(tree) |
| 212 | 207 |
| 213 def testSyncNoSolutionName(self): | 208 def testSyncNoSolutionName(self): |
| 214 # When no solution name is provided, gclient uses the first solution listed. | 209 # When no solution name is provided, gclient uses the first solution listed. |
| 215 self.gclient(['config', self.svn_base + 'trunk/src/']) | 210 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 216 results = self.gclient(['sync', '--deps', 'mac', '-r', '1']) | 211 results = self.gclient(['sync', '--deps', 'mac', '-r', '1']) |
| 217 out = results[0].splitlines(False) | 212 out = results[0].splitlines(False) |
| 218 self.assertEquals(19, len(out)) | 213 self.assertEquals(19, len(out)) |
| 219 self.checkString('', results[1]) | 214 self.checkString('', results[1]) |
| 220 self.assertEquals(0, results[2]) | 215 self.assertEquals(0, results[2]) |
| 221 tree = mangle_svn_tree( | 216 tree = mangle_svn_tree( |
| 222 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[1]), | 217 ('trunk/src', 'src', self.FAKE_REPOS.svn_revs[1]), |
| 223 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), | 218 ('trunk/third_party/foo', 'src/third_party/fpp', |
| 224 self.FAKE_REPOS.svn_revs[2]), | 219 self.FAKE_REPOS.svn_revs[2]), |
| 225 (join('trunk', 'other'), join('src', 'other'), | 220 ('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]), |
| 226 self.FAKE_REPOS.svn_revs[2]), | 221 ('trunk/third_party/foo', 'src/third_party/prout', |
| 227 (join('trunk', 'third_party', 'foo'), | |
| 228 join('src', 'third_party', 'prout'), | |
| 229 self.FAKE_REPOS.svn_revs[2]), | 222 self.FAKE_REPOS.svn_revs[2]), |
| 230 ) | 223 ) |
| 231 self.assertTree(tree) | 224 self.assertTree(tree) |
| 232 | 225 |
| 233 def testRevertAndStatus(self): | 226 def testRevertAndStatus(self): |
| 234 self.gclient(['config', self.svn_base + 'trunk/src/']) | 227 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 235 # Tested in testSync. | 228 # Tested in testSync. |
| 236 self.gclient(['sync', '--deps', 'mac']) | 229 self.gclient(['sync', '--deps', 'mac']) |
| 237 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') | 230 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') |
| 238 | 231 |
| 239 results = self.gclient(['status']) | 232 results = self.gclient(['status', '--deps', 'mac']) |
| 240 out = results[0].splitlines(False) | 233 out = results[0].splitlines(False) |
| 241 self.assertEquals(out[0], '') | 234 self.assertEquals(out[0], '') |
| 242 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) | 235 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) |
| 243 self.assertEquals(out[2], '? svn_hooked1') | 236 self.assertEquals(out[2], '? svn_hooked1') |
| 244 self.assertEquals(out[3], '? other') | 237 self.assertEquals(out[3], '? other') |
| 245 self.assertEquals(out[4], '? third_party/foo') | 238 self.assertEquals(out[4], '? ' + join('third_party', 'foo')) |
| 246 self.assertEquals(out[5], '') | 239 self.assertEquals(out[5], '') |
| 247 self.assertTrue(out[6].startswith('________ running \'svn status\' in \'')) | 240 self.assertTrue(out[6].startswith('________ running \'svn status\' in \'')) |
| 248 self.assertEquals(out[7], '? hi') | 241 self.assertEquals(out[7], '? hi') |
| 249 self.assertEquals(8, len(out)) | 242 self.assertEquals(8, len(out)) |
| 250 self.assertEquals('', results[1]) | 243 self.assertEquals('', results[1]) |
| 251 self.assertEquals(0, results[2]) | 244 self.assertEquals(0, results[2]) |
| 252 | 245 |
| 253 # Revert implies --force implies running hooks without looking at pattern | 246 # Revert implies --force implies running hooks without looking at pattern |
| 254 # matching. | 247 # matching. |
| 255 results = self.gclient(['revert']) | 248 results = self.gclient(['revert', '--deps', 'mac']) |
| 256 out = results[0].splitlines(False) | 249 out = results[0].splitlines(False) |
| 257 self.assertEquals(22, len(out)) | 250 self.assertEquals(22, len(out)) |
| 258 self.checkString('', results[1]) | 251 self.checkString('', results[1]) |
| 259 self.assertEquals(0, results[2]) | 252 self.assertEquals(0, results[2]) |
| 260 tree = mangle_svn_tree( | 253 tree = mangle_svn_tree( |
| 261 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[-1]), | 254 ('trunk/src', 'src', self.FAKE_REPOS.svn_revs[-1]), |
| 262 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), | 255 ('trunk/third_party/foo', 'src/third_party/foo', |
| 263 self.FAKE_REPOS.svn_revs[1]), | 256 self.FAKE_REPOS.svn_revs[1]), |
| 264 (join('trunk', 'other'), join('src', 'other'), | 257 ('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]), |
| 265 self.FAKE_REPOS.svn_revs[2]), | |
| 266 ) | 258 ) |
| 267 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' | 259 tree['src/svn_hooked1'] = 'svn_hooked1' |
| 268 tree[join('src', 'svn_hooked2')] = 'svn_hooked2' | 260 tree['src/svn_hooked2'] = 'svn_hooked2' |
| 269 self.assertTree(tree) | 261 self.assertTree(tree) |
| 270 | 262 |
| 271 results = self.gclient(['status']) | 263 results = self.gclient(['status', '--deps', 'mac']) |
| 272 out = results[0].splitlines(False) | 264 out = results[0].splitlines(False) |
| 273 self.assertEquals(out[0], '') | 265 self.assertEquals(out[0], '') |
| 274 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) | 266 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) |
| 275 self.assertEquals(out[2], '? svn_hooked1') | 267 self.assertEquals(out[2], '? svn_hooked1') |
| 276 self.assertEquals(out[3], '? svn_hooked2') | 268 # I don't know why but on Windows they are reversed. |
| 277 self.assertEquals(out[4], '? other') | 269 if (not (out[3] == '? other' and out[4] == '? svn_hooked2') and |
| 278 self.assertEquals(out[5], '? third_party/foo') | 270 not (out[3] == '? svn_hooked2' and out[4] == '? other')): |
| 271 self.assertEquals(out[3], '? svn_hooked2') |
| 272 self.assertEquals(out[4], '? other') |
| 273 self.assertEquals(out[5], '? ' + join('third_party', 'foo')) |
| 279 self.assertEquals(6, len(out)) | 274 self.assertEquals(6, len(out)) |
| 280 self.checkString('', results[1]) | 275 self.checkString('', results[1]) |
| 281 self.assertEquals(0, results[2]) | 276 self.assertEquals(0, results[2]) |
| 282 | 277 |
| 283 def testRevertAndStatusDepsOs(self): | 278 def testRevertAndStatusDepsOs(self): |
| 284 self.gclient(['config', self.svn_base + 'trunk/src/']) | 279 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 285 # Tested in testSync. | 280 # Tested in testSync. |
| 286 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) | 281 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) |
| 287 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') | 282 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') |
| 288 | 283 |
| 289 results = self.gclient(['status', '--deps', 'mac']) | 284 results = self.gclient(['status', '--deps', 'mac']) |
| 290 out = results[0].splitlines(False) | 285 out = results[0].splitlines(False) |
| 291 self.assertEquals(out[0], '') | 286 self.assertEquals(out[0], '') |
| 292 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) | 287 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) |
| 293 self.assertEquals(out[2], '? other') | 288 self.assertEquals(out[2], '? other') |
| 294 self.assertEquals(out[3], '? third_party/fpp') | 289 self.assertEquals(out[3], '? ' + join('third_party', 'fpp')) |
| 295 self.assertEquals(out[4], '? third_party/prout') | 290 self.assertEquals(out[4], '? ' + join('third_party', 'prout')) |
| 296 self.assertEquals(out[5], '') | 291 self.assertEquals(out[5], '') |
| 297 self.assertTrue(out[6].startswith('________ running \'svn status\' in \'')) | 292 self.assertTrue(out[6].startswith('________ running \'svn status\' in \'')) |
| 298 self.assertEquals(out[7], '? hi') | 293 self.assertEquals(out[7], '? hi') |
| 299 self.assertEquals(8, len(out)) | 294 self.assertEquals(8, len(out)) |
| 300 self.assertEquals('', results[1]) | 295 self.assertEquals('', results[1]) |
| 301 self.assertEquals(0, results[2]) | 296 self.assertEquals(0, results[2]) |
| 302 | 297 |
| 303 # Revert implies --force implies running hooks without looking at pattern | 298 # Revert implies --force implies running hooks without looking at pattern |
| 304 # matching. | 299 # matching. |
| 305 results = self.gclient(['revert', '--deps', 'mac']) | 300 results = self.gclient(['revert', '--deps', 'mac']) |
| 306 out = results[0].splitlines(False) | 301 out = results[0].splitlines(False) |
| 307 self.assertEquals(24, len(out)) | 302 self.assertEquals(24, len(out)) |
| 308 self.checkString('', results[1]) | 303 self.checkString('', results[1]) |
| 309 self.assertEquals(0, results[2]) | 304 self.assertEquals(0, results[2]) |
| 310 tree = mangle_svn_tree( | 305 tree = mangle_svn_tree( |
| 311 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[1]), | 306 ('trunk/src', 'src', self.FAKE_REPOS.svn_revs[1]), |
| 312 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), | 307 ('trunk/third_party/foo', 'src/third_party/fpp', |
| 313 self.FAKE_REPOS.svn_revs[2]), | 308 self.FAKE_REPOS.svn_revs[2]), |
| 314 (join('trunk', 'other'), join('src', 'other'), | 309 ('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]), |
| 315 self.FAKE_REPOS.svn_revs[2]), | 310 ('trunk/third_party/prout', 'src/third_party/prout', |
| 316 (join('trunk', 'third_party', 'prout'), | |
| 317 join('src', 'third_party', 'prout'), | |
| 318 self.FAKE_REPOS.svn_revs[2]), | 311 self.FAKE_REPOS.svn_revs[2]), |
| 319 ) | 312 ) |
| 320 self.assertTree(tree) | 313 self.assertTree(tree) |
| 321 | 314 |
| 322 results = self.gclient(['status', '--deps', 'mac']) | 315 results = self.gclient(['status', '--deps', 'mac']) |
| 323 out = results[0].splitlines(False) | 316 out = results[0].splitlines(False) |
| 324 self.assertEquals(out[0], '') | 317 self.assertEquals(out[0], '') |
| 325 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) | 318 self.assertTrue(out[1].startswith('________ running \'svn status\' in \'')) |
| 326 self.assertEquals(out[2], '? other') | 319 self.assertEquals(out[2], '? other') |
| 327 self.assertEquals(out[3], '? third_party/fpp') | 320 self.assertEquals(out[3], '? ' + join('third_party', 'fpp')) |
| 328 self.assertEquals(out[4], '? third_party/prout') | 321 self.assertEquals(out[4], '? ' + join('third_party', 'prout')) |
| 329 self.assertEquals(5, len(out)) | 322 self.assertEquals(5, len(out)) |
| 330 self.checkString('', results[1]) | 323 self.checkString('', results[1]) |
| 331 self.assertEquals(0, results[2]) | 324 self.assertEquals(0, results[2]) |
| 332 | 325 |
| 333 def testRunHooks(self): | 326 def testRunHooks(self): |
| 334 self.gclient(['config', self.svn_base + 'trunk/src/']) | 327 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 335 self.gclient(['sync', '--deps', 'mac']) | 328 self.gclient(['sync', '--deps', 'mac']) |
| 336 results = self.gclient(['runhooks']) | 329 results = self.gclient(['runhooks', '--deps', 'mac']) |
| 337 out = results[0].splitlines(False) | 330 out = results[0].splitlines(False) |
| 338 self.assertEquals(4, len(out)) | 331 self.assertEquals(4, len(out)) |
| 339 self.assertEquals(out[0], '') | 332 self.assertEquals(out[0], '') |
| 340 self.assertTrue(re.match(r'^________ running \'.*?python -c ' | 333 self.assertTrue(re.match(r'^________ running \'.*?python(.exe)? -c ' |
| 341 r'open\(\'src/svn_hooked1\', \'w\'\)\.write\(\'svn_hooked1\'\)\' in \'.*', | 334 r'open\(\'src/svn_hooked1\', \'w\'\)\.write\(\'svn_hooked1\'\)\' in \'.*', |
| 342 out[1])) | 335 out[1])) |
| 343 self.assertEquals(out[2], '') | 336 self.assertEquals(out[2], '') |
| 344 # runhooks runs all hooks even if not matching by design. | 337 # runhooks runs all hooks even if not matching by design. |
| 345 self.assertTrue(re.match(r'^________ running \'.*?python -c ' | 338 self.assertTrue(re.match(r'^________ running \'.*?python(.exe)? -c ' |
| 346 r'open\(\'src/svn_hooked2\', \'w\'\)\.write\(\'svn_hooked2\'\)\' in \'.*', | 339 r'open\(\'src/svn_hooked2\', \'w\'\)\.write\(\'svn_hooked2\'\)\' in \'.*', |
| 347 out[3])) | 340 out[3])) |
| 348 self.checkString('', results[1]) | 341 self.checkString('', results[1]) |
| 349 self.assertEquals(0, results[2]) | 342 self.assertEquals(0, results[2]) |
| 350 | 343 |
| 351 def testRunHooksDepsOs(self): | 344 def testRunHooksDepsOs(self): |
| 352 self.gclient(['config', self.svn_base + 'trunk/src/']) | 345 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 353 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) | 346 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) |
| 354 results = self.gclient(['runhooks']) | 347 results = self.gclient(['runhooks', '--deps', 'mac']) |
| 355 self.check(('', '', 0), results) | 348 self.check(('', '', 0), results) |
| 356 | 349 |
| 357 def testRevInfo(self): | 350 def testRevInfo(self): |
| 358 # TODO(maruel): Test multiple solutions. | 351 # TODO(maruel): Test multiple solutions. |
| 359 self.gclient(['config', self.svn_base + 'trunk/src/']) | 352 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 360 self.gclient(['sync', '--deps', 'mac']) | 353 self.gclient(['sync', '--deps', 'mac']) |
| 361 results = self.gclient(['revinfo']) | 354 results = self.gclient(['revinfo', '--deps', 'mac']) |
| 362 out = ('src: %(base)s/src@2;\n' | 355 out = ('src: %(base)s/src@2;\n' |
| 363 'src/other: %(base)s/other@2;\n' | 356 'src/other: %(base)s/other@2;\n' |
| 364 'src/third_party/foo: %(base)s/third_party/foo@1\n' % | 357 'src/third_party/foo: %(base)s/third_party/foo@1\n' % |
| 365 { 'base': self.svn_base + 'trunk' }) | 358 { 'base': self.svn_base + 'trunk' }) |
| 366 self.check((out, '', 0), results) | 359 self.check((out, '', 0), results) |
| 367 | 360 |
| 368 | 361 |
| 369 class GClientSmokeGIT(GClientSmokeBase): | 362 class GClientSmokeGIT(GClientSmokeBase): |
| 370 def setUp(self): | 363 def setUp(self): |
| 371 GClientSmokeBase.setUp(self) | 364 GClientSmokeBase.setUp(self) |
| 372 self.FAKE_REPOS.setUpGIT() | 365 self.enabled = self.FAKE_REPOS.setUpGIT() |
| 373 | 366 |
| 374 def testSync(self): | 367 def testSync(self): |
| 368 if not self.enabled: |
| 369 return |
| 375 # TODO(maruel): safesync. | 370 # TODO(maruel): safesync. |
| 376 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 371 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 377 # Test unversioned checkout. | 372 # Test unversioned checkout. |
| 378 results = self.gclient(['sync', '--deps', 'mac']) | 373 results = self.gclient(['sync', '--deps', 'mac']) |
| 379 out = results[0].splitlines(False) | 374 out = results[0].splitlines(False) |
| 380 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must | 375 # TODO(maruel): http://crosbug.com/3582 hooks run even if not matching, must |
| 381 # add sync parsing to get the list of updated files. | 376 # add sync parsing to get the list of updated files. |
| 382 self.assertEquals(13, len(out)) | 377 self.assertEquals(13, len(out)) |
| 383 self.assertTrue(results[1].startswith('Switched to a new branch \'')) | 378 self.assertTrue(results[1].startswith('Switched to a new branch \'')) |
| 384 self.assertEquals(0, results[2]) | 379 self.assertEquals(0, results[2]) |
| 385 tree = mangle_git_tree( | 380 tree = mangle_git_tree( |
| 386 ('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), | 381 ('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), |
| 387 (join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][0][1]), | 382 ('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][0][1]), |
| 388 (join('src', 'repo2', 'repo_renamed'), | 383 ('src/repo2/repo_renamed', self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 389 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | |
| 390 ) | 384 ) |
| 391 tree[join('src', 'git_hooked1')] = 'git_hooked1' | 385 tree['src/git_hooked1'] = 'git_hooked1' |
| 392 tree[join('src', 'git_hooked2')] = 'git_hooked2' | 386 tree['src/git_hooked2'] = 'git_hooked2' |
| 393 self.assertTree(tree) | 387 self.assertTree(tree) |
| 394 | 388 |
| 395 # Manually remove git_hooked1 before synching to make sure it's not | 389 # Manually remove git_hooked1 before synching to make sure it's not |
| 396 # recreated. | 390 # recreated. |
| 397 os.remove(join(self.root_dir, 'src', 'git_hooked1')) | 391 os.remove(join(self.root_dir, 'src', 'git_hooked1')) |
| 398 | 392 |
| 399 # Test incremental versioned sync: sync backward. | 393 # Test incremental versioned sync: sync backward. |
| 400 results = self.gclient(['sync', '--revision', | 394 results = self.gclient(['sync', '--revision', |
| 401 'src@' + self.FAKE_REPOS.git_hashes['repo_1'][0][0], | 395 'src@' + self.FAKE_REPOS.git_hashes['repo_1'][0][0], |
| 402 '--deps', 'mac', '--delete_unversioned_trees']) | 396 '--deps', 'mac', '--delete_unversioned_trees']) |
| 403 logging.debug(results[0]) | 397 logging.debug(results[0]) |
| 404 out = results[0].splitlines(False) | 398 out = results[0].splitlines(False) |
| 405 self.assertEquals(20, len(out)) | 399 self.assertEquals(20, len(out)) |
| 406 self.checkString('', results[1]) | 400 self.checkString('', results[1]) |
| 407 self.assertEquals(0, results[2]) | 401 self.assertEquals(0, results[2]) |
| 408 tree = mangle_git_tree( | 402 tree = mangle_git_tree( |
| 409 ('src', self.FAKE_REPOS.git_hashes['repo_1'][0][1]), | 403 ('src', self.FAKE_REPOS.git_hashes['repo_1'][0][1]), |
| 410 (join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][1][1]), | 404 ('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][1][1]), |
| 411 (join('src', 'repo2', 'repo3'), | 405 ('src/repo2/repo3', self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 412 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | 406 ('src/repo4', self.FAKE_REPOS.git_hashes['repo_4'][1][1]), |
| 413 (join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]), | |
| 414 ) | 407 ) |
| 415 tree[join('src', 'git_hooked2')] = 'git_hooked2' | 408 tree['src/git_hooked2'] = 'git_hooked2' |
| 416 self.assertTree(tree) | 409 self.assertTree(tree) |
| 417 # Test incremental sync: delete-unversioned_trees isn't there. | 410 # Test incremental sync: delete-unversioned_trees isn't there. |
| 418 results = self.gclient(['sync', '--deps', 'mac']) | 411 results = self.gclient(['sync', '--deps', 'mac']) |
| 419 logging.debug(results[0]) | 412 logging.debug(results[0]) |
| 420 out = results[0].splitlines(False) | 413 out = results[0].splitlines(False) |
| 421 self.assertEquals(25, len(out)) | 414 self.assertEquals(25, len(out)) |
| 422 self.checkString('', results[1]) | 415 self.checkString('', results[1]) |
| 423 self.assertEquals(0, results[2]) | 416 self.assertEquals(0, results[2]) |
| 424 tree = mangle_git_tree( | 417 tree = mangle_git_tree( |
| 425 ('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), | 418 ('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), |
| 426 (join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][1][1]), | 419 ('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][1][1]), |
| 427 (join('src', 'repo2', 'repo3'), | 420 ('src/repo2/repo3', self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 428 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | 421 ('src/repo2/repo_renamed', self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 429 (join('src', 'repo2', 'repo_renamed'), | 422 ('src/repo4', self.FAKE_REPOS.git_hashes['repo_4'][1][1]), |
| 430 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | |
| 431 (join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]), | |
| 432 ) | 423 ) |
| 433 tree[join('src', 'git_hooked1')] = 'git_hooked1' | 424 tree['src/git_hooked1'] = 'git_hooked1' |
| 434 tree[join('src', 'git_hooked2')] = 'git_hooked2' | 425 tree['src/git_hooked2'] = 'git_hooked2' |
| 435 self.assertTree(tree) | 426 self.assertTree(tree) |
| 436 | 427 |
| 437 def testSyncIgnoredSolutionName(self): | 428 def testSyncIgnoredSolutionName(self): |
| 438 """TODO(maruel): This will become an error soon.""" | 429 """TODO(maruel): This will become an error soon.""" |
| 430 if not self.enabled: |
| 431 return |
| 439 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 432 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 440 results = self.gclient([ | 433 results = self.gclient([ |
| 441 'sync', '--deps', 'mac', '--revision', | 434 'sync', '--deps', 'mac', '--revision', |
| 442 'invalid@' + self.FAKE_REPOS.git_hashes['repo_1'][0][0], | 435 'invalid@' + self.FAKE_REPOS.git_hashes['repo_1'][0][0], |
| 443 ]) | 436 ]) |
| 444 out = results[0].splitlines(False) | 437 out = results[0].splitlines(False) |
| 445 | 438 |
| 446 self.assertEquals(13, len(out)) | 439 self.assertEquals(13, len(out)) |
| 447 # TODO(maruel): git shouldn't output to stderr... | 440 # TODO(maruel): git shouldn't output to stderr... |
| 448 self.checkString('Please fix your script, having invalid --revision flags ' | 441 self.checkString('Please fix your script, having invalid --revision flags ' |
| 449 'will soon considered an error.\nSwitched to a new branch \'%s\'\n' % | 442 'will soon considered an error.\nSwitched to a new branch \'%s\'\n' % |
| 450 self.FAKE_REPOS.git_hashes['repo_2'][0][0][:7], | 443 self.FAKE_REPOS.git_hashes['repo_2'][0][0][:7], |
| 451 results[1]) | 444 results[1]) |
| 452 self.assertEquals(0, results[2]) | 445 self.assertEquals(0, results[2]) |
| 453 tree = mangle_git_tree( | 446 tree = mangle_git_tree( |
| 454 ('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), | 447 ('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), |
| 455 (join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][0][1]), | 448 ('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][0][1]), |
| 456 (join('src', 'repo2', 'repo_renamed'), | 449 ('src/repo2/repo_renamed', |
| 457 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | 450 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 458 ) | 451 ) |
| 459 tree[join('src', 'git_hooked1')] = 'git_hooked1' | 452 tree['src/git_hooked1'] = 'git_hooked1' |
| 460 tree[join('src', 'git_hooked2')] = 'git_hooked2' | 453 tree['src/git_hooked2'] = 'git_hooked2' |
| 461 self.assertTree(tree) | 454 self.assertTree(tree) |
| 462 | 455 |
| 463 def testSyncNoSolutionName(self): | 456 def testSyncNoSolutionName(self): |
| 457 if not self.enabled: |
| 458 return |
| 464 # When no solution name is provided, gclient uses the first solution listed. | 459 # When no solution name is provided, gclient uses the first solution listed. |
| 465 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 460 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 466 results = self.gclient([ | 461 results = self.gclient([ |
| 467 'sync', '--deps', 'mac', '--revision', | 462 'sync', '--deps', 'mac', '--revision', |
| 468 self.FAKE_REPOS.git_hashes['repo_1'][0][0], | 463 self.FAKE_REPOS.git_hashes['repo_1'][0][0], |
| 469 ]) | 464 ]) |
| 470 out = results[0].splitlines(False) | 465 out = results[0].splitlines(False) |
| 471 self.assertEquals(12, len(out)) | 466 self.assertEquals(12, len(out)) |
| 472 # TODO(maruel): git shouldn't output to stderr... | 467 # TODO(maruel): git shouldn't output to stderr... |
| 473 self.checkString('Switched to a new branch \'%s\'\n' | 468 self.checkString('Switched to a new branch \'%s\'\n' |
| 474 % self.FAKE_REPOS.git_hashes['repo_1'][0][0], results[1]) | 469 % self.FAKE_REPOS.git_hashes['repo_1'][0][0], results[1]) |
| 475 self.assertEquals(0, results[2]) | 470 self.assertEquals(0, results[2]) |
| 476 tree = mangle_git_tree( | 471 tree = mangle_git_tree( |
| 477 ('src', self.FAKE_REPOS.git_hashes['repo_1'][0][1]), | 472 ('src', self.FAKE_REPOS.git_hashes['repo_1'][0][1]), |
| 478 (join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][1][1]), | 473 ('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][1][1]), |
| 479 (join('src', 'repo2', 'repo3'), | 474 ('src/repo2/repo3', self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 480 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | 475 ('src/repo4', self.FAKE_REPOS.git_hashes['repo_4'][1][1]), |
| 481 (join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]), | |
| 482 ) | 476 ) |
| 483 self.assertTree(tree) | 477 self.assertTree(tree) |
| 484 | 478 |
| 485 def testRevertAndStatus(self): | 479 def testRevertAndStatus(self): |
| 486 """TODO(maruel): Remove this line once this test is fixed.""" | 480 """TODO(maruel): Remove this line once this test is fixed.""" |
| 481 if not self.enabled: |
| 482 return |
| 487 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 483 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 488 # Tested in testSync. | 484 # Tested in testSync. |
| 489 self.gclient(['sync', '--deps', 'mac']) | 485 self.gclient(['sync', '--deps', 'mac']) |
| 490 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') | 486 write(join(self.root_dir, 'src', 'repo2', 'hi'), 'Hey!') |
| 491 | 487 |
| 492 results = self.gclient(['status']) | 488 results = self.gclient(['status', '--deps', 'mac']) |
| 493 out = results[0].splitlines(False) | 489 out = results[0].splitlines(False) |
| 494 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned | 490 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned |
| 495 # files. | 491 # files. |
| 496 self.assertEquals(0, len(out)) | 492 self.assertEquals(0, len(out)) |
| 497 | 493 |
| 498 # Revert implies --force implies running hooks without looking at pattern | 494 # Revert implies --force implies running hooks without looking at pattern |
| 499 # matching. | 495 # matching. |
| 500 results = self.gclient(['revert']) | 496 results = self.gclient(['revert', '--deps', 'mac']) |
| 501 out = results[0].splitlines(False) | 497 out = results[0].splitlines(False) |
| 502 # TODO(maruel): http://crosbug.com/3583 It just runs the hooks right now. | 498 # TODO(maruel): http://crosbug.com/3583 It just runs the hooks right now. |
| 503 self.assertEquals(7, len(out)) | 499 self.assertEquals(7, len(out)) |
| 504 self.checkString('', results[1]) | 500 self.checkString('', results[1]) |
| 505 self.assertEquals(0, results[2]) | 501 self.assertEquals(0, results[2]) |
| 506 tree = mangle_git_tree( | 502 tree = mangle_git_tree( |
| 507 ('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), | 503 ('src', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), |
| 508 (join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][0][1]), | 504 ('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][0][1]), |
| 509 (join('src', 'repo2', 'repo_renamed'), | 505 ('src/repo2/repo_renamed', self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 510 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | |
| 511 ) | 506 ) |
| 512 # TODO(maruel): http://crosbug.com/3583 This file should have been removed. | 507 # TODO(maruel): http://crosbug.com/3583 This file should have been removed. |
| 513 tree[join('src', 'repo2', 'hi')] = 'Hey!' | 508 tree[join('src', 'repo2', 'hi')] = 'Hey!' |
| 514 tree[join('src', 'git_hooked1')] = 'git_hooked1' | 509 tree['src/git_hooked1'] = 'git_hooked1' |
| 515 tree[join('src', 'git_hooked2')] = 'git_hooked2' | 510 tree['src/git_hooked2'] = 'git_hooked2' |
| 516 self.assertTree(tree) | 511 self.assertTree(tree) |
| 517 | 512 |
| 518 results = self.gclient(['status']) | 513 results = self.gclient(['status', '--deps', 'mac']) |
| 519 out = results[0].splitlines(False) | 514 out = results[0].splitlines(False) |
| 520 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned | 515 # TODO(maruel): http://crosbug.com/3584 It should output the unversioned |
| 521 # files. | 516 # files. |
| 522 self.assertEquals(0, len(out)) | 517 self.assertEquals(0, len(out)) |
| 523 | 518 |
| 524 def testRunHooks(self): | 519 def testRunHooks(self): |
| 520 if not self.enabled: |
| 521 return |
| 525 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 522 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 526 self.gclient(['sync', '--deps', 'mac']) | 523 self.gclient(['sync', '--deps', 'mac']) |
| 527 results = self.gclient(['runhooks']) | 524 results = self.gclient(['runhooks', '--deps', 'mac']) |
| 528 logging.debug(results[0]) | 525 logging.debug(results[0]) |
| 529 out = results[0].splitlines(False) | 526 out = results[0].splitlines(False) |
| 530 self.assertEquals(4, len(out)) | 527 self.assertEquals(4, len(out)) |
| 531 self.assertEquals(out[0], '') | 528 self.assertEquals(out[0], '') |
| 532 self.assertTrue(re.match(r'^________ running \'.*?python -c ' | 529 self.assertTrue(re.match(r'^________ running \'.*?python -c ' |
| 533 r'open\(\'src/git_hooked1\', \'w\'\)\.write\(\'git_hooked1\'\)\' in \'.*', | 530 r'open\(\'src/git_hooked1\', \'w\'\)\.write\(\'git_hooked1\'\)\' in \'.*', |
| 534 out[1])) | 531 out[1])) |
| 535 self.assertEquals(out[2], '') | 532 self.assertEquals(out[2], '') |
| 536 # runhooks runs all hooks even if not matching by design. | 533 # runhooks runs all hooks even if not matching by design. |
| 537 self.assertTrue(re.match(r'^________ running \'.*?python -c ' | 534 self.assertTrue(re.match(r'^________ running \'.*?python -c ' |
| 538 r'open\(\'src/git_hooked2\', \'w\'\)\.write\(\'git_hooked2\'\)\' in \'.*', | 535 r'open\(\'src/git_hooked2\', \'w\'\)\.write\(\'git_hooked2\'\)\' in \'.*', |
| 539 out[3])) | 536 out[3])) |
| 540 self.checkString('', results[1]) | 537 self.checkString('', results[1]) |
| 541 self.assertEquals(0, results[2]) | 538 self.assertEquals(0, results[2]) |
| 542 | 539 |
| 543 def testRevInfo(self): | 540 def testRevInfo(self): |
| 541 if not self.enabled: |
| 542 return |
| 544 # TODO(maruel): Test multiple solutions. | 543 # TODO(maruel): Test multiple solutions. |
| 545 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 544 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 546 self.gclient(['sync', '--deps', 'mac']) | 545 self.gclient(['sync', '--deps', 'mac']) |
| 547 results = self.gclient(['revinfo']) | 546 results = self.gclient(['revinfo', '--deps', 'mac']) |
| 548 out = ('src: %(base)srepo_1@%(hash1)s;\n' | 547 out = ('src: %(base)srepo_1@%(hash1)s;\n' |
| 549 'src/repo2: %(base)srepo_2@%(hash2)s;\n' | 548 'src/repo2: %(base)srepo_2@%(hash2)s;\n' |
| 550 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % | 549 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % |
| 551 { | 550 { |
| 552 'base': self.git_base, | 551 'base': self.git_base, |
| 553 'hash1': self.FAKE_REPOS.git_hashes['repo_1'][1][0], | 552 'hash1': self.FAKE_REPOS.git_hashes['repo_1'][1][0], |
| 554 'hash2': self.FAKE_REPOS.git_hashes['repo_2'][0][0], | 553 'hash2': self.FAKE_REPOS.git_hashes['repo_2'][0][0], |
| 555 'hash3': self.FAKE_REPOS.git_hashes['repo_3'][1][0], | 554 'hash3': self.FAKE_REPOS.git_hashes['repo_3'][1][0], |
| 556 }) | 555 }) |
| 557 self.check((out, '', 0), results) | 556 self.check((out, '', 0), results) |
| 558 | 557 |
| 559 | 558 |
| 560 class GClientSmokeBoth(GClientSmokeBase): | 559 class GClientSmokeBoth(GClientSmokeBase): |
| 561 def setUp(self): | 560 def setUp(self): |
| 562 GClientSmokeBase.setUp(self) | 561 GClientSmokeBase.setUp(self) |
| 563 self.FAKE_REPOS.setUpSVN() | 562 self.FAKE_REPOS.setUpSVN() |
| 564 self.FAKE_REPOS.setUpGIT() | 563 self.enabled = self.FAKE_REPOS.setUpGIT() |
| 565 | 564 |
| 566 def testMultiSolutions(self): | 565 def testMultiSolutions(self): |
| 566 if not self.enabled: |
| 567 return |
| 567 self.gclient(['config', '--spec', | 568 self.gclient(['config', '--spec', |
| 568 'solutions=[' | 569 'solutions=[' |
| 569 '{"name": "src",' | 570 '{"name": "src",' |
| 570 ' "url": "' + self.svn_base + 'trunk/src/"},' | 571 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 571 '{"name": "src-git",' | 572 '{"name": "src-git",' |
| 572 '"url": "' + self.git_base + 'repo_1"}]']) | 573 '"url": "' + self.git_base + 'repo_1"}]']) |
| 573 results = self.gclient(['sync', '--deps', 'mac']) | 574 results = self.gclient(['sync', '--deps', 'mac']) |
| 574 out = results[0].splitlines(False) | 575 out = results[0].splitlines(False) |
| 575 self.assertEquals(32, len(out)) | 576 self.assertEquals(32, len(out)) |
| 576 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to | 577 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to |
| 577 # new branch \'hash\''. | 578 # new branch \'hash\''. |
| 578 #self.checkString('', results[1]) | 579 #self.checkString('', results[1]) |
| 579 self.assertEquals(0, results[2]) | 580 self.assertEquals(0, results[2]) |
| 580 tree = mangle_git_tree( | 581 tree = mangle_git_tree( |
| 581 ('src-git', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), | 582 ('src-git', self.FAKE_REPOS.git_hashes['repo_1'][1][1]), |
| 582 (join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][0][1]), | 583 ('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][0][1]), |
| 583 (join('src', 'repo2', 'repo_renamed'), | 584 ('src/repo2/repo_renamed', self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 584 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | |
| 585 ) | 585 ) |
| 586 tree.update(mangle_svn_tree( | 586 tree.update(mangle_svn_tree( |
| 587 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[2]), | 587 ('trunk/src', 'src', self.FAKE_REPOS.svn_revs[2]), |
| 588 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'foo'), | 588 ('trunk/third_party/foo', 'src/third_party/foo', |
| 589 self.FAKE_REPOS.svn_revs[1]), | 589 self.FAKE_REPOS.svn_revs[1]), |
| 590 (join('trunk', 'other'), join('src', 'other'), | 590 ('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]), |
| 591 self.FAKE_REPOS.svn_revs[2]), | |
| 592 )) | 591 )) |
| 593 tree[join('src', 'git_hooked1')] = 'git_hooked1' | 592 tree['src/git_hooked1'] = 'git_hooked1' |
| 594 tree[join('src', 'git_hooked2')] = 'git_hooked2' | 593 tree['src/git_hooked2'] = 'git_hooked2' |
| 595 tree[join('src', 'svn_hooked1')] = 'svn_hooked1' | 594 tree['src/svn_hooked1'] = 'svn_hooked1' |
| 596 tree[join('src', 'svn_hooked2')] = 'svn_hooked2' | 595 tree['src/svn_hooked2'] = 'svn_hooked2' |
| 597 self.assertTree(tree) | 596 self.assertTree(tree) |
| 598 | 597 |
| 599 def testMultiSolutionsMultiRev(self): | 598 def testMultiSolutionsMultiRev(self): |
| 599 if not self.enabled: |
| 600 return |
| 600 self.gclient(['config', '--spec', | 601 self.gclient(['config', '--spec', |
| 601 'solutions=[' | 602 'solutions=[' |
| 602 '{"name": "src",' | 603 '{"name": "src",' |
| 603 ' "url": "' + self.svn_base + 'trunk/src/"},' | 604 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 604 '{"name": "src-git",' | 605 '{"name": "src-git",' |
| 605 '"url": "' + self.git_base + 'repo_1"}]']) | 606 '"url": "' + self.git_base + 'repo_1"}]']) |
| 606 results = self.gclient([ | 607 results = self.gclient([ |
| 607 'sync', '--deps', 'mac', '--revision', '1', '-r', | 608 'sync', '--deps', 'mac', '--revision', '1', '-r', |
| 608 'src-git@' + self.FAKE_REPOS.git_hashes['repo_1'][0][0]]) | 609 'src-git@' + self.FAKE_REPOS.git_hashes['repo_1'][0][0]]) |
| 609 out = results[0].splitlines(False) | 610 out = results[0].splitlines(False) |
| 610 self.assertEquals(35, len(out)) | 611 self.assertEquals(35, len(out)) |
| 611 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to | 612 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to |
| 612 # new branch \'hash\''. | 613 # new branch \'hash\''. |
| 613 #self.checkString('', results[1]) | 614 #self.checkString('', results[1]) |
| 614 self.assertEquals(0, results[2]) | 615 self.assertEquals(0, results[2]) |
| 615 tree = mangle_git_tree( | 616 tree = mangle_git_tree( |
| 616 ('src-git', self.FAKE_REPOS.git_hashes['repo_1'][0][1]), | 617 ('src-git', self.FAKE_REPOS.git_hashes['repo_1'][0][1]), |
| 617 (join('src', 'repo2'), self.FAKE_REPOS.git_hashes['repo_2'][1][1]), | 618 ('src/repo2', self.FAKE_REPOS.git_hashes['repo_2'][1][1]), |
| 618 (join('src', 'repo2', 'repo3'), | 619 ('src/repo2/repo3', self.FAKE_REPOS.git_hashes['repo_3'][1][1]), |
| 619 self.FAKE_REPOS.git_hashes['repo_3'][1][1]), | 620 ('src/repo4', self.FAKE_REPOS.git_hashes['repo_4'][1][1]), |
| 620 (join('src', 'repo4'), self.FAKE_REPOS.git_hashes['repo_4'][1][1]), | |
| 621 ) | 621 ) |
| 622 tree.update(mangle_svn_tree( | 622 tree.update(mangle_svn_tree( |
| 623 (join('trunk', 'src'), 'src', self.FAKE_REPOS.svn_revs[1]), | 623 ('trunk/src', 'src', self.FAKE_REPOS.svn_revs[1]), |
| 624 (join('trunk', 'third_party', 'foo'), join('src', 'third_party', 'fpp'), | 624 ('trunk/third_party/foo', 'src/third_party/fpp', |
| 625 self.FAKE_REPOS.svn_revs[2]), | 625 self.FAKE_REPOS.svn_revs[2]), |
| 626 (join('trunk', 'other'), join('src', 'other'), | 626 ('trunk/other', 'src/other', self.FAKE_REPOS.svn_revs[2]), |
| 627 self.FAKE_REPOS.svn_revs[2]), | 627 ('trunk/third_party/foo', 'src/third_party/prout', |
| 628 (join('trunk', 'third_party', 'foo'), | |
| 629 join('src', 'third_party', 'prout'), | |
| 630 self.FAKE_REPOS.svn_revs[2]), | 628 self.FAKE_REPOS.svn_revs[2]), |
| 631 )) | 629 )) |
| 632 self.assertTree(tree) | 630 self.assertTree(tree) |
| 633 | 631 |
| 634 | 632 |
| 635 if __name__ == '__main__': | 633 if __name__ == '__main__': |
| 636 if '-c' in sys.argv: | 634 if '-c' in sys.argv: |
| 637 COVERAGE = True | 635 COVERAGE = True |
| 638 sys.argv.remove('-c') | 636 sys.argv.remove('-c') |
| 639 if os.path.exists('.coverage'): | 637 if os.path.exists('.coverage'): |
| 640 os.remove('.coverage') | 638 os.remove('.coverage') |
| 641 os.environ['COVERAGE_FILE'] = os.path.join( | 639 os.environ['COVERAGE_FILE'] = os.path.join( |
| 642 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 640 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 643 '.coverage') | 641 '.coverage') |
| 644 unittest.main() | 642 unittest.main() |
| OLD | NEW |