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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 self.check(res, self.gclient(['diff'])) | 138 self.check(res, self.gclient(['diff'])) |
139 self.check(res, self.gclient(['export', 'foo'])) | 139 self.check(res, self.gclient(['export', 'foo'])) |
140 self.check(res, self.gclient(['pack'])) | 140 self.check(res, self.gclient(['pack'])) |
141 self.check(res, self.gclient(['revert'])) | 141 self.check(res, self.gclient(['revert'])) |
142 self.check(res, self.gclient(['revinfo'])) | 142 self.check(res, self.gclient(['revinfo'])) |
143 self.check(res, self.gclient(['runhooks'])) | 143 self.check(res, self.gclient(['runhooks'])) |
144 self.check(res, self.gclient(['status'])) | 144 self.check(res, self.gclient(['status'])) |
145 self.check(res, self.gclient(['sync'])) | 145 self.check(res, self.gclient(['sync'])) |
146 self.check(res, self.gclient(['update'])) | 146 self.check(res, self.gclient(['update'])) |
147 | 147 |
148 def testWrongConfig(self): | |
149 # tested in testConfig. | |
150 self.gclient(['config', self.svn_base + 'trunk/src/']) | |
151 other_src = join(self.root_dir, 'src-other') | |
152 os.mkdir(other_src) | |
153 res = ('', 'Error: client not configured; see \'gclient config\'\n', 1) | |
154 self.check(res, self.gclient(['status'], other_src)) | |
155 src = join(self.root_dir, 'src') | |
156 os.mkdir(src) | |
157 res = self.gclient(['status'], src) | |
158 self.checkBlock(res[0], [('running', src)]) | |
159 | |
160 def testConfig(self): | 148 def testConfig(self): |
161 p = join(self.root_dir, '.gclient') | 149 p = join(self.root_dir, '.gclient') |
162 def test(cmd, expected): | 150 def test(cmd, expected): |
163 if os.path.exists(p): | 151 if os.path.exists(p): |
164 os.remove(p) | 152 os.remove(p) |
165 results = self.gclient(cmd) | 153 results = self.gclient(cmd) |
166 self.check(('', '', 0), results) | 154 self.check(('', '', 0), results) |
167 self.checkString(expected, open(p, 'rU').read()) | 155 self.checkString(expected, open(p, 'rU').read()) |
168 | 156 |
169 test(['config', self.svn_base + 'trunk/src/'], | 157 test(['config', self.svn_base + 'trunk/src/'], |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 if __name__ == '__main__': | 879 if __name__ == '__main__': |
892 if '-c' in sys.argv: | 880 if '-c' in sys.argv: |
893 COVERAGE = True | 881 COVERAGE = True |
894 sys.argv.remove('-c') | 882 sys.argv.remove('-c') |
895 if os.path.exists('.coverage'): | 883 if os.path.exists('.coverage'): |
896 os.remove('.coverage') | 884 os.remove('.coverage') |
897 os.environ['COVERAGE_FILE'] = os.path.join( | 885 os.environ['COVERAGE_FILE'] = os.path.join( |
898 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 886 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
899 '.coverage') | 887 '.coverage') |
900 unittest.main() | 888 unittest.main() |
OLD | NEW |