Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: tests/gclient_test.py

Issue 899503003: Add back detection of unreachable code (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: remove self-explanatory msg Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.fail()
997 except gclient_utils.Error, e: 998 except gclient_utils.Error, e:
998 self.assertIn('allowed_hosts must be', str(e)) 999 self.assertIn('allowed_hosts must be', str(e))
999 finally: 1000 finally:
1000 self._get_processed() 1001 self._get_processed()
1001 1002
1002 def testDepsParseFailureWithNonIterableAllowedHosts(self): 1003 def testDepsParseFailureWithNonIterableAllowedHosts(self):
1003 """Verifies gclient fails with defined but non-iterable allowed_hosts.""" 1004 """Verifies gclient fails with defined but non-iterable allowed_hosts."""
1004 write( 1005 write(
1005 '.gclient', 1006 '.gclient',
1006 'solutions = [\n' 1007 'solutions = [\n'
1007 ' { "name": "foo", "url": "svn://example.com/foo",\n' 1008 ' { "name": "foo", "url": "svn://example.com/foo",\n'
1008 ' "deps_file" : ".DEPS.git",\n' 1009 ' "deps_file" : ".DEPS.git",\n'
1009 ' },\n' 1010 ' },\n'
1010 ']') 1011 ']')
1011 write( 1012 write(
1012 os.path.join('foo', 'DEPS'), 1013 os.path.join('foo', 'DEPS'),
1013 'allowed_hosts = None\n' 1014 'allowed_hosts = None\n'
1014 'deps = {\n' 1015 'deps = {\n'
1015 ' "bar": "/bar",\n' 1016 ' "bar": "/bar",\n'
1016 '}') 1017 '}')
1017 options, _ = gclient.OptionParser().parse_args([]) 1018 options, _ = gclient.OptionParser().parse_args([])
1018 obj = gclient.GClient.LoadCurrentConfig(options) 1019 obj = gclient.GClient.LoadCurrentConfig(options)
1019 try: 1020 try:
1020 obj.RunOnDeps('None', []) 1021 obj.RunOnDeps('None', [])
1022 self.fail()
1021 except gclient_utils.Error, e: 1023 except gclient_utils.Error, e:
1022 self.assertIn('allowed_hosts must be', str(e)) 1024 self.assertIn('allowed_hosts must be', str(e))
1023 finally: 1025 finally:
1024 self._get_processed() 1026 self._get_processed()
1025 1027
1026 1028
1027 if __name__ == '__main__': 1029 if __name__ == '__main__':
1028 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) 1030 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout)
1029 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) 1031 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True)
1030 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) 1032 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr)
1031 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) 1033 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True)
1032 logging.basicConfig( 1034 logging.basicConfig(
1033 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ 1035 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
1034 min(sys.argv.count('-v'), 3)], 1036 min(sys.argv.count('-v'), 3)],
1035 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' 1037 format='%(relativeCreated)4d %(levelname)5s %(module)13s('
1036 '%(lineno)d) %(message)s') 1038 '%(lineno)d) %(message)s')
1037 unittest.main() 1039 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698