| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 if os.path.exists(p): | 192 if os.path.exists(p): |
| 193 os.remove(p) | 193 os.remove(p) |
| 194 results = self.gclient(cmd) | 194 results = self.gclient(cmd) |
| 195 self.check(('', '', 0), results) | 195 self.check(('', '', 0), results) |
| 196 self.checkString(expected, open(p, 'rU').read()) | 196 self.checkString(expected, open(p, 'rU').read()) |
| 197 | 197 |
| 198 test(['config', self.svn_base + 'trunk/src/'], | 198 test(['config', self.svn_base + 'trunk/src/'], |
| 199 ('solutions = [\n' | 199 ('solutions = [\n' |
| 200 ' { "name" : "src",\n' | 200 ' { "name" : "src",\n' |
| 201 ' "url" : "%strunk/src",\n' | 201 ' "url" : "%strunk/src",\n' |
| 202 ' "deps_file" : "DEPS",\n' |
| 202 ' "custom_deps" : {\n' | 203 ' "custom_deps" : {\n' |
| 203 ' },\n' | 204 ' },\n' |
| 204 ' "safesync_url": "",\n' | 205 ' "safesync_url": "",\n' |
| 205 ' },\n' | 206 ' },\n' |
| 206 ']\n') % self.svn_base) | 207 ']\n') % self.svn_base) |
| 207 | 208 |
| 208 test(['config', self.git_base + 'repo_1', '--name', 'src'], | 209 test(['config', self.git_base + 'repo_1', '--name', 'src'], |
| 209 ('solutions = [\n' | 210 ('solutions = [\n' |
| 210 ' { "name" : "src",\n' | 211 ' { "name" : "src",\n' |
| 211 ' "url" : "%srepo_1",\n' | 212 ' "url" : "%srepo_1",\n' |
| 213 ' "deps_file" : "DEPS",\n' |
| 212 ' "custom_deps" : {\n' | 214 ' "custom_deps" : {\n' |
| 213 ' },\n' | 215 ' },\n' |
| 214 ' "safesync_url": "",\n' | 216 ' "safesync_url": "",\n' |
| 215 ' },\n' | 217 ' },\n' |
| 216 ']\n') % self.git_base) | 218 ']\n') % self.git_base) |
| 217 | 219 |
| 218 test(['config', 'foo', 'faa'], | 220 test(['config', 'foo', 'faa'], |
| 219 'solutions = [\n' | 221 'solutions = [\n' |
| 220 ' { "name" : "foo",\n' | 222 ' { "name" : "foo",\n' |
| 221 ' "url" : "foo",\n' | 223 ' "url" : "foo",\n' |
| 224 ' "deps_file" : "DEPS",\n' |
| 222 ' "custom_deps" : {\n' | 225 ' "custom_deps" : {\n' |
| 223 ' },\n' | 226 ' },\n' |
| 224 ' "safesync_url": "faa",\n' | 227 ' "safesync_url": "faa",\n' |
| 225 ' },\n' | 228 ' },\n' |
| 226 ']\n') | 229 ']\n') |
| 227 | 230 |
| 231 test(['config', 'foo', '--deps', 'blah'], |
| 232 'solutions = [\n' |
| 233 ' { "name" : "foo",\n' |
| 234 ' "url" : "foo",\n' |
| 235 ' "deps_file" : "blah",\n' |
| 236 ' "custom_deps" : {\n' |
| 237 ' },\n' |
| 238 ' "safesync_url": "",\n' |
| 239 ' },\n' |
| 240 ']\n') |
| 241 |
| 228 test(['config', '--spec', '["blah blah"]'], '["blah blah"]') | 242 test(['config', '--spec', '["blah blah"]'], '["blah blah"]') |
| 229 | 243 |
| 230 os.remove(p) | 244 os.remove(p) |
| 231 results = self.gclient(['config', 'foo', 'faa', 'fuu']) | 245 results = self.gclient(['config', 'foo', 'faa', 'fuu']) |
| 232 err = ('Usage: gclient.py config [options] [url] [safesync url]\n\n' | 246 err = ('Usage: gclient.py config [options] [url] [safesync url]\n\n' |
| 233 'gclient.py: error: Inconsistent arguments. Use either --spec or one' | 247 'gclient.py: error: Inconsistent arguments. Use either --spec or one' |
| 234 ' or 2 args\n') | 248 ' or 2 args\n') |
| 235 self.check(('', err, 2), results) | 249 self.check(('', err, 2), results) |
| 236 self.assertFalse(os.path.exists(join(self.root_dir, '.gclient'))) | 250 self.assertFalse(os.path.exists(join(self.root_dir, '.gclient'))) |
| 237 | 251 |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 'src/file/other: %(base)s/other/DEPS@2\n' | 679 'src/file/other: %(base)s/other/DEPS@2\n' |
| 666 'src/other: %(base)s/other@2\n' | 680 'src/other: %(base)s/other@2\n' |
| 667 'src/third_party/foo: %(base)s/third_party/foo@1\n' % | 681 'src/third_party/foo: %(base)s/third_party/foo@1\n' % |
| 668 { 'base': self.svn_base + 'trunk' }) | 682 { 'base': self.svn_base + 'trunk' }) |
| 669 self.check((out, '', 0), results) | 683 self.check((out, '', 0), results) |
| 670 results = self.gclient(['revinfo', '--deps', 'mac', '--snapshot']) | 684 results = self.gclient(['revinfo', '--deps', 'mac', '--snapshot']) |
| 671 out = ('# Snapshot generated with gclient revinfo --snapshot\n' | 685 out = ('# Snapshot generated with gclient revinfo --snapshot\n' |
| 672 'solutions = [\n' | 686 'solutions = [\n' |
| 673 ' { "name" : "src",\n' | 687 ' { "name" : "src",\n' |
| 674 ' "url" : "%(base)s/src",\n' | 688 ' "url" : "%(base)s/src",\n' |
| 689 ' "deps_file" : "DEPS",\n' |
| 675 ' "custom_deps" : {\n' | 690 ' "custom_deps" : {\n' |
| 676 ' "foo/bar": None,\n' | 691 ' "foo/bar": None,\n' |
| 677 ' "invalid": None,\n' | 692 ' "invalid": None,\n' |
| 678 ' "src/file/other": \'%(base)s/other/DEPS@2\',\n' | 693 ' "src/file/other": \'%(base)s/other/DEPS@2\',\n' |
| 679 ' "src/other": \'%(base)s/other@2\',\n' | 694 ' "src/other": \'%(base)s/other@2\',\n' |
| 680 ' "src/third_party/foo": ' | 695 ' "src/third_party/foo": ' |
| 681 '\'%(base)s/third_party/foo@1\',\n' | 696 '\'%(base)s/third_party/foo@1\',\n' |
| 682 ' },\n' | 697 ' },\n' |
| 683 ' "safesync_url": "",\n' | 698 ' "safesync_url": "",\n' |
| 684 ' },\n' | 699 ' },\n' |
| 685 ']\n\n' % | 700 ']\n\n' % |
| 686 { 'base': self.svn_base + 'trunk' }) | 701 { 'base': self.svn_base + 'trunk' }) |
| 687 self.check((out, '', 0), results) | 702 self.check((out, '', 0), results) |
| 688 | 703 |
| 704 def testRevInfoAltDeps(self): |
| 705 if not self.enabled: |
| 706 return |
| 707 self.gclient(['config', self.svn_base + 'trunk/src/', '--deps-file', |
| 708 'DEPS.alt']) |
| 709 self.gclient(['sync']) |
| 710 results = self.gclient(['revinfo', '--snapshot']) |
| 711 out = ('# Snapshot generated with gclient revinfo --snapshot\n' |
| 712 'solutions = [\n' |
| 713 ' { "name" : "src",\n' |
| 714 ' "url" : "%(base)s/src",\n' |
| 715 ' "deps_file" : "DEPS.alt",\n' |
| 716 ' "custom_deps" : {\n' |
| 717 ' "src/other2": \'%(base)s/other@2\',\n' |
| 718 ' },\n' |
| 719 ' "safesync_url": "",\n' |
| 720 ' },\n' |
| 721 ']\n\n' % |
| 722 { 'base': self.svn_base + 'trunk' }) |
| 723 self.check((out, '', 0), results) |
| 724 |
| 725 |
| 689 def testWrongDirectory(self): | 726 def testWrongDirectory(self): |
| 690 # Check that we're not using a .gclient configuration which only talks | 727 # Check that we're not using a .gclient configuration which only talks |
| 691 # about a subdirectory src when we're in a different subdirectory src-other. | 728 # about a subdirectory src when we're in a different subdirectory src-other. |
| 692 if not self.enabled: | 729 if not self.enabled: |
| 693 return | 730 return |
| 694 self.gclient(['config', self.svn_base + 'trunk/src/']) | 731 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 695 self.gclient(['sync']) | 732 self.gclient(['sync']) |
| 696 other_src = join(self.root_dir, 'src-other') | 733 other_src = join(self.root_dir, 'src-other') |
| 697 os.mkdir(other_src) | 734 os.mkdir(other_src) |
| 698 res = ('', 'Error: client not configured; see \'gclient config\'\n', 1) | 735 res = ('', 'Error: client not configured; see \'gclient config\'\n', 1) |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 | 1254 |
| 1218 if '-c' in sys.argv: | 1255 if '-c' in sys.argv: |
| 1219 COVERAGE = True | 1256 COVERAGE = True |
| 1220 sys.argv.remove('-c') | 1257 sys.argv.remove('-c') |
| 1221 if os.path.exists('.coverage'): | 1258 if os.path.exists('.coverage'): |
| 1222 os.remove('.coverage') | 1259 os.remove('.coverage') |
| 1223 os.environ['COVERAGE_FILE'] = os.path.join( | 1260 os.environ['COVERAGE_FILE'] = os.path.join( |
| 1224 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1261 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 1225 '.coverage') | 1262 '.coverage') |
| 1226 unittest.main() | 1263 unittest.main() |
| OLD | NEW |