def testCalculateChangedDeps(self): webrtc_deps = ParseLocalDepsFile(self._webrtc_depsfile) new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile) with mock.patch('roll_deps._RunCommand', self.fake): _SetupGitLsRemoteCall( self.fake, 'https://chromium.googlesource.com/chromium/src/build', BUILD_NEW_REV) changed_deps = CalculateChangedDeps(webrtc_deps, new_cr_deps) self.assertEquals(len(changed_deps), 3) self.assertEquals(changed_deps[0].path, 'src/build') self.assertEquals(changed_deps[0].current_rev, BUILD_OLD_REV) self.assertEquals(changed_deps[0].new_rev, BUILD_NEW_REV) self.assertEquals(changed_deps[1].path, 'src/buildtools/linux64') self.assertEquals(changed_deps[1].package, 'gn/gn/linux-amd64') self.assertEquals( changed_deps[1].current_version, 'git_revision:69ec4fca1fa69ddadae13f9e6b7507efa0675263') self.assertEquals(changed_deps[1].new_version, 'git_revision:new-revision') self.assertEquals(changed_deps[2].path, 'src/third_party/depot_tools') self.assertEquals(changed_deps[2].current_rev, DEPOTTOOLS_OLD_REV) self.assertEquals(changed_deps[2].new_rev, DEPOTTOOLS_NEW_REV)
def testExpectedDepsIsNotReportedMissing(self): """Some deps musn't be seen as missing, even if absent from Chromium.""" webrtc_deps = ParseLocalDepsFile(self._webrtc_depsfile) new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile_android) removed_android_paths, other_paths = FindRemovedDeps( webrtc_deps, new_cr_deps) self.assertTrue('src/build' not in removed_android_paths) self.assertTrue('src/build' not in other_paths)
def testFindAddedDeps(self): webrtc_deps = ParseLocalDepsFile(self._webrtc_depsfile_android) new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile_android) added_android_paths, other_paths = FindAddedDeps(webrtc_deps, new_cr_deps) self.assertEqual( added_android_paths, ['src/third_party/android_deps/libs/android_arch_lifecycle_common']) self.assertEqual(other_paths, [])
def testFindRemovedDeps(self): webrtc_deps = ParseLocalDepsFile(self._webrtc_depsfile_android) new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile_android) removed_android_paths, other_paths = FindRemovedDeps( webrtc_deps, new_cr_deps) self.assertEquals(removed_android_paths, [ 'src/third_party/android_deps/libs/android_arch_lifecycle_runtime' ]) self.assertEquals(other_paths, [])
def testMissingDepsIsDetected(self): """Check an error is reported when deps cannot be automatically removed.""" # The situation at test is the following: # * A WebRTC DEPS entry is missing from Chromium. # * The dependency isn't an android_deps (those are supported). webrtc_deps = ParseLocalDepsFile(self._webrtc_depsfile) new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile_android) _, other_paths = FindRemovedDeps(webrtc_deps, new_cr_deps) self.assertEquals(other_paths, ['src/third_party/xstream', 'src/buildtools'])
def testWithDistinctDeps(self): """Check CalculateChangedDeps still works when deps are added/removed. """ webrtc_deps = ParseLocalDepsFile(self._webrtc_depsfile_android) new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile_android) changed_deps = CalculateChangedDeps(webrtc_deps, new_cr_deps) self.assertEquals(len(changed_deps), 1) self.assertEquals( changed_deps[0].path, 'src/third_party/android_deps/libs/android_arch_core_common') self.assertEquals( changed_deps[0].package, 'chromium/third_party/android_deps/libs/android_arch_core_common') self.assertEquals(changed_deps[0].current_version, 'version:0.9.0') self.assertEquals(changed_deps[0].new_version, 'version:1.0.0-cr0')
def testCalculateChangedDeps(self): _SetupGitLsRemoteCall(self.fake, 'https://chromium.googlesource.com/chromium/src/build', BUILD_NEW_REV) webrtc_deps = ParseLocalDepsFile(self._webrtc_depsfile) new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile) changed_deps = CalculateChangedDeps(webrtc_deps, new_cr_deps) self.assertEquals(len(changed_deps), 2) self.assertEquals(changed_deps[0].path, 'src/build') self.assertEquals(changed_deps[0].current_rev, BUILD_OLD_REV) self.assertEquals(changed_deps[0].new_rev, BUILD_NEW_REV) self.assertEquals(changed_deps[1].path, 'src/buildtools') self.assertEquals(changed_deps[1].current_rev, BUILDTOOLS_OLD_REV) self.assertEquals(changed_deps[1].new_rev, BUILDTOOLS_NEW_REV)
def _CommitMessageSetup(self): webrtc_deps = ParseLocalDepsFile(self._webrtc_depsfile_android) new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile_android) changed_deps = CalculateChangedDeps(webrtc_deps, new_cr_deps) added_paths, _ = FindAddedDeps(webrtc_deps, new_cr_deps) removed_paths, _ = FindRemovedDeps(webrtc_deps, new_cr_deps) current_commit_pos = 'cafe' new_commit_pos = 'f00d' commit_msg = GenerateCommitMessage(NO_CHROMIUM_REVISION_UPDATE, current_commit_pos, new_commit_pos, changed_deps, added_paths, removed_paths) return [l.strip() for l in commit_msg.split('\n')]
def testCalculateChangedDeps(self): _SetupGitLsRemoteCall(self.fake, 'https://chromium.googlesource.com/chromium/src/build', BUILD_NEW_REV) webrtc_deps = ParseLocalDepsFile(self._webrtc_depsfile) new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile) changed_deps = CalculateChangedDeps(webrtc_deps, new_cr_deps) self.assertEquals(len(changed_deps), 3) self.assertEquals(changed_deps[0].path, 'src/build') self.assertEquals(changed_deps[0].current_rev, BUILD_OLD_REV) self.assertEquals(changed_deps[0].new_rev, BUILD_NEW_REV) self.assertEquals(changed_deps[1].path, 'src/buildtools') self.assertEquals(changed_deps[1].current_rev, BUILDTOOLS_OLD_REV) self.assertEquals(changed_deps[1].new_rev, BUILDTOOLS_NEW_REV) self.assertEquals(changed_deps[2].path, 'src/third_party/xstream') self.assertEquals(changed_deps[2].package, 'chromium/third_party/xstream') self.assertEquals(changed_deps[2].current_version, '1.4.8-cr0') self.assertEquals(changed_deps[2].new_version, '1.10.0-cr0')
def _CommitMessageSetup(self): webrtc_deps = ParseLocalDepsFile(self._webrtc_depsfile_android) new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile_android) changed_deps = CalculateChangedDeps(webrtc_deps, new_cr_deps) added_paths, _ = FindAddedDeps(webrtc_deps, new_cr_deps) removed_paths, _ = FindRemovedDeps(webrtc_deps, new_cr_deps) current_commit_pos = 'cafe' new_commit_pos = 'f00d' with mock.patch('roll_deps._RunCommand', self.fake): # We don't really care, but it's needed to construct the message. self.fake.AddExpectation(['git', 'config', 'user.email'], _returns=('*****@*****.**', None), _ignores=['working_dir']) commit_msg = GenerateCommitMessage(NO_CHROMIUM_REVISION_UPDATE, current_commit_pos, new_commit_pos, changed_deps, added_paths, removed_paths) return [l.strip() for l in commit_msg.split('\n')]