| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Unit tests for gclient.py. | 6 """Unit tests for gclient.py. |
| 7 | 7 |
| 8 See gclient_smoketest.py for integration tests. | 8 See gclient_smoketest.py for integration tests. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 write( | 987 write( |
| 988 os.path.join('foo', 'DEPS'), | 988 os.path.join('foo', 'DEPS'), |
| 989 'allowed_hosts = []\n' | 989 'allowed_hosts = []\n' |
| 990 'deps = {\n' | 990 'deps = {\n' |
| 991 ' "bar": "/bar",\n' | 991 ' "bar": "/bar",\n' |
| 992 '}') | 992 '}') |
| 993 options, _ = gclient.OptionParser().parse_args([]) | 993 options, _ = gclient.OptionParser().parse_args([]) |
| 994 obj = gclient.GClient.LoadCurrentConfig(options) | 994 obj = gclient.GClient.LoadCurrentConfig(options) |
| 995 try: | 995 try: |
| 996 obj.RunOnDeps('None', []) | 996 obj.RunOnDeps('None', []) |
| 997 self.assertFalse("unreachable code") | |
| 998 except gclient_utils.Error, e: | 997 except gclient_utils.Error, e: |
| 999 self.assertIn('allowed_hosts must be', str(e)) | 998 self.assertIn('allowed_hosts must be', str(e)) |
| 1000 finally: | 999 finally: |
| 1001 self._get_processed() | 1000 self._get_processed() |
| 1002 | 1001 |
| 1003 def testDepsParseFailureWithNonIterableAllowedHosts(self): | 1002 def testDepsParseFailureWithNonIterableAllowedHosts(self): |
| 1004 """Verifies gclient fails with defined but non-iterable allowed_hosts.""" | 1003 """Verifies gclient fails with defined but non-iterable allowed_hosts.""" |
| 1005 write( | 1004 write( |
| 1006 '.gclient', | 1005 '.gclient', |
| 1007 'solutions = [\n' | 1006 'solutions = [\n' |
| 1008 ' { "name": "foo", "url": "svn://example.com/foo",\n' | 1007 ' { "name": "foo", "url": "svn://example.com/foo",\n' |
| 1009 ' "deps_file" : ".DEPS.git",\n' | 1008 ' "deps_file" : ".DEPS.git",\n' |
| 1010 ' },\n' | 1009 ' },\n' |
| 1011 ']') | 1010 ']') |
| 1012 write( | 1011 write( |
| 1013 os.path.join('foo', 'DEPS'), | 1012 os.path.join('foo', 'DEPS'), |
| 1014 'allowed_hosts = None\n' | 1013 'allowed_hosts = None\n' |
| 1015 'deps = {\n' | 1014 'deps = {\n' |
| 1016 ' "bar": "/bar",\n' | 1015 ' "bar": "/bar",\n' |
| 1017 '}') | 1016 '}') |
| 1018 options, _ = gclient.OptionParser().parse_args([]) | 1017 options, _ = gclient.OptionParser().parse_args([]) |
| 1019 obj = gclient.GClient.LoadCurrentConfig(options) | 1018 obj = gclient.GClient.LoadCurrentConfig(options) |
| 1020 try: | 1019 try: |
| 1021 obj.RunOnDeps('None', []) | 1020 obj.RunOnDeps('None', []) |
| 1022 self.assertFalse("unreachable code") | |
| 1023 except gclient_utils.Error, e: | 1021 except gclient_utils.Error, e: |
| 1024 self.assertIn('allowed_hosts must be', str(e)) | 1022 self.assertIn('allowed_hosts must be', str(e)) |
| 1025 finally: | 1023 finally: |
| 1026 self._get_processed() | 1024 self._get_processed() |
| 1027 | 1025 |
| 1028 | 1026 |
| 1029 if __name__ == '__main__': | 1027 if __name__ == '__main__': |
| 1030 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 1028 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
| 1031 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) | 1029 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |
| 1032 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) | 1030 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) |
| 1033 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) | 1031 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) |
| 1034 logging.basicConfig( | 1032 logging.basicConfig( |
| 1035 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 1033 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
| 1036 min(sys.argv.count('-v'), 3)], | 1034 min(sys.argv.count('-v'), 3)], |
| 1037 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' | 1035 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' |
| 1038 '%(lineno)d) %(message)s') | 1036 '%(lineno)d) %(message)s') |
| 1039 unittest.main() | 1037 unittest.main() |
| OLD | NEW |