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

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

Issue 2581493003: Move tools/autoroller to tools-webrtc/ + rename script (Closed)
Patch Set: Renamed the script Created 4 years 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 | « tools-webrtc/autoroller/roll_deps.py ('k') | tools-webrtc/autoroller/unittests/testdata/DEPS » ('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
11 import os 11 import os
12 import shutil 12 import shutil
13 import sys 13 import sys
14 import tempfile 14 import tempfile
15 import unittest 15 import unittest
16 16
17 17
18 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 18 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
19 PARENT_DIR = os.path.join(SCRIPT_DIR, os.pardir) 19 PARENT_DIR = os.path.join(SCRIPT_DIR, os.pardir)
20 sys.path.append(PARENT_DIR) 20 sys.path.append(PARENT_DIR)
21 import roll_chromium_revision 21 import roll_deps
22 from roll_chromium_revision import CalculateChangedDepsProper, \ 22 from roll_deps import CalculateChangedDepsProper, GetMatchingDepsEntries, \
23 GetMatchingDepsEntries, ParseDepsDict, \ 23 ParseDepsDict, ParseLocalDepsFile, UpdateDepsFile
24 ParseLocalDepsFile, UpdateDepsFile
25 24
26 25
27 TEST_DATA_VARS = { 26 TEST_DATA_VARS = {
28 'chromium_git': 'https://chromium.googlesource.com', 27 'chromium_git': 'https://chromium.googlesource.com',
29 'chromium_revision': '1b9c098a08e40114e44b6c1ec33ddf95c40b901d', 28 'chromium_revision': '1b9c098a08e40114e44b6c1ec33ddf95c40b901d',
30 } 29 }
31 30
32 DEPS_ENTRIES = { 31 DEPS_ENTRIES = {
33 'src/build': 'https://build.com', 32 'src/build': 'https://build.com',
34 'src/buildtools': 'https://buildtools.com', 33 'src/buildtools': 'https://buildtools.com',
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 class TestRollChromiumRevision(unittest.TestCase): 67 class TestRollChromiumRevision(unittest.TestCase):
69 def setUp(self): 68 def setUp(self):
70 self._output_dir = tempfile.mkdtemp() 69 self._output_dir = tempfile.mkdtemp()
71 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', '*')):
72 shutil.copy(test_file, self._output_dir) 71 shutil.copy(test_file, self._output_dir)
73 self._webrtc_depsfile = os.path.join(self._output_dir, 'DEPS') 72 self._webrtc_depsfile = os.path.join(self._output_dir, 'DEPS')
74 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')
75 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')
76 75
77 self.fake = FakeCmd() 76 self.fake = FakeCmd()
78 self.old_RunCommand = getattr(roll_chromium_revision, '_RunCommand') 77 self.old_RunCommand = getattr(roll_deps, '_RunCommand')
79 setattr(roll_chromium_revision, '_RunCommand', self.fake) 78 setattr(roll_deps, '_RunCommand', self.fake)
80 79
81 def tearDown(self): 80 def tearDown(self):
82 shutil.rmtree(self._output_dir, ignore_errors=True) 81 shutil.rmtree(self._output_dir, ignore_errors=True)
83 self.assertEqual(self.fake.expectations, []) 82 self.assertEqual(self.fake.expectations, [])
84 setattr(roll_chromium_revision, '_RunCommand', self.old_RunCommand) 83 setattr(roll_deps, '_RunCommand', self.old_RunCommand)
85 84
86 def testUpdateDepsFile(self): 85 def testUpdateDepsFile(self):
87 new_rev = 'aaaaabbbbbcccccdddddeeeeefffff0000011111' 86 new_rev = 'aaaaabbbbbcccccdddddeeeeefffff0000011111'
88 87
89 current_rev = TEST_DATA_VARS['chromium_revision'] 88 current_rev = TEST_DATA_VARS['chromium_revision']
90 UpdateDepsFile(self._webrtc_depsfile, current_rev, new_rev, []) 89 UpdateDepsFile(self._webrtc_depsfile, current_rev, new_rev, [])
91 with open(self._webrtc_depsfile) as deps_file: 90 with open(self._webrtc_depsfile) as deps_file:
92 deps_contents = deps_file.read() 91 deps_contents = deps_file.read()
93 self.assertTrue(new_rev in deps_contents, 92 self.assertTrue(new_rev in deps_contents,
94 'Failed to find %s in\n%s' % (new_rev, deps_contents)) 93 'Failed to find %s in\n%s' % (new_rev, deps_contents))
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 self.assertEquals(changed_deps[0].new_rev, BUILDTOOLS_NEW_REV) 144 self.assertEquals(changed_deps[0].new_rev, BUILDTOOLS_NEW_REV)
146 145
147 146
148 def _SetupGitLsRemoteCall(cmd_fake, url, revision): 147 def _SetupGitLsRemoteCall(cmd_fake, url, revision):
149 cmd = ['git', 'ls-remote', url, revision] 148 cmd = ['git', 'ls-remote', url, revision]
150 cmd_fake.add_expectation(cmd, _returns=(revision, None)) 149 cmd_fake.add_expectation(cmd, _returns=(revision, None))
151 150
152 151
153 if __name__ == '__main__': 152 if __name__ == '__main__':
154 unittest.main() 153 unittest.main()
OLDNEW
« no previous file with comments | « tools-webrtc/autoroller/roll_deps.py ('k') | tools-webrtc/autoroller/unittests/testdata/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698