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

Side by Side Diff: tools-webrtc/autoroller/unittests/roll_deps_test.py

Issue 2737233003: Revert of PyLint fixes for tools-webrtc and webrtc/tools (Closed)
Patch Set: Created 3 years, 9 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 | « cleanup_links.py ('k') | tools-webrtc/check_package_boundaries.py » ('j') | 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) 2015 The WebRTC project authors. All Rights Reserved. 2 # Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 # 3 #
4 # Use of this source code is governed by a BSD-style license 4 # Use of this source code is governed by a BSD-style license
5 # that can be found in the LICENSE file in the root of the source 5 # that can be found in the LICENSE file in the root of the source
6 # tree. An additional intellectual property rights grant can be found 6 # tree. An additional intellectual property rights grant can be found
7 # in the file PATENTS. All contributing project authors may 7 # in the file PATENTS. All contributing project authors may
8 # be found in the AUTHORS file in the root of the source tree. 8 # be found in the AUTHORS file in the root of the source tree.
9 9
10 import glob 10 import glob
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 43
44 class TestError(Exception): 44 class TestError(Exception):
45 pass 45 pass
46 46
47 47
48 class FakeCmd(object): 48 class FakeCmd(object):
49 def __init__(self): 49 def __init__(self):
50 self.expectations = [] 50 self.expectations = []
51 51
52 def AddExpectation(self, *args, **kwargs): 52 def add_expectation(self, *args, **kwargs):
53 returns = kwargs.pop('_returns', None) 53 returns = kwargs.pop('_returns', None)
54 self.expectations.append((args, kwargs, returns)) 54 self.expectations.append((args, kwargs, returns))
55 55
56 def __call__(self, *args, **kwargs): 56 def __call__(self, *args, **kwargs):
57 if not self.expectations: 57 if not self.expectations:
58 raise TestError('Got unexpected\n%s\n%s' % (args, kwargs)) 58 raise TestError('Got unexpected\n%s\n%s' % (args, kwargs))
59 exp_args, exp_kwargs, exp_returns = self.expectations.pop(0) 59 exp_args, exp_kwargs, exp_returns = self.expectations.pop(0)
60 if args != exp_args or kwargs != exp_kwargs: 60 if args != exp_args or kwargs != exp_kwargs:
61 message = 'Expected:\n args: %s\n kwargs: %s\n' % (exp_args, exp_kwargs) 61 message = 'Expected:\n args: %s\n kwargs: %s\n' % (exp_args, exp_kwargs)
62 message += 'Got:\n args: %s\n kwargs: %s\n' % (args, kwargs) 62 message += 'Got:\n args: %s\n kwargs: %s\n' % (args, kwargs)
63 raise TestError(message) 63 raise TestError(message)
64 return exp_returns 64 return exp_returns
65 65
66 66
67 class TestRollChromiumRevision(unittest.TestCase): 67 class TestRollChromiumRevision(unittest.TestCase):
68 def setUp(self): 68 def setUp(self):
69 self._output_dir = tempfile.mkdtemp() 69 self._output_dir = tempfile.mkdtemp()
70 for test_file in glob.glob(os.path.join(SCRIPT_DIR, 'testdata', '*')): 70 for test_file in glob.glob(os.path.join(SCRIPT_DIR, 'testdata', '*')):
71 shutil.copy(test_file, self._output_dir) 71 shutil.copy(test_file, self._output_dir)
72 self._webrtc_depsfile = os.path.join(self._output_dir, 'DEPS') 72 self._webrtc_depsfile = os.path.join(self._output_dir, 'DEPS')
73 self._old_cr_depsfile = os.path.join(self._output_dir, 'DEPS.chromium.old') 73 self._old_cr_depsfile = os.path.join(self._output_dir, 'DEPS.chromium.old')
74 self._new_cr_depsfile = os.path.join(self._output_dir, 'DEPS.chromium.new') 74 self._new_cr_depsfile = os.path.join(self._output_dir, 'DEPS.chromium.new')
75 75
76 self.fake = FakeCmd() 76 self.fake = FakeCmd()
77 self.old_run_command = getattr(roll_deps, '_RunCommand') 77 self.old_RunCommand = getattr(roll_deps, '_RunCommand')
78 setattr(roll_deps, '_RunCommand', self.fake) 78 setattr(roll_deps, '_RunCommand', self.fake)
79 79
80 def tearDown(self): 80 def tearDown(self):
81 shutil.rmtree(self._output_dir, ignore_errors=True) 81 shutil.rmtree(self._output_dir, ignore_errors=True)
82 self.assertEqual(self.fake.expectations, []) 82 self.assertEqual(self.fake.expectations, [])
83 setattr(roll_deps, '_RunCommand', self.old_run_command) 83 setattr(roll_deps, '_RunCommand', self.old_RunCommand)
84 84
85 def testUpdateDepsFile(self): 85 def testUpdateDepsFile(self):
86 new_rev = 'aaaaabbbbbcccccdddddeeeeefffff0000011111' 86 new_rev = 'aaaaabbbbbcccccdddddeeeeefffff0000011111'
87 87
88 current_rev = TEST_DATA_VARS['chromium_revision'] 88 current_rev = TEST_DATA_VARS['chromium_revision']
89 UpdateDepsFile(self._webrtc_depsfile, current_rev, new_rev, []) 89 UpdateDepsFile(self._webrtc_depsfile, current_rev, new_rev, [])
90 with open(self._webrtc_depsfile) as deps_file: 90 with open(self._webrtc_depsfile) as deps_file:
91 deps_contents = deps_file.read() 91 deps_contents = deps_file.read()
92 self.assertTrue(new_rev in deps_contents, 92 self.assertTrue(new_rev in deps_contents,
93 'Failed to find %s in\n%s' % (new_rev, deps_contents)) 93 'Failed to find %s in\n%s' % (new_rev, deps_contents))
94 94
95 def testParseDepsDict(self): 95 def testParseDepsDict(self):
96 with open(self._webrtc_depsfile) as deps_file: 96 with open(self._webrtc_depsfile) as deps_file:
97 deps_contents = deps_file.read() 97 deps_contents = deps_file.read()
98 local_scope = ParseDepsDict(deps_contents) 98 local_scope = ParseDepsDict(deps_contents)
99 vars_dict = local_scope['vars'] 99 vars_dict = local_scope['vars']
100 100
101 def AssertVar(variable_name): 101 def assertVar(variable_name):
102 self.assertEquals(vars_dict[variable_name], TEST_DATA_VARS[variable_name]) 102 self.assertEquals(vars_dict[variable_name], TEST_DATA_VARS[variable_name])
103 AssertVar('chromium_git') 103 assertVar('chromium_git')
104 AssertVar('chromium_revision') 104 assertVar('chromium_revision')
105 self.assertEquals(len(local_scope['deps']), 3) 105 self.assertEquals(len(local_scope['deps']), 3)
106 self.assertEquals(len(local_scope['deps_os']), 1) 106 self.assertEquals(len(local_scope['deps_os']), 1)
107 107
108 def testGetMatchingDepsEntriesReturnsPathInSimpleCase(self): 108 def testGetMatchingDepsEntriesReturnsPathInSimpleCase(self):
109 entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing/gtest') 109 entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing/gtest')
110 self.assertEquals(len(entries), 1) 110 self.assertEquals(len(entries), 1)
111 self.assertEquals(entries[0], DEPS_ENTRIES['src/testing/gtest']) 111 self.assertEquals(entries[0], DEPS_ENTRIES['src/testing/gtest'])
112 112
113 def testGetMatchingDepsEntriesHandlesSimilarStartingPaths(self): 113 def testGetMatchingDepsEntriesHandlesSimilarStartingPaths(self):
114 entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing') 114 entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing')
(...skipping 15 matching lines...) Expand all
130 self.assertEquals(changed_deps[0].current_rev, BUILD_OLD_REV) 130 self.assertEquals(changed_deps[0].current_rev, BUILD_OLD_REV)
131 self.assertEquals(changed_deps[0].new_rev, BUILD_NEW_REV) 131 self.assertEquals(changed_deps[0].new_rev, BUILD_NEW_REV)
132 132
133 self.assertEquals(changed_deps[1].path, 'src/buildtools') 133 self.assertEquals(changed_deps[1].path, 'src/buildtools')
134 self.assertEquals(changed_deps[1].current_rev, BUILDTOOLS_OLD_REV) 134 self.assertEquals(changed_deps[1].current_rev, BUILDTOOLS_OLD_REV)
135 self.assertEquals(changed_deps[1].new_rev, BUILDTOOLS_NEW_REV) 135 self.assertEquals(changed_deps[1].new_rev, BUILDTOOLS_NEW_REV)
136 136
137 137
138 def _SetupGitLsRemoteCall(cmd_fake, url, revision): 138 def _SetupGitLsRemoteCall(cmd_fake, url, revision):
139 cmd = ['git', 'ls-remote', url, revision] 139 cmd = ['git', 'ls-remote', url, revision]
140 cmd_fake.AddExpectation(cmd, _returns=(revision, None)) 140 cmd_fake.add_expectation(cmd, _returns=(revision, None))
141 141
142 142
143 if __name__ == '__main__': 143 if __name__ == '__main__':
144 unittest.main() 144 unittest.main()
OLDNEW
« no previous file with comments | « cleanup_links.py ('k') | tools-webrtc/check_package_boundaries.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698