OLD | NEW |
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 os | 10 import os |
11 import shutil | 11 import shutil |
12 import sys | 12 import sys |
13 import tempfile | 13 import tempfile |
14 import unittest | 14 import unittest |
15 | 15 |
16 | 16 |
17 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 17 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
18 PARENT_DIR = os.path.join(SCRIPT_DIR, os.pardir) | 18 PARENT_DIR = os.path.join(SCRIPT_DIR, os.pardir) |
19 sys.path.append(PARENT_DIR) | 19 sys.path.append(PARENT_DIR) |
20 from roll_chromium_revision import ParseDepsDict, UpdateDeps, \ | 20 from roll_chromium_revision import ParseDepsDict, UpdateDeps, \ |
21 GetMatchingDepsEntries | 21 GetMatchingDepsEntries |
22 | 22 |
23 TEST_DATA_VARS = { | 23 TEST_DATA_VARS = { |
24 'extra_gyp_flag': '-Dextra_gyp_flag=0', | |
25 'chromium_git': 'https://chromium.googlesource.com', | 24 'chromium_git': 'https://chromium.googlesource.com', |
26 'chromium_revision': '1b9c098a08e40114e44b6c1ec33ddf95c40b901d', | 25 'chromium_revision': '1b9c098a08e40114e44b6c1ec33ddf95c40b901d', |
27 } | 26 } |
28 | 27 |
29 DEPS_ENTRIES = { | 28 DEPS_ENTRIES = { |
30 'src/build': 'https://build.com', | 29 'src/build': 'https://build.com', |
31 'src/buildtools': 'https://buildtools.com', | 30 'src/buildtools': 'https://buildtools.com', |
32 'src/testing/gtest': 'https://gtest.com', | 31 'src/testing/gtest': 'https://gtest.com', |
33 'src/testing/gmock': 'https://gmock.com', | 32 'src/testing/gmock': 'https://gmock.com', |
34 } | 33 } |
(...skipping 19 matching lines...) Expand all Loading... |
54 'Failed to find %s in\n%s' % (new_rev, deps_contents)) | 53 'Failed to find %s in\n%s' % (new_rev, deps_contents)) |
55 | 54 |
56 def testParseDepsDict(self): | 55 def testParseDepsDict(self): |
57 with open(self._deps_filename) as deps_file: | 56 with open(self._deps_filename) as deps_file: |
58 deps_contents = deps_file.read() | 57 deps_contents = deps_file.read() |
59 local_scope = ParseDepsDict(deps_contents) | 58 local_scope = ParseDepsDict(deps_contents) |
60 vars_dict = local_scope['vars'] | 59 vars_dict = local_scope['vars'] |
61 | 60 |
62 def assertVar(variable_name): | 61 def assertVar(variable_name): |
63 self.assertEquals(vars_dict[variable_name], TEST_DATA_VARS[variable_name]) | 62 self.assertEquals(vars_dict[variable_name], TEST_DATA_VARS[variable_name]) |
64 assertVar('extra_gyp_flag') | |
65 assertVar('chromium_git') | 63 assertVar('chromium_git') |
66 assertVar('chromium_revision') | 64 assertVar('chromium_revision') |
67 | 65 |
68 def testGetMatchingDepsEntriesReturnsPathInSimpleCase(self): | 66 def testGetMatchingDepsEntriesReturnsPathInSimpleCase(self): |
69 entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing/gtest') | 67 entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing/gtest') |
70 self.assertEquals(len(entries), 1) | 68 self.assertEquals(len(entries), 1) |
71 self.assertEquals(entries[0], DEPS_ENTRIES['src/testing/gtest']) | 69 self.assertEquals(entries[0], DEPS_ENTRIES['src/testing/gtest']) |
72 | 70 |
73 def testGetMatchingDepsEntriesHandlesSimilarStartingPaths(self): | 71 def testGetMatchingDepsEntriesHandlesSimilarStartingPaths(self): |
74 entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing') | 72 entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing') |
75 self.assertEquals(len(entries), 2) | 73 self.assertEquals(len(entries), 2) |
76 | 74 |
77 def testGetMatchingDepsEntriesHandlesTwoPathsWithIdenticalFirstParts(self): | 75 def testGetMatchingDepsEntriesHandlesTwoPathsWithIdenticalFirstParts(self): |
78 entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/build') | 76 entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/build') |
79 self.assertEquals(len(entries), 1) | 77 self.assertEquals(len(entries), 1) |
80 self.assertEquals(entries[0], DEPS_ENTRIES['src/build']) | 78 self.assertEquals(entries[0], DEPS_ENTRIES['src/build']) |
81 | 79 |
82 if __name__ == '__main__': | 80 if __name__ == '__main__': |
83 unittest.main() | 81 unittest.main() |
OLD | NEW |