From: machenbach@chromium.org Date: Tue, 23 Sep 2014 14:41:36 +0000 (+0000) Subject: Refactoring: Remove global configs in release scripts. X-Git-Tag: upstream/4.7.83~6751 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=98e9e050920a30f487503073cedafbc55ac94d02;p=platform%2Fupstream%2Fv8.git Refactoring: Remove global configs in release scripts. TBR=tandrii@chromium.org TEST=script_test.py Review URL: https://codereview.chromium.org/594773003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24154 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/tools/push-to-trunk/auto_push.py b/tools/push-to-trunk/auto_push.py index 5a061f6..fef3b53 100755 --- a/tools/push-to-trunk/auto_push.py +++ b/tools/push-to-trunk/auto_push.py @@ -36,16 +36,8 @@ import urllib from common_includes import * import push_to_trunk -SETTINGS_LOCATION = "SETTINGS_LOCATION" - -CONFIG = { - PERSISTFILE_BASENAME: "/tmp/v8-auto-push-tempfile", - SETTINGS_LOCATION: "~/.auto-roll", -} - PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") - class Preparation(Step): MESSAGE = "Preparation." @@ -58,7 +50,7 @@ class CheckAutoPushSettings(Step): MESSAGE = "Checking settings file." def RunStep(self): - settings_file = os.path.realpath(self.Config(SETTINGS_LOCATION)) + settings_file = os.path.realpath(self.Config("SETTINGS_LOCATION")) if os.path.exists(settings_file): settings_dict = json.loads(FileToText(settings_file)) if settings_dict.get("enable_auto_roll") is False: @@ -118,9 +110,8 @@ class PushToTrunk(Step): # TODO(machenbach): Update the script before calling it. if self._options.push: - P = push_to_trunk.PushToTrunk self._side_effect_handler.Call( - P(push_to_trunk.CONFIG, self._side_effect_handler).Run, + push_to_trunk.PushToTrunk().Run, ["--author", self._options.author, "--reviewer", self._options.reviewer, "--revision", self["lkgr"], @@ -140,6 +131,12 @@ class AutoPush(ScriptsBase): options.requires_editor = False return True + def _Config(self): + return { + "PERSISTFILE_BASENAME": "/tmp/v8-auto-push-tempfile", + "SETTINGS_LOCATION": "~/.auto-roll", + } + def _Steps(self): return [ Preparation, @@ -152,4 +149,4 @@ class AutoPush(ScriptsBase): if __name__ == "__main__": # pragma: no cover - sys.exit(AutoPush(CONFIG).Run()) + sys.exit(AutoPush().Run()) diff --git a/tools/push-to-trunk/auto_roll.py b/tools/push-to-trunk/auto_roll.py index a40c356..120e633 100755 --- a/tools/push-to-trunk/auto_roll.py +++ b/tools/push-to-trunk/auto_roll.py @@ -12,13 +12,6 @@ import urllib from common_includes import * import chromium_roll -CLUSTERFUZZ_API_KEY_FILE = "CLUSTERFUZZ_API_KEY_FILE" - -CONFIG = { - PERSISTFILE_BASENAME: "/tmp/v8-auto-roll-tempfile", - CLUSTERFUZZ_API_KEY_FILE: ".cf_api_key", -} - class CheckActiveRoll(Step): MESSAGE = "Check active roll." @@ -76,10 +69,10 @@ class CheckClusterFuzz(Step): MESSAGE = "Check ClusterFuzz api for new problems." def RunStep(self): - if not os.path.exists(self.Config(CLUSTERFUZZ_API_KEY_FILE)): + if not os.path.exists(self.Config("CLUSTERFUZZ_API_KEY_FILE")): print "Skipping ClusterFuzz check. No api key file found." return False - api_key = FileToText(self.Config(CLUSTERFUZZ_API_KEY_FILE)) + api_key = FileToText(self.Config("CLUSTERFUZZ_API_KEY_FILE")) # Check for open, reproducible issues that have no associated bug. result = self._side_effect_handler.ReadClusterFuzzAPI( api_key, job_type="linux_asan_d8_dbg", reproducible="True", @@ -106,10 +99,7 @@ class RollChromium(Step): "--sheriff", "--googlers-mapping", self._options.googlers_mapping]) if self._options.dry_run: args.extend(["--dry-run"]) - R = chromium_roll.ChromiumRoll - self._side_effect_handler.Call( - R(chromium_roll.CONFIG, self._side_effect_handler).Run, - args) + self._side_effect_handler.Call(chromium_roll.ChromiumRoll().Run, args) class AutoRoll(ScriptsBase): @@ -129,6 +119,12 @@ class AutoRoll(ScriptsBase): return False return True + def _Config(self): + return { + "PERSISTFILE_BASENAME": "/tmp/v8-auto-roll-tempfile", + "CLUSTERFUZZ_API_KEY_FILE": ".cf_api_key", + } + def _Steps(self): return [ CheckActiveRoll, @@ -140,4 +136,4 @@ class AutoRoll(ScriptsBase): if __name__ == "__main__": # pragma: no cover - sys.exit(AutoRoll(CONFIG).Run()) + sys.exit(AutoRoll().Run()) diff --git a/tools/push-to-trunk/auto_tag.py b/tools/push-to-trunk/auto_tag.py index 0800896..175e10e 100755 --- a/tools/push-to-trunk/auto_tag.py +++ b/tools/push-to-trunk/auto_tag.py @@ -8,11 +8,6 @@ import sys from common_includes import * -CONFIG = { - BRANCHNAME: "auto-tag-v8", - PERSISTFILE_BASENAME: "/tmp/v8-auto-tag-tempfile", -} - class Preparation(Step): MESSAGE = "Preparation." @@ -28,7 +23,7 @@ class GetTags(Step): MESSAGE = "Get all V8 tags." def RunStep(self): - self.GitCreateBranch(self._config[BRANCHNAME]) + self.GitCreateBranch(self._config["BRANCHNAME"]) # Get remote tags. tags = filter(lambda s: re.match(r"^svn/tags/[\d+\.]+$", s), @@ -182,6 +177,12 @@ class AutoTag(ScriptsBase): options.force_upload = True return True + def _Config(self): + return { + "BRANCHNAME": "auto-tag-v8", + "PERSISTFILE_BASENAME": "/tmp/v8-auto-tag-tempfile", + } + def _Steps(self): return [ Preparation, @@ -195,4 +196,4 @@ class AutoTag(ScriptsBase): if __name__ == "__main__": # pragma: no cover - sys.exit(AutoTag(CONFIG).Run()) + sys.exit(AutoTag().Run()) diff --git a/tools/push-to-trunk/bump_up_version.py b/tools/push-to-trunk/bump_up_version.py index 2e5d08f..c9f052b 100755 --- a/tools/push-to-trunk/bump_up_version.py +++ b/tools/push-to-trunk/bump_up_version.py @@ -25,11 +25,6 @@ import sys from common_includes import * -CONFIG = { - PERSISTFILE_BASENAME: "/tmp/v8-bump-up-version-tempfile", - PATCH_FILE: "/tmp/v8-bump-up-version-tempfile-patch-file", -} - VERSION_BRANCH = "auto-bump-up-version" @@ -227,6 +222,11 @@ class BumpUpVersion(ScriptsBase): options.force_upload = True return True + def _Config(self): + return { + "PERSISTFILE_BASENAME": "/tmp/v8-bump-up-version-tempfile", + } + def _Steps(self): return [ Preparation, @@ -242,4 +242,4 @@ class BumpUpVersion(ScriptsBase): ] if __name__ == "__main__": # pragma: no cover - sys.exit(BumpUpVersion(CONFIG).Run()) + sys.exit(BumpUpVersion().Run()) diff --git a/tools/push-to-trunk/chromium_roll.py b/tools/push-to-trunk/chromium_roll.py index 35603a2..dc5e6eb 100755 --- a/tools/push-to-trunk/chromium_roll.py +++ b/tools/push-to-trunk/chromium_roll.py @@ -9,12 +9,6 @@ import sys from common_includes import * -CHROMIUM = "CHROMIUM" - -CONFIG = { - PERSISTFILE_BASENAME: "/tmp/v8-chromium-roll-tempfile", -} - class Preparation(Step): MESSAGE = "Preparation." @@ -116,7 +110,7 @@ class CleanUp(Step): % self["trunk_revision"]) # Clean up all temporary files. - Command("rm", "-f %s*" % self._config[PERSISTFILE_BASENAME]) + Command("rm", "-f %s*" % self._config["PERSISTFILE_BASENAME"]) class ChromiumRoll(ScriptsBase): @@ -140,6 +134,11 @@ class ChromiumRoll(ScriptsBase): options.manual = False return True + def _Config(self): + return { + "PERSISTFILE_BASENAME": "/tmp/v8-chromium-roll-tempfile", + } + def _Steps(self): return [ Preparation, @@ -154,4 +153,4 @@ class ChromiumRoll(ScriptsBase): if __name__ == "__main__": # pragma: no cover - sys.exit(ChromiumRoll(CONFIG).Run()) + sys.exit(ChromiumRoll().Run()) diff --git a/tools/push-to-trunk/common_includes.py b/tools/push-to-trunk/common_includes.py index 83e0156..00fb097 100644 --- a/tools/push-to-trunk/common_includes.py +++ b/tools/push-to-trunk/common_includes.py @@ -45,13 +45,6 @@ import urllib2 from git_recipes import GitRecipesMixin from git_recipes import GitFailedException -PERSISTFILE_BASENAME = "PERSISTFILE_BASENAME" -BRANCHNAME = "BRANCHNAME" -CHANGELOG_FILE = "CHANGELOG_FILE" -CHANGELOG_ENTRY_FILE = "CHANGELOG_ENTRY_FILE" -COMMITMSG_FILE = "COMMITMSG_FILE" -PATCH_FILE = "PATCH_FILE" - VERSION_FILE = os.path.join("src", "version.cc") # V8 base directory. @@ -294,7 +287,7 @@ class Step(GitRecipesMixin): def Run(self): # Restore state. - state_file = "%s-state.json" % self._config[PERSISTFILE_BASENAME] + state_file = "%s-state.json" % self._config["PERSISTFILE_BASENAME"] if not self._state and os.path.exists(state_file): self._state.update(json.loads(FileToText(state_file))) @@ -433,15 +426,15 @@ class Step(GitRecipesMixin): def PrepareBranch(self): # Delete the branch that will be created later if it exists already. - self.DeleteBranch(self._config[BRANCHNAME]) + self.DeleteBranch(self._config["BRANCHNAME"]) def CommonCleanup(self): self.GitCheckout(self["current_branch"]) - if self._config[BRANCHNAME] != self["current_branch"]: - self.GitDeleteBranch(self._config[BRANCHNAME]) + if self._config["BRANCHNAME"] != self["current_branch"]: + self.GitDeleteBranch(self._config["BRANCHNAME"]) # Clean up all temporary files. - for f in glob.iglob("%s*" % self._config[PERSISTFILE_BASENAME]): + for f in glob.iglob("%s*" % self._config["PERSISTFILE_BASENAME"]): if os.path.isfile(f): os.remove(f) if os.path.isdir(f): @@ -526,12 +519,12 @@ class Step(GitRecipesMixin): def SVNCommit(self, root, commit_message): patch = self.GitDiff("HEAD^", "HEAD") - TextToFile(patch, self._config[PATCH_FILE]) + TextToFile(patch, self._config["PATCH_FILE"]) self.Command("svn", "update", cwd=self._options.svn) if self.Command("svn", "status", cwd=self._options.svn) != "": self.Die("SVN checkout not clean.") if not self.Command("patch", "-d %s -p1 -i %s" % - (root, self._config[PATCH_FILE]), + (root, self._config["PATCH_FILE"]), cwd=self._options.svn): self.Die("Could not apply patch.") self.Command( @@ -608,9 +601,11 @@ def MakeStep(step_class=Step, number=0, state=None, config=None, class ScriptsBase(object): # TODO(machenbach): Move static config here. - def __init__(self, config, side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER, + def __init__(self, + config=None, + side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER, state=None): - self._config = config + self._config = config or self._Config() self._side_effect_handler = side_effect_handler self._state = state if state is not None else {} @@ -626,6 +621,9 @@ class ScriptsBase(object): def _Steps(self): # pragma: no cover raise Exception("Not implemented.") + def _Config(self): + return {} + def MakeOptions(self, args=None): parser = argparse.ArgumentParser(description=self._Description()) parser.add_argument("-a", "--author", default="", @@ -691,7 +689,7 @@ class ScriptsBase(object): if not options: return 1 - state_file = "%s-state.json" % self._config[PERSISTFILE_BASENAME] + state_file = "%s-state.json" % self._config["PERSISTFILE_BASENAME"] if options.step == 0 and os.path.exists(state_file): os.remove(state_file) diff --git a/tools/push-to-trunk/merge_to_branch.py b/tools/push-to-trunk/merge_to_branch.py index c5cabf0..3fd3450 100755 --- a/tools/push-to-trunk/merge_to_branch.py +++ b/tools/push-to-trunk/merge_to_branch.py @@ -32,31 +32,16 @@ import sys from common_includes import * -ALREADY_MERGING_SENTINEL_FILE = "ALREADY_MERGING_SENTINEL_FILE" -COMMIT_HASHES_FILE = "COMMIT_HASHES_FILE" -TEMPORARY_PATCH_FILE = "TEMPORARY_PATCH_FILE" - -CONFIG = { - BRANCHNAME: "prepare-merge", - PERSISTFILE_BASENAME: "/tmp/v8-merge-to-branch-tempfile", - ALREADY_MERGING_SENTINEL_FILE: - "/tmp/v8-merge-to-branch-tempfile-already-merging", - TEMPORARY_PATCH_FILE: "/tmp/v8-prepare-merge-tempfile-temporary-patch", - COMMITMSG_FILE: "/tmp/v8-prepare-merge-tempfile-commitmsg", - COMMIT_HASHES_FILE: "/tmp/v8-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", -} - - class Preparation(Step): MESSAGE = "Preparation." def RunStep(self): - if os.path.exists(self.Config(ALREADY_MERGING_SENTINEL_FILE)): + if os.path.exists(self.Config("ALREADY_MERGING_SENTINEL_FILE")): if self._options.force: - os.remove(self.Config(ALREADY_MERGING_SENTINEL_FILE)) + os.remove(self.Config("ALREADY_MERGING_SENTINEL_FILE")) elif self._options.step == 0: # pragma: no cover self.Die("A merge is already in progress") - open(self.Config(ALREADY_MERGING_SENTINEL_FILE), "a").close() + open(self.Config("ALREADY_MERGING_SENTINEL_FILE"), "a").close() self.InitialEnvironmentChecks(self.default_cwd) if self._options.revert_bleeding_edge: @@ -74,7 +59,7 @@ class CreateBranch(Step): MESSAGE = "Create a fresh branch for the patch." def RunStep(self): - self.GitCreateBranch(self.Config(BRANCHNAME), + self.GitCreateBranch(self.Config("BRANCHNAME"), "svn/%s" % self["merge_to_branch"]) @@ -157,8 +142,8 @@ class ApplyPatches(Step): print("Applying patch for %s to %s..." % (commit_hash, self["merge_to_branch"])) patch = self.GitGetPatch(commit_hash) - TextToFile(patch, self.Config(TEMPORARY_PATCH_FILE)) - self.ApplyPatch(self.Config(TEMPORARY_PATCH_FILE), self._options.revert) + TextToFile(patch, self.Config("TEMPORARY_PATCH_FILE")) + self.ApplyPatch(self.Config("TEMPORARY_PATCH_FILE"), self._options.revert) if self._options.patch: self.ApplyPatch(self._options.patch, self._options.revert) @@ -213,15 +198,15 @@ class CommitLocal(Step): title = ("Version %s (merged %s)" % (self["version"], self["revision_list"])) self["new_commit_msg"] = "%s\n\n%s" % (title, self["new_commit_msg"]) - TextToFile(self["new_commit_msg"], self.Config(COMMITMSG_FILE)) - self.GitCommit(file_name=self.Config(COMMITMSG_FILE)) + TextToFile(self["new_commit_msg"], self.Config("COMMITMSG_FILE")) + self.GitCommit(file_name=self.Config("COMMITMSG_FILE")) class CommitRepository(Step): MESSAGE = "Commit to the repository." def RunStep(self): - self.GitCheckout(self.Config(BRANCHNAME)) + self.GitCheckout(self.Config("BRANCHNAME")) self.WaitForLGTM() self.GitPresubmit() self.GitDCommit() @@ -310,6 +295,16 @@ class MergeToBranch(ScriptsBase): options.bypass_upload_hooks = True return True + def _Config(self): + return { + "BRANCHNAME": "prepare-merge", + "PERSISTFILE_BASENAME": "/tmp/v8-merge-to-branch-tempfile", + "ALREADY_MERGING_SENTINEL_FILE": + "/tmp/v8-merge-to-branch-tempfile-already-merging", + "TEMPORARY_PATCH_FILE": "/tmp/v8-prepare-merge-tempfile-temporary-patch", + "COMMITMSG_FILE": "/tmp/v8-prepare-merge-tempfile-commitmsg", + } + def _Steps(self): return [ Preparation, @@ -329,4 +324,4 @@ class MergeToBranch(ScriptsBase): if __name__ == "__main__": # pragma: no cover - sys.exit(MergeToBranch(CONFIG).Run()) + sys.exit(MergeToBranch().Run()) diff --git a/tools/push-to-trunk/push_to_trunk.py b/tools/push-to-trunk/push_to_trunk.py index 4336880..8a9629e 100755 --- a/tools/push-to-trunk/push_to_trunk.py +++ b/tools/push-to-trunk/push_to_trunk.py @@ -34,18 +34,6 @@ import urllib2 from common_includes import * -TRUNKBRANCH = "TRUNKBRANCH" - -CONFIG = { - BRANCHNAME: "prepare-push", - TRUNKBRANCH: "trunk-push", - PERSISTFILE_BASENAME: "/tmp/v8-push-to-trunk-tempfile", - CHANGELOG_FILE: "ChangeLog", - CHANGELOG_ENTRY_FILE: "/tmp/v8-push-to-trunk-tempfile-changelog-entry", - PATCH_FILE: "/tmp/v8-push-to-trunk-tempfile-patch-file", - COMMITMSG_FILE: "/tmp/v8-push-to-trunk-tempfile-commitmsg", -} - PUSH_MESSAGE_SUFFIX = " (based on bleeding_edge revision r%d)" PUSH_MESSAGE_RE = re.compile(r".* \(based on bleeding_edge revision r(\d+)\)$") @@ -56,19 +44,19 @@ class Preparation(Step): self.InitialEnvironmentChecks(self.default_cwd) self.CommonPrepare() - if(self["current_branch"] == self.Config(TRUNKBRANCH) - or self["current_branch"] == self.Config(BRANCHNAME)): + if(self["current_branch"] == self.Config("TRUNKBRANCH") + or self["current_branch"] == self.Config("BRANCHNAME")): print "Warning: Script started on branch %s" % self["current_branch"] self.PrepareBranch() - self.DeleteBranch(self.Config(TRUNKBRANCH)) + self.DeleteBranch(self.Config("TRUNKBRANCH")) class FreshBranch(Step): MESSAGE = "Create a fresh branch." def RunStep(self): - self.GitCreateBranch(self.Config(BRANCHNAME), "svn/bleeding_edge") + self.GitCreateBranch(self.Config("BRANCHNAME"), "svn/bleeding_edge") class PreparePushRevision(Step): @@ -204,7 +192,7 @@ class PrepareChangeLog(Step): def RunStep(self): self["date"] = self.GetDate() output = "%s: Version %s\n\n" % (self["date"], self["version"]) - TextToFile(output, self.Config(CHANGELOG_ENTRY_FILE)) + TextToFile(output, self.Config("CHANGELOG_ENTRY_FILE")) commits = self.GitLog(format="%H", git_hash="%s..%s" % (self["last_push_bleeding_edge"], self["push_hash"])) @@ -220,17 +208,17 @@ class PrepareChangeLog(Step): # Auto-format commit messages. body = MakeChangeLogBody(commit_messages, auto_format=True) - AppendToFile(body, self.Config(CHANGELOG_ENTRY_FILE)) + AppendToFile(body, self.Config("CHANGELOG_ENTRY_FILE")) msg = (" Performance and stability improvements on all platforms." "\n#\n# The change log above is auto-generated. Please review if " "all relevant\n# commit messages from the list below are included." "\n# All lines starting with # will be stripped.\n#\n") - AppendToFile(msg, self.Config(CHANGELOG_ENTRY_FILE)) + AppendToFile(msg, self.Config("CHANGELOG_ENTRY_FILE")) # Include unformatted commit messages as a reference in a comment. comment_body = MakeComment(MakeChangeLogBody(commit_messages)) - AppendToFile(comment_body, self.Config(CHANGELOG_ENTRY_FILE)) + AppendToFile(comment_body, self.Config("CHANGELOG_ENTRY_FILE")) class EditChangeLog(Step): @@ -241,10 +229,10 @@ class EditChangeLog(Step): "entry, then edit its contents to your liking. When you're done, " "save the file and exit your EDITOR. ") self.ReadLine(default="") - self.Editor(self.Config(CHANGELOG_ENTRY_FILE)) + self.Editor(self.Config("CHANGELOG_ENTRY_FILE")) # Strip comments and reformat with correct indentation. - changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)).rstrip() + changelog_entry = FileToText(self.Config("CHANGELOG_ENTRY_FILE")).rstrip() changelog_entry = StripComments(changelog_entry) changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines())) changelog_entry = changelog_entry.lstrip() @@ -253,7 +241,7 @@ class EditChangeLog(Step): self.Die("Empty ChangeLog entry.") # Safe new change log for adding it later to the trunk patch. - TextToFile(changelog_entry, self.Config(CHANGELOG_ENTRY_FILE)) + TextToFile(changelog_entry, self.Config("CHANGELOG_ENTRY_FILE")) class StragglerCommits(Step): @@ -272,10 +260,10 @@ class SquashCommits(Step): # Instead of relying on "git rebase -i", we'll just create a diff, because # that's easier to automate. TextToFile(self.GitDiff("svn/trunk", self["push_hash"]), - self.Config(PATCH_FILE)) + self.Config("PATCH_FILE")) # Convert the ChangeLog entry to commit message format. - text = FileToText(self.Config(CHANGELOG_ENTRY_FILE)) + text = FileToText(self.Config("CHANGELOG_ENTRY_FILE")) # Remove date and trailing white space. text = re.sub(r"^%s: " % self["date"], "", text.rstrip()) @@ -295,22 +283,22 @@ class SquashCommits(Step): if not text: # pragma: no cover self.Die("Commit message editing failed.") - TextToFile(text, self.Config(COMMITMSG_FILE)) + TextToFile(text, self.Config("COMMITMSG_FILE")) class NewBranch(Step): MESSAGE = "Create a new branch from trunk." def RunStep(self): - self.GitCreateBranch(self.Config(TRUNKBRANCH), "svn/trunk") + self.GitCreateBranch(self.Config("TRUNKBRANCH"), "svn/trunk") class ApplyChanges(Step): MESSAGE = "Apply squashed changes." def RunStep(self): - self.ApplyPatch(self.Config(PATCH_FILE)) - os.remove(self.Config(PATCH_FILE)) + self.ApplyPatch(self.Config("PATCH_FILE")) + os.remove(self.Config("PATCH_FILE")) class AddChangeLog(Step): @@ -320,12 +308,12 @@ class AddChangeLog(Step): # The change log has been modified by the patch. Reset it to the version # on trunk and apply the exact changes determined by this PrepareChangeLog # step above. - self.GitCheckoutFile(self.Config(CHANGELOG_FILE), "svn/trunk") - changelog_entry = FileToText(self.Config(CHANGELOG_ENTRY_FILE)) - old_change_log = FileToText(self.Config(CHANGELOG_FILE)) + self.GitCheckoutFile(self.Config("CHANGELOG_FILE"), "svn/trunk") + changelog_entry = FileToText(self.Config("CHANGELOG_ENTRY_FILE")) + old_change_log = FileToText(self.Config("CHANGELOG_FILE")) new_change_log = "%s\n\n\n%s" % (changelog_entry, old_change_log) - TextToFile(new_change_log, self.Config(CHANGELOG_FILE)) - os.remove(self.Config(CHANGELOG_ENTRY_FILE)) + TextToFile(new_change_log, self.Config("CHANGELOG_FILE")) + os.remove(self.Config("CHANGELOG_ENTRY_FILE")) class SetVersion(Step): @@ -342,8 +330,8 @@ class CommitTrunk(Step): MESSAGE = "Commit to local trunk branch." def RunStep(self): - self.GitCommit(file_name = self.Config(COMMITMSG_FILE)) - os.remove(self.Config(COMMITMSG_FILE)) + self.GitCommit(file_name = self.Config("COMMITMSG_FILE")) + os.remove(self.Config("COMMITMSG_FILE")) class SanityCheck(Step): @@ -400,8 +388,8 @@ class CleanUp(Step): print "%s\ttrunk\t%s" % (self["version"], self["trunk_revision"]) self.CommonCleanup() - if self.Config(TRUNKBRANCH) != self["current_branch"]: - self.GitDeleteBranch(self.Config(TRUNKBRANCH)) + if self.Config("TRUNKBRANCH") != self["current_branch"]: + self.GitDeleteBranch(self.Config("TRUNKBRANCH")) class PushToTrunk(ScriptsBase): @@ -437,6 +425,17 @@ class PushToTrunk(ScriptsBase): options.tbr_commit = not options.manual return True + def _Config(self): + return { + "BRANCHNAME": "prepare-push", + "TRUNKBRANCH": "trunk-push", + "PERSISTFILE_BASENAME": "/tmp/v8-push-to-trunk-tempfile", + "CHANGELOG_FILE": "ChangeLog", + "CHANGELOG_ENTRY_FILE": "/tmp/v8-push-to-trunk-tempfile-changelog-entry", + "PATCH_FILE": "/tmp/v8-push-to-trunk-tempfile-patch-file", + "COMMITMSG_FILE": "/tmp/v8-push-to-trunk-tempfile-commitmsg", + } + def _Steps(self): return [ Preparation, @@ -462,4 +461,4 @@ class PushToTrunk(ScriptsBase): if __name__ == "__main__": # pragma: no cover - sys.exit(PushToTrunk(CONFIG).Run()) + sys.exit(PushToTrunk().Run()) diff --git a/tools/push-to-trunk/releases.py b/tools/push-to-trunk/releases.py index fd1f725..1d26198 100755 --- a/tools/push-to-trunk/releases.py +++ b/tools/push-to-trunk/releases.py @@ -20,11 +20,9 @@ import sys from common_includes import * -CHROMIUM = "CHROMIUM" - CONFIG = { - BRANCHNAME: "retrieve-v8-releases", - PERSISTFILE_BASENAME: "/tmp/v8-releases-tempfile", + "BRANCHNAME": "retrieve-v8-releases", + "PERSISTFILE_BASENAME": "/tmp/v8-releases-tempfile", } # Expression for retrieving the bleeding edge revision from a commit message. @@ -231,7 +229,7 @@ class RetrieveV8Releases(Step): return releases def RunStep(self): - self.GitCreateBranch(self._config[BRANCHNAME]) + self.GitCreateBranch(self._config["BRANCHNAME"]) # Get relevant remote branches, e.g. "svn/3.25". branches = filter(lambda s: re.match(r"^svn/\d+\.\d+$", s), self.GitRemotes()) @@ -284,7 +282,7 @@ class UpdateChromiumCheckout(Step): cwd = self._options.chromium self.GitCheckout("master", cwd=cwd) self.GitPull(cwd=cwd) - self.GitCreateBranch(self.Config(BRANCHNAME), cwd=cwd) + self.GitCreateBranch(self.Config("BRANCHNAME"), cwd=cwd) def ConvertToCommitNumber(step, revision): @@ -408,7 +406,7 @@ class CleanUp(Step): def RunStep(self): self.GitCheckout("master", cwd=self._options.chromium) - self.GitDeleteBranch(self.Config(BRANCHNAME), cwd=self._options.chromium) + self.GitDeleteBranch(self.Config("BRANCHNAME"), cwd=self._options.chromium) self.CommonCleanup() @@ -449,6 +447,12 @@ class Releases(ScriptsBase): def _ProcessOptions(self, options): # pragma: no cover return True + def _Config(self): + return { + "BRANCHNAME": "retrieve-v8-releases", + "PERSISTFILE_BASENAME": "/tmp/v8-releases-tempfile", + } + def _Steps(self): return [ Preparation, @@ -463,4 +467,4 @@ class Releases(ScriptsBase): if __name__ == "__main__": # pragma: no cover - sys.exit(Releases(CONFIG).Run()) + sys.exit(Releases().Run()) diff --git a/tools/push-to-trunk/test_scripts.py b/tools/push-to-trunk/test_scripts.py index 38c644e..b0d1c58 100644 --- a/tools/push-to-trunk/test_scripts.py +++ b/tools/push-to-trunk/test_scripts.py @@ -34,9 +34,7 @@ import unittest import auto_push from auto_push import CheckLastPush -from auto_push import SETTINGS_LOCATION import auto_roll -from auto_roll import CLUSTERFUZZ_API_KEY_FILE import common_includes from common_includes import * import merge_to_branch @@ -44,7 +42,6 @@ from merge_to_branch import * import push_to_trunk from push_to_trunk import * import chromium_roll -from chromium_roll import CHROMIUM from chromium_roll import ChromiumRoll import releases from releases import Releases @@ -57,20 +54,19 @@ from auto_tag import AutoTag TEST_CONFIG = { "DEFAULT_CWD": None, - BRANCHNAME: "test-prepare-push", - TRUNKBRANCH: "test-trunk-push", - PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", - CHANGELOG_FILE: None, - CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", - PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", - COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", - CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", - SETTINGS_LOCATION: None, - ALREADY_MERGING_SENTINEL_FILE: + "BRANCHNAME": "test-prepare-push", + "TRUNKBRANCH": "test-trunk-push", + "PERSISTFILE_BASENAME": "/tmp/test-v8-push-to-trunk-tempfile", + "CHANGELOG_FILE": None, + "CHANGELOG_ENTRY_FILE": "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", + "PATCH_FILE": "/tmp/test-v8-push-to-trunk-tempfile-patch", + "COMMITMSG_FILE": "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", + "CHROMIUM": "/tmp/test-v8-push-to-trunk-tempfile-chromium", + "SETTINGS_LOCATION": None, + "ALREADY_MERGING_SENTINEL_FILE": "/tmp/test-merge-to-branch-tempfile-already-merging", - COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", - TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch", - CLUSTERFUZZ_API_KEY_FILE: "/tmp/test-fake-cf-api-key", + "TEMPORARY_PATCH_FILE": "/tmp/test-merge-to-branch-tempfile-temporary-patch", + "CLUSTERFUZZ_API_KEY_FILE": "/tmp/test-fake-cf-api-key", } @@ -428,8 +424,8 @@ class ScriptTest(unittest.TestCase): TEST_CONFIG["DEFAULT_CWD"] = self.MakeEmptyTempDirectory() def tearDown(self): - if os.path.exists(TEST_CONFIG[PERSISTFILE_BASENAME]): - shutil.rmtree(TEST_CONFIG[PERSISTFILE_BASENAME]) + if os.path.exists(TEST_CONFIG["PERSISTFILE_BASENAME"]): + shutil.rmtree(TEST_CONFIG["PERSISTFILE_BASENAME"]) # Clean up temps. Doesn't work automatically. for name in self._tmp_files: @@ -451,9 +447,9 @@ class ScriptTest(unittest.TestCase): Cmd("git status -s -uno", ""), Cmd("git status -s -b -uno", "## some_branch"), Cmd("git svn fetch", ""), - Cmd("git branch", " branch1\n* %s" % TEST_CONFIG[BRANCHNAME]), + Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]), RL("Y"), - Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), + Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""), ]) self.MakeStep().CommonPrepare() self.MakeStep().PrepareBranch() @@ -464,7 +460,7 @@ class ScriptTest(unittest.TestCase): Cmd("git status -s -uno", ""), Cmd("git status -s -b -uno", "## some_branch"), Cmd("git svn fetch", ""), - Cmd("git branch", " branch1\n* %s" % TEST_CONFIG[BRANCHNAME]), + Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]), RL("n"), ]) self.MakeStep().CommonPrepare() @@ -476,9 +472,9 @@ class ScriptTest(unittest.TestCase): Cmd("git status -s -uno", ""), Cmd("git status -s -b -uno", "## some_branch"), Cmd("git svn fetch", ""), - Cmd("git branch", " branch1\n* %s" % TEST_CONFIG[BRANCHNAME]), + Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]), RL("Y"), - Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], None), + Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], None), ]) self.MakeStep().CommonPrepare() self.assertRaises(Exception, self.MakeStep().PrepareBranch) @@ -533,7 +529,7 @@ class ScriptTest(unittest.TestCase): def testPrepareChangeLog(self): self.WriteFakeVersionFile() - TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() + TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile() self.Expect([ Cmd("git log --format=%H 1234..push_hash", "rev1\nrev2\nrev3\nrev4"), @@ -560,7 +556,7 @@ class ScriptTest(unittest.TestCase): self._state["version"] = "3.22.5" self.RunStep(PushToTrunk, PrepareChangeLog) - actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) + actual_cl = FileToText(TEST_CONFIG["CHANGELOG_ENTRY_FILE"]) expected_cl = """1999-07-31: Version 3.22.5 @@ -591,18 +587,18 @@ class ScriptTest(unittest.TestCase): self.assertEquals(expected_cl, actual_cl) def testEditChangeLog(self): - TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() - TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) + TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile() + TextToFile(" New \n\tLines \n", TEST_CONFIG["CHANGELOG_ENTRY_FILE"]) os.environ["EDITOR"] = "vi" self.Expect([ RL(""), # Open editor. - Cmd("vi %s" % TEST_CONFIG[CHANGELOG_ENTRY_FILE], ""), + Cmd("vi %s" % TEST_CONFIG["CHANGELOG_ENTRY_FILE"], ""), ]) self.RunStep(PushToTrunk, EditChangeLog) self.assertEquals("New\n Lines", - FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])) + FileToText(TEST_CONFIG["CHANGELOG_ENTRY_FILE"])) # Version on trunk: 3.22.4.0. Version on master (bleeding_edge): 3.22.6. # Make sure that the increment is 3.22.7.0. @@ -627,8 +623,8 @@ class ScriptTest(unittest.TestCase): self.assertEquals("0", self._state["new_patch"]) def _TestSquashCommits(self, change_log, expected_msg): - TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() - with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: + TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile() + with open(TEST_CONFIG["CHANGELOG_ENTRY_FILE"], "w") as f: f.write(change_log) self.Expect([ @@ -640,9 +636,9 @@ class ScriptTest(unittest.TestCase): self._state["date"] = "1999-11-11" self.RunStep(PushToTrunk, SquashCommits) - self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg) + self.assertEquals(FileToText(TEST_CONFIG["COMMITMSG_FILE"]), expected_msg) - patch = FileToText(TEST_CONFIG[ PATCH_FILE]) + patch = FileToText(TEST_CONFIG["PATCH_FILE"]) self.assertTrue(re.search(r"patch content", patch)) def testSquashCommitsUnformatted(self): @@ -685,10 +681,10 @@ Performance and stability improvements on all platforms.""" # file from trunk has build level 4. self.WriteFakeVersionFile(build=5) - TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() - TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() + TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile() + TEST_CONFIG["CHANGELOG_FILE"] = self.MakeEmptyTempFile() bleeding_edge_change_log = "2014-03-17: Sentinel\n" - TextToFile(bleeding_edge_change_log, TEST_CONFIG[CHANGELOG_FILE]) + TextToFile(bleeding_edge_change_log, TEST_CONFIG["CHANGELOG_FILE"]) os.environ["EDITOR"] = "vi" def ResetChangeLog(): @@ -697,14 +693,14 @@ Performance and stability improvements on all platforms.""" trunk_change_log = """1999-04-05: Version 3.22.4 Performance and stability improvements on all platforms.\n""" - TextToFile(trunk_change_log, TEST_CONFIG[CHANGELOG_FILE]) + TextToFile(trunk_change_log, TEST_CONFIG["CHANGELOG_FILE"]) def ResetToTrunk(): ResetChangeLog() self.WriteFakeVersionFile() def CheckSVNCommit(): - commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) + commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"]) self.assertEquals( """Version 3.22.5 (based on bleeding_edge revision r123455) @@ -720,7 +716,7 @@ Performance and stability improvements on all platforms.""", commit) self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) # Check that the change log on the trunk branch got correctly modified. - change_log = FileToText(TEST_CONFIG[CHANGELOG_FILE]) + change_log = FileToText(TEST_CONFIG["CHANGELOG_FILE"]) self.assertEquals( """1999-07-31: Version 3.22.5 @@ -744,7 +740,7 @@ Performance and stability improvements on all platforms.""", commit) Cmd("git svn fetch", ""), Cmd("git branch", " branch1\n* branch2\n"), Cmd("git branch", " branch1\n* branch2\n"), - Cmd("git checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], + Cmd("git checkout -b %s svn/bleeding_edge" % TEST_CONFIG["BRANCHNAME"], ""), Cmd("git svn find-rev r123455", "push_hash\n"), Cmd(("git log -1 --format=%H --grep=" @@ -774,20 +770,21 @@ Performance and stability improvements on all platforms.""", commit) if manual: expectations.append(RL("")) # Open editor. if not force: - expectations.append(Cmd("vi %s" % TEST_CONFIG[CHANGELOG_ENTRY_FILE], "")) + expectations.append( + Cmd("vi %s" % TEST_CONFIG["CHANGELOG_ENTRY_FILE"], "")) expectations += [ Cmd("git svn fetch", "fetch result\n"), Cmd("git checkout -f svn/bleeding_edge", ""), Cmd("git diff svn/trunk push_hash", "patch content\n"), Cmd("git svn find-rev push_hash", "123455\n"), - Cmd("git checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], "", + Cmd("git checkout -b %s svn/trunk" % TEST_CONFIG["TRUNKBRANCH"], "", cb=ResetToTrunk), - Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""), - Cmd("git checkout -f svn/trunk -- %s" % TEST_CONFIG[CHANGELOG_FILE], "", + Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG["PATCH_FILE"], ""), + Cmd("git checkout -f svn/trunk -- %s" % TEST_CONFIG["CHANGELOG_FILE"], "", cb=ResetChangeLog), Cmd("git checkout -f svn/trunk -- src/version.cc", "", cb=self.WriteFakeVersionFile), - Cmd("git commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", + Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], "", cb=CheckSVNCommit), ] if manual: @@ -797,8 +794,8 @@ Performance and stability improvements on all platforms.""", commit) "Some output\nCommitted r123456\nSome output\n"), Cmd("git svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""), Cmd("git checkout -f some_branch", ""), - Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), - Cmd("git branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""), + Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""), + Cmd("git branch -D %s" % TEST_CONFIG["TRUNKBRANCH"], ""), ] self.Expect(expectations) @@ -808,7 +805,7 @@ Performance and stability improvements on all platforms.""", commit) else: args += ["-r", "reviewer@chromium.org"] PushToTrunk(TEST_CONFIG, self).Run(args) - cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) + cl = FileToText(TEST_CONFIG["CHANGELOG_FILE"]) self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) @@ -845,7 +842,7 @@ git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@123456 123 """ def testChromiumRoll(self): - googlers_mapping_py = "%s-mapping.py" % TEST_CONFIG[PERSISTFILE_BASENAME] + googlers_mapping_py = "%s-mapping.py" % TEST_CONFIG["PERSISTFILE_BASENAME"] with open(googlers_mapping_py, "w") as f: f.write(""" def list_to_dict(entries): @@ -854,9 +851,9 @@ def get_list(): pass""") # Setup fake directory structures. - TEST_CONFIG[CHROMIUM] = self.MakeEmptyTempDirectory() - TextToFile("", os.path.join(TEST_CONFIG[CHROMIUM], ".git")) - chrome_dir = TEST_CONFIG[CHROMIUM] + TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory() + TextToFile("", os.path.join(TEST_CONFIG["CHROMIUM"], ".git")) + chrome_dir = TEST_CONFIG["CHROMIUM"] os.makedirs(os.path.join(chrome_dir, "v8")) # Write fake deps file. @@ -919,7 +916,7 @@ def get_list(): def testAutoPush(self): TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git")) - TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" + TEST_CONFIG["SETTINGS_LOCATION"] = "~/.doesnotexist" self.Expect([ Cmd("git status -s -uno", ""), @@ -939,14 +936,15 @@ def get_list(): auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS + ["--push"]) state = json.loads(FileToText("%s-state.json" - % TEST_CONFIG[PERSISTFILE_BASENAME])) + % TEST_CONFIG["PERSISTFILE_BASENAME"])) self.assertEquals("100", state["lkgr"]) def testAutoPushStoppedBySettings(self): TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git")) - TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() - TextToFile("{\"enable_auto_push\": false}", TEST_CONFIG[SETTINGS_LOCATION]) + TEST_CONFIG["SETTINGS_LOCATION"] = self.MakeEmptyTempFile() + TextToFile("{\"enable_auto_push\": false}", + TEST_CONFIG["SETTINGS_LOCATION"]) self.Expect([ Cmd("git status -s -uno", ""), @@ -960,7 +958,7 @@ def get_list(): def testAutoPushStoppedByTreeStatus(self): TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git")) - TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" + TEST_CONFIG["SETTINGS_LOCATION"] = "~/.doesnotexist" self.Expect([ Cmd("git status -s -uno", ""), @@ -983,7 +981,7 @@ def get_list(): ]) result = auto_roll.AutoRoll(TEST_CONFIG, self).Run( - AUTO_PUSH_ARGS + ["-c", TEST_CONFIG[CHROMIUM]]) + AUTO_PUSH_ARGS + ["-c", TEST_CONFIG["CHROMIUM"]]) self.assertEquals(0, result) # Snippet from the original DEPS file. @@ -999,8 +997,8 @@ deps = { """ def testAutoRollUpToDate(self): - TEST_CONFIG[CHROMIUM] = self.MakeEmptyTempDirectory() - TextToFile(self.FAKE_DEPS, os.path.join(TEST_CONFIG[CHROMIUM], "DEPS")) + TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory() + TextToFile(self.FAKE_DEPS, os.path.join(TEST_CONFIG["CHROMIUM"], "DEPS")) self.Expect([ URL("https://codereview.chromium.org/search", "owner=author%40chromium.org&limit=30&closed=3&format=json", @@ -1013,14 +1011,14 @@ deps = { ]) result = auto_roll.AutoRoll(TEST_CONFIG, self).Run( - AUTO_PUSH_ARGS + ["-c", TEST_CONFIG[CHROMIUM]]) + AUTO_PUSH_ARGS + ["-c", TEST_CONFIG["CHROMIUM"]]) self.assertEquals(0, result) def testAutoRoll(self): - TEST_CONFIG[CHROMIUM] = self.MakeEmptyTempDirectory() - TextToFile(self.FAKE_DEPS, os.path.join(TEST_CONFIG[CHROMIUM], "DEPS")) - TEST_CONFIG[CLUSTERFUZZ_API_KEY_FILE] = self.MakeEmptyTempFile() - TextToFile("fake key", TEST_CONFIG[CLUSTERFUZZ_API_KEY_FILE]) + TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory() + TextToFile(self.FAKE_DEPS, os.path.join(TEST_CONFIG["CHROMIUM"], "DEPS")) + TEST_CONFIG["CLUSTERFUZZ_API_KEY_FILE"] = self.MakeEmptyTempFile() + TextToFile("fake key", TEST_CONFIG["CLUSTERFUZZ_API_KEY_FILE"]) self.Expect([ URL("https://codereview.chromium.org/search", @@ -1034,11 +1032,11 @@ deps = { ]) result = auto_roll.AutoRoll(TEST_CONFIG, self).Run( - AUTO_PUSH_ARGS + ["-c", TEST_CONFIG[CHROMIUM], "--roll"]) + AUTO_PUSH_ARGS + ["-c", TEST_CONFIG["CHROMIUM"], "--roll"]) self.assertEquals(0, result) def testMergeToBranch(self): - TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() + TEST_CONFIG["ALREADY_MERGING_SENTINEL_FILE"] = self.MakeEmptyTempFile() TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git")) self.WriteFakeVersionFile(build=5) os.environ["EDITOR"] = "vi" @@ -1046,7 +1044,7 @@ deps = { def VerifyPatch(patch): return lambda: self.assertEquals(patch, - FileToText(TEST_CONFIG[TEMPORARY_PATCH_FILE])) + FileToText(TEST_CONFIG["TEMPORARY_PATCH_FILE"])) msg = """Version 3.22.5.1 (merged r12345, r23456, r34567, r45678, r56789) @@ -1065,7 +1063,7 @@ LOG=N """ def VerifySVNCommit(): - commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) + commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"]) self.assertEquals(msg, commit) version = FileToText( os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE)) @@ -1079,7 +1077,7 @@ LOG=N Cmd("git status -s -b -uno", "## some_branch\n"), Cmd("git svn fetch", ""), Cmd("git branch", " branch1\n* branch2\n"), - Cmd("git checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""), + Cmd("git checkout -b %s svn/trunk" % TEST_CONFIG["BRANCHNAME"], ""), Cmd(("git log --format=%H --grep=\"Port r12345\" " "--reverse svn/bleeding_edge"), "hash1\nhash2"), @@ -1117,31 +1115,31 @@ LOG=N Cmd("git log -1 hash5", "Revert \"Something\"\nBUG=none"), Cmd("git log -1 -p hash4", "patch4"), Cmd(("git apply --index --reject \"%s\"" % - TEST_CONFIG[TEMPORARY_PATCH_FILE]), + TEST_CONFIG["TEMPORARY_PATCH_FILE"]), "", cb=VerifyPatch("patch4")), Cmd("git log -1 -p hash2", "patch2"), Cmd(("git apply --index --reject \"%s\"" % - TEST_CONFIG[TEMPORARY_PATCH_FILE]), + TEST_CONFIG["TEMPORARY_PATCH_FILE"]), "", cb=VerifyPatch("patch2")), Cmd("git log -1 -p hash3", "patch3"), Cmd(("git apply --index --reject \"%s\"" % - TEST_CONFIG[TEMPORARY_PATCH_FILE]), + TEST_CONFIG["TEMPORARY_PATCH_FILE"]), "", cb=VerifyPatch("patch3")), Cmd("git log -1 -p hash1", "patch1"), Cmd(("git apply --index --reject \"%s\"" % - TEST_CONFIG[TEMPORARY_PATCH_FILE]), + TEST_CONFIG["TEMPORARY_PATCH_FILE"]), "", cb=VerifyPatch("patch1")), Cmd("git log -1 -p hash5", "patch5\n"), Cmd(("git apply --index --reject \"%s\"" % - TEST_CONFIG[TEMPORARY_PATCH_FILE]), + TEST_CONFIG["TEMPORARY_PATCH_FILE"]), "", cb=VerifyPatch("patch5\n")), Cmd("git apply --index --reject \"%s\"" % extra_patch, ""), RL("Y"), # Automatically increment patch level? - Cmd("git commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""), + Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], ""), RL("reviewer@chromium.org"), # V8 reviewer. Cmd("git cl upload --send-mail -r \"reviewer@chromium.org\" " "--bypass-hooks", ""), - Cmd("git checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""), + Cmd("git checkout -f %s" % TEST_CONFIG["BRANCHNAME"], ""), RL("LGTM"), # Enter LGTM for V8 CL. Cmd("git cl presubmit", "Presubmit successfull\n"), Cmd("git cl dcommit -f --bypass-hooks", "Closing issue\n", @@ -1154,7 +1152,7 @@ LOG=N "https://v8.googlecode.com/svn/tags/3.22.5.1 -m " "\"Tagging version 3.22.5.1\""), ""), Cmd("git checkout -f some_branch", ""), - Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), + Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""), ]) # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS @@ -1222,8 +1220,8 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b csv_output = self.MakeEmptyTempFile() self.WriteFakeVersionFile() - TEST_CONFIG[CHROMIUM] = self.MakeEmptyTempDirectory() - chrome_dir = TEST_CONFIG[CHROMIUM] + TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory() + chrome_dir = TEST_CONFIG["CHROMIUM"] chrome_v8_dir = os.path.join(chrome_dir, "v8") os.makedirs(chrome_v8_dir) def WriteDEPS(revision): @@ -1244,7 +1242,7 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b Cmd("git status -s -b -uno", "## some_branch\n"), Cmd("git svn fetch", ""), Cmd("git branch", " branch1\n* branch2\n"), - Cmd("git checkout -b %s" % TEST_CONFIG[BRANCHNAME], ""), + Cmd("git checkout -b %s" % TEST_CONFIG["BRANCHNAME"], ""), Cmd("git branch -r", " svn/3.21\n svn/3.3\n"), Cmd("git reset --hard svn/3.3", ""), Cmd("git log --format=%H", "hash1\nhash2"), @@ -1293,7 +1291,7 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b Cmd("git status -s -uno", "", cwd=chrome_dir), Cmd("git checkout -f master", "", cwd=chrome_dir), Cmd("git pull", "", cwd=chrome_dir), - Cmd("git checkout -b %s" % TEST_CONFIG[BRANCHNAME], "", cwd=chrome_dir), + Cmd("git checkout -b %s" % TEST_CONFIG["BRANCHNAME"], "", cwd=chrome_dir), Cmd("git fetch origin", "", cwd=chrome_v8_dir), Cmd("git log --format=%H --grep=\"V8\"", "c_hash1\nc_hash2\nc_hash3\n", cwd=chrome_dir), @@ -1321,12 +1319,12 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b Cmd("git checkout -f HEAD -- DEPS", "", cb=ResetDEPS(567), cwd=chrome_dir), Cmd("git checkout -f master", "", cwd=chrome_dir), - Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], "", cwd=chrome_dir), + Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], "", cwd=chrome_dir), Cmd("git checkout -f some_branch", ""), - Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), + Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""), ]) - args = ["-c", TEST_CONFIG[CHROMIUM], + args = ["-c", TEST_CONFIG["CHROMIUM"], "--json", json_output, "--csv", csv_output, "--max-releases", "1"] @@ -1417,17 +1415,18 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b BumpUpVersion(TEST_CONFIG, self).Run(["-a", "author@chromium.org"]) def testBumpUpVersionSvn(self): + svn_root = self.MakeEmptyTempDirectory() expectations = self._bumpUpVersion() expectations += [ Cmd("git diff HEAD^ HEAD", "patch content"), - Cmd("svn update", "", cwd="[SVN_ROOT]"), - Cmd("svn status", "", cwd="[SVN_ROOT]"), + Cmd("svn update", "", cwd=svn_root), + Cmd("svn status", "", cwd=svn_root), Cmd("patch -d branches/bleeding_edge -p1 -i %s" % - TEST_CONFIG[PATCH_FILE], "Applied patch...", cwd="[SVN_ROOT]"), + TEST_CONFIG["PATCH_FILE"], "Applied patch...", cwd=svn_root), Cmd("svn commit --non-interactive --username=author@chromium.org " "--config-dir=[CONFIG_DIR] " "-m \"[Auto-roll] Bump up version to 3.11.6.0\"", - "", cwd="[SVN_ROOT]"), + "", cwd=svn_root), Cmd("git checkout -f bleeding_edge", ""), Cmd("git branch", "auto-bump-up-version\n* bleeding_edge"), Cmd("git branch -D auto-bump-up-version", ""), @@ -1436,7 +1435,7 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b BumpUpVersion(TEST_CONFIG, self).Run( ["-a", "author@chromium.org", - "--svn", "[SVN_ROOT]", + "--svn", svn_root, "--svn-config", "[CONFIG_DIR]"]) def testAutoTag(self): @@ -1454,7 +1453,7 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b Cmd("git branch", " branch1\n* branch2\n"), Cmd("git checkout -f master", ""), Cmd("git svn rebase", ""), - Cmd("git checkout -b %s" % TEST_CONFIG[BRANCHNAME], "", + Cmd("git checkout -b %s" % TEST_CONFIG["BRANCHNAME"], "", cb=ResetVersion(4, 5)), Cmd("git branch -r", "svn/tags/3.4.2\nsvn/tags/3.2.1.0\nsvn/branches/3.4"), @@ -1484,7 +1483,7 @@ git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b Cmd("git reset --hard hash123", ""), Cmd("git svn tag 3.4.3 -m \"Tagging version 3.4.3\"", ""), Cmd("git checkout -f some_branch", ""), - Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), + Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""), ]) AutoTag(TEST_CONFIG, self).Run(["-a", "author@chromium.org"])