| 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. |
| 11 """ | 11 """ |
| 12 | 12 |
| 13 # pylint: disable=E1103,W0403 | 13 # pylint: disable=E1103,W0403 |
| 14 | 14 |
| 15 import logging | 15 import logging |
| 16 import os | 16 import os |
| 17 import re | 17 import re |
| 18 import subprocess | 18 import subprocess |
| 19 import sys | 19 import sys |
| 20 import unittest | 20 import unittest |
| 21 | 21 |
| 22 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | 22 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 23 sys.path.insert(0, os.path.dirname(ROOT_DIR)) | 23 sys.path.insert(0, os.path.dirname(ROOT_DIR)) |
| 24 from tests.fake_repos import check_call, join, write, FakeReposTestBase | 24 from tests.fake_repos import join, write, FakeReposTestBase |
| 25 import subprocess2 |
| 25 | 26 |
| 26 GCLIENT_PATH = os.path.join(os.path.dirname(ROOT_DIR), 'gclient') | 27 GCLIENT_PATH = os.path.join(os.path.dirname(ROOT_DIR), 'gclient') |
| 27 COVERAGE = False | 28 COVERAGE = False |
| 28 | 29 |
| 29 | 30 |
| 30 class GClientSmokeBase(FakeReposTestBase): | 31 class GClientSmokeBase(FakeReposTestBase): |
| 31 def setUp(self): | 32 def setUp(self): |
| 32 super(GClientSmokeBase, self).setUp() | 33 super(GClientSmokeBase, self).setUp() |
| 33 # Make sure it doesn't try to auto update when testing! | 34 # Make sure it doesn't try to auto update when testing! |
| 34 self.env = os.environ.copy() | 35 self.env = os.environ.copy() |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 | 1076 |
| 1076 | 1077 |
| 1077 class GClientSmokeFromCheckout(GClientSmokeBase): | 1078 class GClientSmokeFromCheckout(GClientSmokeBase): |
| 1078 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. | 1079 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. |
| 1079 def setUp(self): | 1080 def setUp(self): |
| 1080 super(GClientSmokeFromCheckout, self).setUp() | 1081 super(GClientSmokeFromCheckout, self).setUp() |
| 1081 self.enabled = self.FAKE_REPOS.set_up_svn() | 1082 self.enabled = self.FAKE_REPOS.set_up_svn() |
| 1082 os.rmdir(self.root_dir) | 1083 os.rmdir(self.root_dir) |
| 1083 if self.enabled: | 1084 if self.enabled: |
| 1084 usr, pwd = self.FAKE_REPOS.USERS[0] | 1085 usr, pwd = self.FAKE_REPOS.USERS[0] |
| 1085 check_call( | 1086 subprocess2.check_call( |
| 1086 ['svn', 'checkout', self.svn_base + '/trunk/webkit', | 1087 ['svn', 'checkout', self.svn_base + '/trunk/webkit', |
| 1087 self.root_dir, '-q', | 1088 self.root_dir, '-q', |
| 1088 '--non-interactive', '--no-auth-cache', | 1089 '--non-interactive', '--no-auth-cache', |
| 1089 '--username', usr, '--password', pwd]) | 1090 '--username', usr, '--password', pwd]) |
| 1090 | 1091 |
| 1091 def testSync(self): | 1092 def testSync(self): |
| 1092 if not self.enabled: | 1093 if not self.enabled: |
| 1093 return | 1094 return |
| 1094 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'], | 1095 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'], |
| 1095 ['running', 'running']) | 1096 ['running', 'running']) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 | 1175 |
| 1175 if '-c' in sys.argv: | 1176 if '-c' in sys.argv: |
| 1176 COVERAGE = True | 1177 COVERAGE = True |
| 1177 sys.argv.remove('-c') | 1178 sys.argv.remove('-c') |
| 1178 if os.path.exists('.coverage'): | 1179 if os.path.exists('.coverage'): |
| 1179 os.remove('.coverage') | 1180 os.remove('.coverage') |
| 1180 os.environ['COVERAGE_FILE'] = os.path.join( | 1181 os.environ['COVERAGE_FILE'] = os.path.join( |
| 1181 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1182 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 1182 '.coverage') | 1183 '.coverage') |
| 1183 unittest.main() | 1184 unittest.main() |
| OLD | NEW |