From 990ab1b42c1f347686a509aade4303289f779902 Mon Sep 17 00:00:00 2001 From: iannucci Date: Thu, 8 Sep 2016 10:56:07 -0700 Subject: [PATCH] Remove force parameter from bot_update.ensure_checkout. This is the simplest change I can make here. The bot_update.py script already ignores the value of force (and sets it to True in all cases). This is an expectations-only change. I'll refactor the content of the bot_update.py script to account for this removed option in a followup CL as well. R=agable@chromium.org, estaab@chromium.org, hinoka@chromium.org, martiniss@chromium.org BUG=643885 Review-Url: https://codereview.chromium.org/2316323002 --- recipe_modules/bot_update/api.py | 7 +- .../bot_update/example.expected/forced.json | 57 --------------- recipe_modules/bot_update/example.py | 8 --- recipe_modules/bot_update/test_api.py | 72 +++++++++---------- 4 files changed, 36 insertions(+), 108 deletions(-) delete mode 100644 recipe_modules/bot_update/example.expected/forced.json diff --git a/recipe_modules/bot_update/api.py b/recipe_modules/bot_update/api.py index 32117394d5..da65b670e3 100644 --- a/recipe_modules/bot_update/api.py +++ b/recipe_modules/bot_update/api.py @@ -67,7 +67,7 @@ class BotUpdateApi(recipe_api.RecipeApi): def ensure_checkout(self, gclient_config=None, suffix=None, patch=True, update_presentation=True, - force=False, patch_root=None, no_shallow=False, + patch_root=None, no_shallow=False, with_branch_heads=False, refs=None, patch_oauth2=False, use_site_config_creds=True, output_manifest=True, clobber=False, @@ -214,8 +214,6 @@ class BotUpdateApi(recipe_api.RecipeApi): if clobber: cmd.append('--clobber') - if force: - cmd.append('--force') if no_shallow: cmd.append('--no_shallow') if output_manifest: @@ -230,8 +228,7 @@ class BotUpdateApi(recipe_api.RecipeApi): # Inject Json output for testing. first_sln = cfg.solutions[0].name step_test_data = lambda: self.test_api.output_json( - master, builder, slave, root, first_sln, rev_map, force, - self._fail_patch, + master, builder, slave, root, first_sln, rev_map, self._fail_patch, output_manifest=output_manifest, fixed_revisions=fixed_revisions) # Add suffixes to the step name, if specified. diff --git a/recipe_modules/bot_update/example.expected/forced.json b/recipe_modules/bot_update/example.expected/forced.json deleted file mode 100644 index a360331a83..0000000000 --- a/recipe_modules/bot_update/example.expected/forced.json +++ /dev/null @@ -1,57 +0,0 @@ -[ - { - "cmd": [ - "python", - "-u", - "RECIPE_MODULE[depot_tools::bot_update]/resources/bot_update.py", - "--master", - "experimental", - "--builder", - "Experimental Builder", - "--slave", - "somehost", - "--spec", - "cache_dir = '[GIT_CACHE]'\nsolutions = [{'deps_file': '.DEPS.git', 'managed': True, 'name': 'src', 'url': 'https://chromium.googlesource.com/chromium/src.git'}]", - "--root", - "src", - "--revision_mapping_file", - "{\"src\": \"got_cr_revision\"}", - "--git-cache-dir", - "[GIT_CACHE]", - "--output_json", - "/path/to/tmp/json", - "--revision", - "src@HEAD", - "--force" - ], - "env": { - "PATH": "%(PATH)s:RECIPE_PACKAGE_REPO[depot_tools]" - }, - "name": "bot_update", - "~followup_annotations": [ - "@@@STEP_TEXT@Some step text@@@", - "@@@STEP_LOG_LINE@json.output@{@@@", - "@@@STEP_LOG_LINE@json.output@ \"did_run\": true, @@@", - "@@@STEP_LOG_LINE@json.output@ \"fixed_revisions\": {@@@", - "@@@STEP_LOG_LINE@json.output@ \"src\": \"HEAD\"@@@", - "@@@STEP_LOG_LINE@json.output@ }, @@@", - "@@@STEP_LOG_LINE@json.output@ \"patch_failure\": false, @@@", - "@@@STEP_LOG_LINE@json.output@ \"patch_root\": \"src\", @@@", - "@@@STEP_LOG_LINE@json.output@ \"properties\": {@@@", - "@@@STEP_LOG_LINE@json.output@ \"got_cr_revision\": \"f27fede2220bcd326aee3e86ddfd4ebd0fe58cb9\", @@@", - "@@@STEP_LOG_LINE@json.output@ \"got_cr_revision_cp\": \"refs/heads/master@{#170242}\"@@@", - "@@@STEP_LOG_LINE@json.output@ }, @@@", - "@@@STEP_LOG_LINE@json.output@ \"root\": \"src\", @@@", - "@@@STEP_LOG_LINE@json.output@ \"step_text\": \"Some step text\"@@@", - "@@@STEP_LOG_LINE@json.output@}@@@", - "@@@STEP_LOG_END@json.output@@@", - "@@@SET_BUILD_PROPERTY@got_cr_revision@\"f27fede2220bcd326aee3e86ddfd4ebd0fe58cb9\"@@@", - "@@@SET_BUILD_PROPERTY@got_cr_revision_cp@\"refs/heads/master@{#170242}\"@@@" - ] - }, - { - "name": "$result", - "recipe_result": null, - "status_code": 0 - } -] \ No newline at end of file diff --git a/recipe_modules/bot_update/example.py b/recipe_modules/bot_update/example.py index a369997c7b..8f0182d166 100644 --- a/recipe_modules/bot_update/example.py +++ b/recipe_modules/bot_update/example.py @@ -25,7 +25,6 @@ def RunSteps(api): 'HEAD') patch = api.properties.get('patch', True) clobber = True if api.properties.get('clobber') else False - force = True if api.properties.get('force') else False no_shallow = True if api.properties.get('no_shallow') else False output_manifest = api.properties.get('output_manifest', False) with_branch_heads = api.properties.get('with_branch_heads', False) @@ -44,7 +43,6 @@ def RunSteps(api): gerrit_no_rebase_patch_ref=gerrit_no_rebase_patch_ref) else: api.bot_update.ensure_checkout( - force=force, no_shallow=no_shallow, patch=patch, with_branch_heads=with_branch_heads, @@ -124,12 +122,6 @@ def GenTests(api): rietveld='https://rietveld.example.com/', fail_patch='download' ) + api.step_data('bot_update', retcode=87) - yield api.test('forced') + api.properties( - mastername='experimental', - buildername='Experimental Builder', - slavename='somehost', - force=1 - ) yield api.test('no_shallow') + api.properties( mastername='experimental', buildername='Experimental Builder', diff --git a/recipe_modules/bot_update/test_api.py b/recipe_modules/bot_update/test_api.py index afe524a631..eeeb49ba66 100644 --- a/recipe_modules/bot_update/test_api.py +++ b/recipe_modules/bot_update/test_api.py @@ -11,57 +11,53 @@ from recipe_engine import recipe_test_api class BotUpdateTestApi(recipe_test_api.RecipeTestApi): def output_json(self, master, builder, slave, root, first_sln, - revision_mapping, force=False, fail_patch=False, + revision_mapping, fail_patch=False, output_manifest=False, fixed_revisions=None): """Deterministically synthesize json.output test data for gclient's --output-json option. """ - active = True - output = { - 'did_run': active, + 'did_run': True, 'patch_failure': False } - # Add in extra json output if active. - if active: - properties = { - property_name: self.gen_revision(project_name) - for project_name, property_name in revision_mapping.iteritems() - } - properties.update({ - '%s_cp' % property_name: ('refs/heads/master@{#%s}' % - self.gen_commit_position(project_name)) - for project_name, property_name in revision_mapping.iteritems() - }) + properties = { + property_name: self.gen_revision(project_name) + for project_name, property_name in revision_mapping.iteritems() + } + properties.update({ + '%s_cp' % property_name: ('refs/heads/master@{#%s}' % + self.gen_commit_position(project_name)) + for project_name, property_name in revision_mapping.iteritems() + }) - output.update({ - 'patch_root': root or first_sln, - 'root': first_sln, - 'properties': properties, - 'step_text': 'Some step text' - }) + output.update({ + 'patch_root': root or first_sln, + 'root': first_sln, + 'properties': properties, + 'step_text': 'Some step text' + }) - if output_manifest: - output.update({ - 'manifest': { - project_name: { - 'repository': 'https://fake.org/%s.git' % project_name, - 'revision': self.gen_revision(project_name), - } - for project_name in revision_mapping + if output_manifest: + output.update({ + 'manifest': { + project_name: { + 'repository': 'https://fake.org/%s.git' % project_name, + 'revision': self.gen_revision(project_name), } - }) + for project_name in revision_mapping + } + }) - if fixed_revisions: - output['fixed_revisions'] = fixed_revisions + if fixed_revisions: + output['fixed_revisions'] = fixed_revisions - if fail_patch: - output['log_lines'] = [('patch error', 'Patch failed to apply'),] - output['patch_failure'] = True - output['patch_apply_return_code'] = 1 - if fail_patch == 'download': - output['patch_apply_return_code'] = 3 + if fail_patch: + output['log_lines'] = [('patch error', 'Patch failed to apply'),] + output['patch_failure'] = True + output['patch_apply_return_code'] = 1 + if fail_patch == 'download': + output['patch_apply_return_code'] = 3 return self.m.json.output(output) @staticmethod