def testResolveToRevision_InputGitHash(self): # The ResolveToRevision function returns a git commit hash corresponding # to the input, so if the input can't be parsed as an int, it is returned. self.assertEqual( 'abcd1234', source_control.ResolveToRevision('abcd1234', 'chromium', {}, 5)) # Note: It actually does this for any junk that isn't an int. This isn't # necessarily desired behavior. self.assertEqual( 'foo bar', source_control.ResolveToRevision('foo bar', 'chromium', {}, 5))
def testResolveToRevision_Found(self, mock_run_git): # In general, ResolveToRevision finds a git commit hash by repeatedly # calling "git log --grep ..." with different numbers until something # matches. mock_run_git.return_value = 'abcd1234' self.assertEqual( 'abcd1234', source_control.ResolveToRevision('12345', 'chromium', {}, 5)) self.assertEqual(1, mock_run_git.call_count)
def _AssertCompatibleCommand(self, expected_command, original_command, revision, target_platform): """Tests the modification of the command that might be done. This modification to the command is done in order to get a Telemetry command that works; before some revisions, the browser name that Telemetry expects is different in some cases, but we want it to work anyway. Specifically, only for android: After r276628, only android-chrome-shell works. Prior to r274857, only android-chromium-testshell works. In the range [274857, 276628], both work. """ bisect_options = bisect_perf_regression.BisectOptions() bisect_options.output_buildbot_annotations = None bisect_instance = bisect_perf_regression.BisectPerformanceMetrics( bisect_options, os.getcwd()) bisect_instance.opts.target_platform = target_platform git_revision = source_control.ResolveToRevision( revision, 'chromium', bisect_utils.DEPOT_DEPS_NAME, 100) depot = 'chromium' command = bisect_instance.GetCompatibleCommand(original_command, git_revision, depot) self.assertEqual(expected_command, command)
def testResolveToRevision_NotFound(self, mock_run_git): # If no corresponding git hash was found, then None is returned. mock_run_git.return_value = '' self.assertIsNone( source_control.ResolveToRevision('12345', 'chromium', {}, 5))