2013-11-08 14:27:16 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright 2013 the V8 project authors. All rights reserved.
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are
|
|
|
|
# met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above
|
|
|
|
# copyright notice, this list of conditions and the following
|
|
|
|
# disclaimer in the documentation and/or other materials provided
|
|
|
|
# with the distribution.
|
|
|
|
# * Neither the name of Google Inc. nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived
|
|
|
|
# from this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
import os
|
2014-09-05 09:19:48 +00:00
|
|
|
import shutil
|
2013-11-08 14:27:16 +00:00
|
|
|
import tempfile
|
2014-01-23 13:44:52 +00:00
|
|
|
import traceback
|
2013-11-08 14:27:16 +00:00
|
|
|
import unittest
|
|
|
|
|
2014-03-24 15:52:31 +00:00
|
|
|
import auto_push
|
2015-01-28 10:08:53 +00:00
|
|
|
from auto_push import LastReleaseBailout
|
2014-04-02 06:59:25 +00:00
|
|
|
import auto_roll
|
2014-02-18 13:09:14 +00:00
|
|
|
import common_includes
|
|
|
|
from common_includes import *
|
2015-01-30 16:46:41 +00:00
|
|
|
import create_release
|
|
|
|
from create_release import CreateRelease
|
2014-02-18 13:09:14 +00:00
|
|
|
import merge_to_branch
|
2016-07-22 09:27:41 +00:00
|
|
|
from merge_to_branch import MergeToBranch
|
2015-01-26 14:20:59 +00:00
|
|
|
import push_to_candidates
|
|
|
|
from push_to_candidates import *
|
2014-04-09 14:30:02 +00:00
|
|
|
import releases
|
|
|
|
from releases import Releases
|
2014-07-18 12:16:14 +00:00
|
|
|
from auto_tag import AutoTag
|
2016-07-22 09:27:41 +00:00
|
|
|
import roll_merge
|
|
|
|
from roll_merge import RollMerge
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
TEST_CONFIG = {
|
2014-09-19 13:37:34 +00:00
|
|
|
"DEFAULT_CWD": None,
|
2014-09-23 14:41:36 +00:00
|
|
|
"BRANCHNAME": "test-prepare-push",
|
2015-01-26 13:29:23 +00:00
|
|
|
"CANDIDATESBRANCH": "test-candidates-push",
|
|
|
|
"PERSISTFILE_BASENAME": "/tmp/test-v8-push-to-candidates-tempfile",
|
|
|
|
"CHANGELOG_ENTRY_FILE":
|
|
|
|
"/tmp/test-v8-push-to-candidates-tempfile-changelog-entry",
|
|
|
|
"PATCH_FILE": "/tmp/test-v8-push-to-candidates-tempfile-patch",
|
|
|
|
"COMMITMSG_FILE": "/tmp/test-v8-push-to-candidates-tempfile-commitmsg",
|
|
|
|
"CHROMIUM": "/tmp/test-v8-push-to-candidates-tempfile-chromium",
|
2014-09-23 14:41:36 +00:00
|
|
|
"SETTINGS_LOCATION": None,
|
|
|
|
"ALREADY_MERGING_SENTINEL_FILE":
|
2014-02-18 13:09:14 +00:00
|
|
|
"/tmp/test-merge-to-branch-tempfile-already-merging",
|
2014-09-23 14:41:36 +00:00
|
|
|
"TEMPORARY_PATCH_FILE": "/tmp/test-merge-to-branch-tempfile-temporary-patch",
|
2013-11-08 14:27:16 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 19:45:28 +00:00
|
|
|
|
2014-03-24 15:52:31 +00:00
|
|
|
AUTO_PUSH_ARGS = [
|
2014-02-26 15:13:31 +00:00
|
|
|
"-a", "author@chromium.org",
|
|
|
|
"-r", "reviewer@chromium.org",
|
|
|
|
]
|
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2013-11-20 08:25:17 +00:00
|
|
|
class ToplevelTest(unittest.TestCase):
|
2015-11-05 17:26:41 +00:00
|
|
|
def testSaniniziteVersionTags(self):
|
|
|
|
self.assertEquals("4.8.230", SanitizeVersionTag("4.8.230"))
|
|
|
|
self.assertEquals("4.8.230", SanitizeVersionTag("tags/4.8.230"))
|
|
|
|
self.assertEquals(None, SanitizeVersionTag("candidate"))
|
|
|
|
|
|
|
|
def testNormalizeVersionTags(self):
|
|
|
|
input = ["4.8.230",
|
|
|
|
"tags/4.8.230",
|
|
|
|
"tags/4.8.224.1",
|
|
|
|
"4.8.224.1",
|
|
|
|
"4.8.223.1",
|
|
|
|
"tags/4.8.223",
|
|
|
|
"tags/4.8.231",
|
|
|
|
"candidates"]
|
|
|
|
expected = ["4.8.230",
|
|
|
|
"4.8.230",
|
|
|
|
"4.8.224.1",
|
|
|
|
"4.8.224.1",
|
|
|
|
"4.8.223.1",
|
|
|
|
"4.8.223",
|
|
|
|
"4.8.231",
|
|
|
|
]
|
|
|
|
self.assertEquals(expected, NormalizeVersionTags(input))
|
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
def testSortBranches(self):
|
|
|
|
S = releases.SortBranches
|
|
|
|
self.assertEquals(["3.1", "2.25"], S(["2.25", "3.1"])[0:2])
|
|
|
|
self.assertEquals(["3.0", "2.25"], S(["2.25", "3.0", "2.24"])[0:2])
|
|
|
|
self.assertEquals(["3.11", "3.2"], S(["3.11", "3.2", "2.24"])[0:2])
|
|
|
|
|
|
|
|
def testFilterDuplicatesAndReverse(self):
|
|
|
|
F = releases.FilterDuplicatesAndReverse
|
|
|
|
self.assertEquals([], F([]))
|
|
|
|
self.assertEquals([["100", "10"]], F([["100", "10"]]))
|
|
|
|
self.assertEquals([["99", "9"], ["100", "10"]],
|
|
|
|
F([["100", "10"], ["99", "9"]]))
|
|
|
|
self.assertEquals([["98", "9"], ["100", "10"]],
|
|
|
|
F([["100", "10"], ["99", "9"], ["98", "9"]]))
|
|
|
|
self.assertEquals([["98", "9"], ["99", "10"]],
|
|
|
|
F([["100", "10"], ["99", "10"], ["98", "9"]]))
|
|
|
|
|
|
|
|
def testBuildRevisionRanges(self):
|
|
|
|
B = releases.BuildRevisionRanges
|
|
|
|
self.assertEquals({}, B([]))
|
|
|
|
self.assertEquals({"10": "100"}, B([["100", "10"]]))
|
|
|
|
self.assertEquals({"10": "100", "9": "99:99"},
|
|
|
|
B([["100", "10"], ["99", "9"]]))
|
|
|
|
self.assertEquals({"10": "100", "9": "97:99"},
|
|
|
|
B([["100", "10"], ["98", "9"], ["97", "9"]]))
|
|
|
|
self.assertEquals({"10": "100", "9": "99:99", "3": "91:98"},
|
|
|
|
B([["100", "10"], ["99", "9"], ["91", "3"]]))
|
|
|
|
self.assertEquals({"13": "101", "12": "100:100", "9": "94:97",
|
2014-04-11 07:40:48 +00:00
|
|
|
"3": "91:93, 98:99"},
|
2014-04-09 14:30:02 +00:00
|
|
|
B([["101", "13"], ["100", "12"], ["98", "3"],
|
|
|
|
["94", "9"], ["91", "3"]]))
|
|
|
|
|
2013-11-21 09:35:25 +00:00
|
|
|
def testMakeComment(self):
|
|
|
|
self.assertEquals("# Line 1\n# Line 2\n#",
|
|
|
|
MakeComment(" Line 1\n Line 2\n"))
|
|
|
|
self.assertEquals("#Line 1\n#Line 2",
|
|
|
|
MakeComment("Line 1\n Line 2"))
|
|
|
|
|
|
|
|
def testStripComments(self):
|
|
|
|
self.assertEquals(" Line 1\n Line 3\n",
|
|
|
|
StripComments(" Line 1\n# Line 2\n Line 3\n#\n"))
|
|
|
|
self.assertEquals("\nLine 2 ### Test\n #",
|
|
|
|
StripComments("###\n# \n\n# Line 1\nLine 2 ### Test\n #"))
|
|
|
|
|
2013-11-20 08:25:17 +00:00
|
|
|
def testMakeChangeLogBodySimple(self):
|
2013-11-21 09:35:25 +00:00
|
|
|
commits = [
|
2013-11-22 09:48:43 +00:00
|
|
|
["Title text 1",
|
2013-11-20 08:25:17 +00:00
|
|
|
"Title text 1\n\nBUG=\n",
|
2013-11-22 09:48:43 +00:00
|
|
|
"author1@chromium.org"],
|
2013-11-25 14:20:39 +00:00
|
|
|
["Title text 2.",
|
2013-11-20 08:25:17 +00:00
|
|
|
"Title text 2\n\nBUG=1234\n",
|
2013-11-22 09:48:43 +00:00
|
|
|
"author2@chromium.org"],
|
2013-11-20 08:25:17 +00:00
|
|
|
]
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals(" Title text 1.\n"
|
2013-11-22 09:48:43 +00:00
|
|
|
" (author1@chromium.org)\n\n"
|
2013-11-25 14:20:39 +00:00
|
|
|
" Title text 2 (Chromium issue 1234).\n"
|
2013-11-22 09:48:43 +00:00
|
|
|
" (author2@chromium.org)\n\n",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBody(commits))
|
|
|
|
|
|
|
|
def testMakeChangeLogBodyEmpty(self):
|
2013-11-21 09:35:25 +00:00
|
|
|
self.assertEquals("", MakeChangeLogBody([]))
|
|
|
|
|
|
|
|
def testMakeChangeLogBodyAutoFormat(self):
|
|
|
|
commits = [
|
2013-11-25 14:20:39 +00:00
|
|
|
["Title text 1!",
|
2013-11-21 09:35:25 +00:00
|
|
|
"Title text 1\nLOG=y\nBUG=\n",
|
2013-11-22 09:48:43 +00:00
|
|
|
"author1@chromium.org"],
|
|
|
|
["Title text 2",
|
2013-11-21 09:35:25 +00:00
|
|
|
"Title text 2\n\nBUG=1234\n",
|
2013-11-22 09:48:43 +00:00
|
|
|
"author2@chromium.org"],
|
|
|
|
["Title text 3",
|
2013-11-21 09:35:25 +00:00
|
|
|
"Title text 3\n\nBUG=1234\nLOG = Yes\n",
|
2013-11-22 09:48:43 +00:00
|
|
|
"author3@chromium.org"],
|
|
|
|
["Title text 3",
|
2013-11-21 09:35:25 +00:00
|
|
|
"Title text 4\n\nBUG=1234\nLOG=\n",
|
2013-11-22 09:48:43 +00:00
|
|
|
"author4@chromium.org"],
|
2013-11-21 09:35:25 +00:00
|
|
|
]
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals(" Title text 1.\n\n"
|
|
|
|
" Title text 3 (Chromium issue 1234).\n\n",
|
2013-11-21 09:35:25 +00:00
|
|
|
MakeChangeLogBody(commits, True))
|
2013-11-20 08:25:17 +00:00
|
|
|
|
2013-12-03 09:13:51 +00:00
|
|
|
def testRegressWrongLogEntryOnTrue(self):
|
|
|
|
body = """
|
|
|
|
Check elimination: Learn from if(CompareMap(x)) on true branch.
|
|
|
|
|
|
|
|
BUG=
|
|
|
|
R=verwaest@chromium.org
|
|
|
|
|
|
|
|
Committed: https://code.google.com/p/v8/source/detail?r=18210
|
|
|
|
"""
|
|
|
|
self.assertEquals("", MakeChangeLogBody([["title", body, "author"]], True))
|
|
|
|
|
2013-11-20 08:25:17 +00:00
|
|
|
def testMakeChangeLogBugReferenceEmpty(self):
|
|
|
|
self.assertEquals("", MakeChangeLogBugReference(""))
|
|
|
|
self.assertEquals("", MakeChangeLogBugReference("LOG="))
|
|
|
|
self.assertEquals("", MakeChangeLogBugReference(" BUG ="))
|
|
|
|
self.assertEquals("", MakeChangeLogBugReference("BUG=none\t"))
|
|
|
|
|
|
|
|
def testMakeChangeLogBugReferenceSimple(self):
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(issue 987654)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("BUG = v8:987654"))
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(Chromium issue 987654)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("BUG=987654 "))
|
|
|
|
|
|
|
|
def testMakeChangeLogBugReferenceFromBody(self):
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(Chromium issue 1234567)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("Title\n\nTBR=\nBUG=\n"
|
|
|
|
" BUG=\tchromium:1234567\t\n"
|
|
|
|
"R=somebody\n"))
|
|
|
|
|
|
|
|
def testMakeChangeLogBugReferenceMultiple(self):
|
|
|
|
# All issues should be sorted and grouped. Multiple references to the same
|
|
|
|
# issue should be filtered.
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(issues 123, 234, Chromium issue 345)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("Title\n\n"
|
|
|
|
"BUG=v8:234\n"
|
|
|
|
" BUG\t= 345, \tv8:234,\n"
|
|
|
|
"BUG=v8:123\n"
|
|
|
|
"R=somebody\n"))
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(Chromium issues 123, 234)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("Title\n\n"
|
|
|
|
"BUG=234,,chromium:123 \n"
|
|
|
|
"R=somebody\n"))
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(Chromium issues 123, 234)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("Title\n\n"
|
|
|
|
"BUG=chromium:234, , 123\n"
|
|
|
|
"R=somebody\n"))
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(issues 345, 456)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("Title\n\n"
|
|
|
|
"\t\tBUG=v8:345,v8:456\n"
|
|
|
|
"R=somebody\n"))
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(issue 123, Chromium issues 345, 456)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("Title\n\n"
|
|
|
|
"BUG=chromium:456\n"
|
|
|
|
"BUG = none\n"
|
|
|
|
"R=somebody\n"
|
|
|
|
"BUG=456,v8:123, 345"))
|
|
|
|
|
2013-11-25 14:20:39 +00:00
|
|
|
# TODO(machenbach): These test don't make much sense when the formatting is
|
|
|
|
# done later.
|
2013-11-20 08:25:17 +00:00
|
|
|
def testMakeChangeLogBugReferenceLong(self):
|
|
|
|
# -----------------00--------10--------20--------30--------
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(issues 234, 1234567890, 1234567"
|
|
|
|
"8901234567890, Chromium issues 12345678,"
|
|
|
|
" 123456789)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("BUG=v8:234\n"
|
|
|
|
"BUG=v8:1234567890\n"
|
|
|
|
"BUG=v8:12345678901234567890\n"
|
|
|
|
"BUG=123456789\n"
|
|
|
|
"BUG=12345678\n"))
|
|
|
|
# -----------------00--------10--------20--------30--------
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(issues 234, 1234567890, 1234567"
|
|
|
|
"8901234567890, Chromium issues"
|
|
|
|
" 123456789, 1234567890)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("BUG=v8:234\n"
|
|
|
|
"BUG=v8:12345678901234567890\n"
|
|
|
|
"BUG=v8:1234567890\n"
|
|
|
|
"BUG=123456789\n"
|
|
|
|
"BUG=1234567890\n"))
|
|
|
|
# -----------------00--------10--------20--------30--------
|
2013-11-25 14:20:39 +00:00
|
|
|
self.assertEquals("(Chromium issues 234, 1234567890"
|
|
|
|
", 12345678901234567, "
|
|
|
|
"1234567890123456789)",
|
2013-11-20 08:25:17 +00:00
|
|
|
MakeChangeLogBugReference("BUG=234\n"
|
|
|
|
"BUG=12345678901234567\n"
|
|
|
|
"BUG=1234567890123456789\n"
|
|
|
|
"BUG=1234567890\n"))
|
|
|
|
|
2013-11-22 07:56:00 +00:00
|
|
|
|
2014-09-02 12:51:30 +00:00
|
|
|
def Cmd(*args, **kwargs):
|
2014-09-02 15:21:45 +00:00
|
|
|
"""Convenience function returning a shell command test expectation."""
|
2014-03-12 14:39:04 +00:00
|
|
|
return {
|
2014-09-02 15:21:45 +00:00
|
|
|
"name": "command",
|
2014-09-02 12:51:30 +00:00
|
|
|
"args": args,
|
2014-03-12 14:39:04 +00:00
|
|
|
"ret": args[-1],
|
|
|
|
"cb": kwargs.get("cb"),
|
2014-09-19 13:37:34 +00:00
|
|
|
"cwd": kwargs.get("cwd", TEST_CONFIG["DEFAULT_CWD"]),
|
2014-03-12 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def RL(text, cb=None):
|
|
|
|
"""Convenience function returning a readline test expectation."""
|
2014-09-05 09:19:48 +00:00
|
|
|
return {
|
|
|
|
"name": "readline",
|
|
|
|
"args": [],
|
|
|
|
"ret": text,
|
|
|
|
"cb": cb,
|
|
|
|
"cwd": None,
|
|
|
|
}
|
2014-03-12 14:39:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
def URL(*args, **kwargs):
|
|
|
|
"""Convenience function returning a readurl test expectation."""
|
|
|
|
return {
|
|
|
|
"name": "readurl",
|
|
|
|
"args": args[:-1],
|
|
|
|
"ret": args[-1],
|
|
|
|
"cb": kwargs.get("cb"),
|
2014-09-05 09:19:48 +00:00
|
|
|
"cwd": None,
|
2014-03-12 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-22 07:56:00 +00:00
|
|
|
class SimpleMock(object):
|
2014-09-02 15:21:45 +00:00
|
|
|
def __init__(self):
|
2013-11-22 07:56:00 +00:00
|
|
|
self._recipe = []
|
|
|
|
self._index = -1
|
|
|
|
|
|
|
|
def Expect(self, recipe):
|
|
|
|
self._recipe = recipe
|
|
|
|
|
2014-09-05 09:19:48 +00:00
|
|
|
def Call(self, name, *args, **kwargs): # pragma: no cover
|
2013-11-22 07:56:00 +00:00
|
|
|
self._index += 1
|
|
|
|
try:
|
|
|
|
expected_call = self._recipe[self._index]
|
|
|
|
except IndexError:
|
2014-09-02 15:21:45 +00:00
|
|
|
raise NoRetryException("Calling %s %s" % (name, " ".join(args)))
|
2014-03-12 14:39:04 +00:00
|
|
|
|
|
|
|
if not isinstance(expected_call, dict):
|
2014-09-02 15:21:45 +00:00
|
|
|
raise NoRetryException("Found wrong expectation type for %s %s" %
|
|
|
|
(name, " ".join(args)))
|
2013-11-22 07:56:00 +00:00
|
|
|
|
2014-09-02 15:21:45 +00:00
|
|
|
if expected_call["name"] != name:
|
|
|
|
raise NoRetryException("Expected action: %s %s - Actual: %s" %
|
|
|
|
(expected_call["name"], expected_call["args"], name))
|
2013-11-22 07:56:00 +00:00
|
|
|
|
2014-09-05 09:19:48 +00:00
|
|
|
# Check if the given working directory matches the expected one.
|
|
|
|
if expected_call["cwd"] != kwargs.get("cwd"):
|
|
|
|
raise NoRetryException("Expected cwd: %s in %s %s - Actual: %s" %
|
|
|
|
(expected_call["cwd"],
|
|
|
|
expected_call["name"],
|
|
|
|
expected_call["args"],
|
|
|
|
kwargs.get("cwd")))
|
|
|
|
|
2013-11-22 07:56:00 +00:00
|
|
|
# The number of arguments in the expectation must match the actual
|
|
|
|
# arguments.
|
2014-03-12 14:39:04 +00:00
|
|
|
if len(args) > len(expected_call['args']):
|
2013-12-16 10:56:52 +00:00
|
|
|
raise NoRetryException("When calling %s with arguments, the "
|
2014-09-02 12:51:30 +00:00
|
|
|
"expectations must consist of at least as many arguments." %
|
2014-09-02 15:21:45 +00:00
|
|
|
name)
|
2013-11-22 07:56:00 +00:00
|
|
|
|
|
|
|
# Compare expected and actual arguments.
|
2014-03-12 14:39:04 +00:00
|
|
|
for (expected_arg, actual_arg) in zip(expected_call['args'], args):
|
2013-11-22 07:56:00 +00:00
|
|
|
if expected_arg != actual_arg:
|
2014-09-02 15:21:45 +00:00
|
|
|
raise NoRetryException("Expected: %s - Actual: %s" %
|
|
|
|
(expected_arg, actual_arg))
|
2013-11-22 07:56:00 +00:00
|
|
|
|
2014-03-12 14:39:04 +00:00
|
|
|
# The expected call contains an optional callback for checking the context
|
|
|
|
# at the time of the call.
|
|
|
|
if expected_call['cb']:
|
2014-01-23 13:44:52 +00:00
|
|
|
try:
|
2014-03-12 14:39:04 +00:00
|
|
|
expected_call['cb']()
|
2014-01-23 13:44:52 +00:00
|
|
|
except:
|
|
|
|
tb = traceback.format_exc()
|
|
|
|
raise NoRetryException("Caught exception from callback: %s" % tb)
|
2013-12-02 09:53:28 +00:00
|
|
|
|
|
|
|
# If the return value is an exception, raise it instead of returning.
|
2014-03-12 14:39:04 +00:00
|
|
|
if isinstance(expected_call['ret'], Exception):
|
|
|
|
raise expected_call['ret']
|
|
|
|
return expected_call['ret']
|
2013-11-22 07:56:00 +00:00
|
|
|
|
2014-03-03 20:17:03 +00:00
|
|
|
def AssertFinished(self): # pragma: no cover
|
2013-11-22 07:56:00 +00:00
|
|
|
if self._index < len(self._recipe) -1:
|
2014-09-02 15:21:45 +00:00
|
|
|
raise NoRetryException("Called mock too seldom: %d vs. %d" %
|
|
|
|
(self._index, len(self._recipe)))
|
2013-11-22 07:56:00 +00:00
|
|
|
|
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
class ScriptTest(unittest.TestCase):
|
|
|
|
def MakeEmptyTempFile(self):
|
|
|
|
handle, name = tempfile.mkstemp()
|
|
|
|
os.close(handle)
|
|
|
|
self._tmp_files.append(name)
|
|
|
|
return name
|
|
|
|
|
2014-09-05 09:19:48 +00:00
|
|
|
def MakeEmptyTempDirectory(self):
|
|
|
|
name = tempfile.mkdtemp()
|
|
|
|
self._tmp_files.append(name)
|
|
|
|
return name
|
|
|
|
|
|
|
|
|
2015-02-16 17:00:44 +00:00
|
|
|
def WriteFakeVersionFile(self, major=3, minor=22, build=4, patch=0):
|
2014-09-23 09:35:49 +00:00
|
|
|
version_file = os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE)
|
|
|
|
if not os.path.exists(os.path.dirname(version_file)):
|
|
|
|
os.makedirs(os.path.dirname(version_file))
|
|
|
|
with open(version_file, "w") as f:
|
2013-11-08 14:27:16 +00:00
|
|
|
f.write(" // Some line...\n")
|
|
|
|
f.write("\n")
|
2015-02-26 08:59:17 +00:00
|
|
|
f.write("#define V8_MAJOR_VERSION %s\n" % major)
|
|
|
|
f.write("#define V8_MINOR_VERSION %s\n" % minor)
|
|
|
|
f.write("#define V8_BUILD_NUMBER %s\n" % build)
|
|
|
|
f.write("#define V8_PATCH_LEVEL %s\n" % patch)
|
2013-11-08 14:27:16 +00:00
|
|
|
f.write(" // Some line...\n")
|
2015-02-26 08:59:17 +00:00
|
|
|
f.write("#define V8_IS_CANDIDATE_VERSION 0\n")
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2016-02-04 09:02:51 +00:00
|
|
|
def WriteFakeWatchlistsFile(self):
|
|
|
|
watchlists_file = os.path.join(TEST_CONFIG["DEFAULT_CWD"], WATCHLISTS_FILE)
|
|
|
|
if not os.path.exists(os.path.dirname(watchlists_file)):
|
|
|
|
os.makedirs(os.path.dirname(watchlists_file))
|
|
|
|
with open(watchlists_file, "w") as f:
|
|
|
|
|
|
|
|
content = """
|
|
|
|
'merges': [
|
|
|
|
# Only enabled on branches created with tools/release/create_release.py
|
|
|
|
# 'v8-merges@googlegroups.com',
|
|
|
|
],
|
|
|
|
"""
|
|
|
|
f.write(content)
|
|
|
|
|
2014-03-04 23:27:27 +00:00
|
|
|
def MakeStep(self):
|
|
|
|
"""Convenience wrapper."""
|
|
|
|
options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([])
|
|
|
|
return MakeStep(step_class=Step, state=self._state,
|
|
|
|
config=TEST_CONFIG, side_effect_handler=self,
|
|
|
|
options=options)
|
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
def RunStep(self, script=PushToCandidates, step_class=Step, args=None):
|
2013-11-22 09:48:43 +00:00
|
|
|
"""Convenience wrapper."""
|
2014-07-16 07:57:13 +00:00
|
|
|
args = args if args is not None else ["-m"]
|
2014-03-04 23:27:27 +00:00
|
|
|
return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-01-17 11:29:43 +00:00
|
|
|
def Call(self, fun, *args, **kwargs):
|
|
|
|
print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs))
|
|
|
|
|
2014-09-05 09:19:48 +00:00
|
|
|
def Command(self, cmd, args="", prefix="", pipe=True, cwd=None):
|
2014-09-02 15:21:45 +00:00
|
|
|
print "%s %s" % (cmd, args)
|
2014-09-05 09:19:48 +00:00
|
|
|
print "in %s" % cwd
|
|
|
|
return self._mock.Call("command", cmd + " " + args, cwd=cwd)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def ReadLine(self):
|
2014-09-02 15:21:45 +00:00
|
|
|
return self._mock.Call("readline")
|
2013-11-22 07:56:00 +00:00
|
|
|
|
2014-01-15 15:55:23 +00:00
|
|
|
def ReadURL(self, url, params):
|
|
|
|
if params is not None:
|
2014-09-02 15:21:45 +00:00
|
|
|
return self._mock.Call("readurl", url, params)
|
2014-01-15 15:55:23 +00:00
|
|
|
else:
|
2014-09-02 15:21:45 +00:00
|
|
|
return self._mock.Call("readurl", url)
|
2013-11-22 07:56:00 +00:00
|
|
|
|
2013-12-02 09:53:28 +00:00
|
|
|
def Sleep(self, seconds):
|
|
|
|
pass
|
|
|
|
|
2013-12-03 12:38:25 +00:00
|
|
|
def GetDate(self):
|
|
|
|
return "1999-07-31"
|
|
|
|
|
2014-07-18 12:16:14 +00:00
|
|
|
def GetUTCStamp(self):
|
2015-01-29 14:21:31 +00:00
|
|
|
return "1000000"
|
2014-07-18 12:16:14 +00:00
|
|
|
|
2014-09-02 15:21:45 +00:00
|
|
|
def Expect(self, *args):
|
2013-11-22 07:56:00 +00:00
|
|
|
"""Convenience wrapper."""
|
2014-09-02 15:21:45 +00:00
|
|
|
self._mock.Expect(*args)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def setUp(self):
|
2014-09-02 15:21:45 +00:00
|
|
|
self._mock = SimpleMock()
|
2013-11-08 14:27:16 +00:00
|
|
|
self._tmp_files = []
|
2014-02-19 11:56:48 +00:00
|
|
|
self._state = {}
|
2014-09-19 13:37:34 +00:00
|
|
|
TEST_CONFIG["DEFAULT_CWD"] = self.MakeEmptyTempDirectory()
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def tearDown(self):
|
2014-09-23 14:41:36 +00:00
|
|
|
if os.path.exists(TEST_CONFIG["PERSISTFILE_BASENAME"]):
|
|
|
|
shutil.rmtree(TEST_CONFIG["PERSISTFILE_BASENAME"])
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
# Clean up temps. Doesn't work automatically.
|
|
|
|
for name in self._tmp_files:
|
2014-09-05 09:19:48 +00:00
|
|
|
if os.path.isfile(name):
|
2013-11-08 14:27:16 +00:00
|
|
|
os.remove(name)
|
2014-09-05 09:19:48 +00:00
|
|
|
if os.path.isdir(name):
|
|
|
|
shutil.rmtree(name)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-09-02 15:21:45 +00:00
|
|
|
self._mock.AssertFinished()
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def testGitMock(self):
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([Cmd("git --version", "git version 1.2.3"),
|
|
|
|
Cmd("git dummy", "")])
|
2013-11-08 14:27:16 +00:00
|
|
|
self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version"))
|
|
|
|
self.assertEquals("", self.MakeStep().Git("dummy"))
|
|
|
|
|
|
|
|
def testCommonPrepareDefault(self):
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git status -s -uno", ""),
|
2015-03-14 01:20:45 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
2014-10-23 14:27:15 +00:00
|
|
|
Cmd("git fetch", ""),
|
2014-09-23 14:41:36 +00:00
|
|
|
Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]),
|
2014-09-02 15:21:45 +00:00
|
|
|
RL("Y"),
|
2014-09-23 14:41:36 +00:00
|
|
|
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
2013-11-22 07:56:00 +00:00
|
|
|
])
|
2013-11-08 14:27:16 +00:00
|
|
|
self.MakeStep().CommonPrepare()
|
2013-11-18 14:10:47 +00:00
|
|
|
self.MakeStep().PrepareBranch()
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def testCommonPrepareNoConfirm(self):
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git status -s -uno", ""),
|
2015-03-14 01:20:45 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
2014-10-23 14:27:15 +00:00
|
|
|
Cmd("git fetch", ""),
|
2014-09-23 14:41:36 +00:00
|
|
|
Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]),
|
2014-09-02 15:21:45 +00:00
|
|
|
RL("n"),
|
2013-11-22 07:56:00 +00:00
|
|
|
])
|
2013-11-18 14:10:47 +00:00
|
|
|
self.MakeStep().CommonPrepare()
|
|
|
|
self.assertRaises(Exception, self.MakeStep().PrepareBranch)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def testCommonPrepareDeleteBranchFailure(self):
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git status -s -uno", ""),
|
2015-03-14 01:20:45 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
2014-10-23 14:27:15 +00:00
|
|
|
Cmd("git fetch", ""),
|
2014-09-23 14:41:36 +00:00
|
|
|
Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]),
|
2014-09-02 15:21:45 +00:00
|
|
|
RL("Y"),
|
2014-09-23 14:41:36 +00:00
|
|
|
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], None),
|
2013-11-22 07:56:00 +00:00
|
|
|
])
|
2013-11-18 14:10:47 +00:00
|
|
|
self.MakeStep().CommonPrepare()
|
|
|
|
self.assertRaises(Exception, self.MakeStep().PrepareBranch)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def testInitialEnvironmentChecks(self):
|
2014-09-19 13:37:34 +00:00
|
|
|
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
|
2013-11-08 14:27:16 +00:00
|
|
|
os.environ["EDITOR"] = "vi"
|
2014-09-05 09:19:48 +00:00
|
|
|
self.Expect([
|
|
|
|
Cmd("which vi", "/usr/bin/vi"),
|
|
|
|
])
|
2014-09-19 13:37:34 +00:00
|
|
|
self.MakeStep().InitialEnvironmentChecks(TEST_CONFIG["DEFAULT_CWD"])
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-10-07 10:46:04 +00:00
|
|
|
def testTagTimeout(self):
|
|
|
|
self.Expect([
|
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git log -1 --format=%H --grep=\"Title\" origin/candidates", ""),
|
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git log -1 --format=%H --grep=\"Title\" origin/candidates", ""),
|
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git log -1 --format=%H --grep=\"Title\" origin/candidates", ""),
|
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git log -1 --format=%H --grep=\"Title\" origin/candidates", ""),
|
|
|
|
])
|
2014-11-12 17:54:11 +00:00
|
|
|
args = ["--branch", "candidates", "ab12345"]
|
2014-10-07 10:46:04 +00:00
|
|
|
self._state["version"] = "tag_name"
|
|
|
|
self._state["commit_title"] = "Title"
|
|
|
|
self.assertRaises(Exception,
|
2016-07-22 09:27:41 +00:00
|
|
|
lambda: self.RunStep(RollMerge, TagRevision, args))
|
2014-10-07 10:46:04 +00:00
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
def testReadAndPersistVersion(self):
|
2014-03-19 13:10:41 +00:00
|
|
|
self.WriteFakeVersionFile(build=5)
|
2013-11-08 14:27:16 +00:00
|
|
|
step = self.MakeStep()
|
|
|
|
step.ReadAndPersistVersion()
|
2014-02-19 11:56:48 +00:00
|
|
|
self.assertEquals("3", step["major"])
|
|
|
|
self.assertEquals("22", step["minor"])
|
|
|
|
self.assertEquals("5", step["build"])
|
|
|
|
self.assertEquals("0", step["patch"])
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def testRegex(self):
|
|
|
|
self.assertEqual("(issue 321)",
|
|
|
|
re.sub(r"BUG=v8:(.*)$", r"(issue \1)", "BUG=v8:321"))
|
|
|
|
self.assertEqual("(Chromium issue 321)",
|
|
|
|
re.sub(r"BUG=(.*)$", r"(Chromium issue \1)", "BUG=321"))
|
|
|
|
|
|
|
|
cl = " too little\n\ttab\ttab\n too much\n trailing "
|
|
|
|
cl = MSub(r"\t", r" ", cl)
|
|
|
|
cl = MSub(r"^ {1,7}([^ ])", r" \1", cl)
|
|
|
|
cl = MSub(r"^ {9,80}([^ ])", r" \1", cl)
|
|
|
|
cl = MSub(r" +$", r"", cl)
|
|
|
|
self.assertEqual(" too little\n"
|
|
|
|
" tab tab\n"
|
|
|
|
" too much\n"
|
|
|
|
" trailing", cl)
|
|
|
|
|
2015-02-26 08:59:17 +00:00
|
|
|
self.assertEqual("//\n#define V8_BUILD_NUMBER 3\n",
|
|
|
|
MSub(r"(?<=#define V8_BUILD_NUMBER)(?P<space>\s+)\d*$",
|
2013-11-08 14:27:16 +00:00
|
|
|
r"\g<space>3",
|
2015-02-26 08:59:17 +00:00
|
|
|
"//\n#define V8_BUILD_NUMBER 321\n"))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-03-20 15:44:30 +00:00
|
|
|
def testPreparePushRevision(self):
|
|
|
|
# Tests the default push hash used when the --revision option is not set.
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git log -1 --format=%H HEAD", "push_hash")
|
2014-03-20 15:44:30 +00:00
|
|
|
])
|
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
self.RunStep(PushToCandidates, PreparePushRevision)
|
2014-03-20 15:44:30 +00:00
|
|
|
self.assertEquals("push_hash", self._state["push_hash"])
|
|
|
|
|
2013-11-08 14:27:16 +00:00
|
|
|
def testPrepareChangeLog(self):
|
2014-03-19 10:46:24 +00:00
|
|
|
self.WriteFakeVersionFile()
|
2014-09-23 14:41:36 +00:00
|
|
|
TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git log --format=%H 1234..push_hash", "rev1\nrev2\nrev3\nrev4"),
|
|
|
|
Cmd("git log -1 --format=%s rev1", "Title text 1"),
|
|
|
|
Cmd("git log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"),
|
|
|
|
Cmd("git log -1 --format=%an rev1", "author1@chromium.org"),
|
|
|
|
Cmd("git log -1 --format=%s rev2", "Title text 2."),
|
|
|
|
Cmd("git log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"),
|
|
|
|
Cmd("git log -1 --format=%an rev2", "author2@chromium.org"),
|
|
|
|
Cmd("git log -1 --format=%s rev3", "Title text 3"),
|
|
|
|
Cmd("git log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"),
|
|
|
|
Cmd("git log -1 --format=%an rev3", "author3@chromium.org"),
|
|
|
|
Cmd("git log -1 --format=%s rev4", "Title text 4"),
|
2017-07-03 13:14:55 +00:00
|
|
|
Cmd("git log -1 --format=%B rev4", "Title\n\nBUG=456\nLOG=N"),
|
2014-09-02 15:21:45 +00:00
|
|
|
Cmd("git log -1 --format=%an rev4", "author4@chromium.org"),
|
2013-11-22 07:56:00 +00:00
|
|
|
])
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
self._state["last_push_master"] = "1234"
|
2014-03-20 15:44:30 +00:00
|
|
|
self._state["push_hash"] = "push_hash"
|
2014-03-19 13:10:41 +00:00
|
|
|
self._state["version"] = "3.22.5"
|
2015-01-26 13:29:23 +00:00
|
|
|
self.RunStep(PushToCandidates, PrepareChangeLog)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
actual_cl = FileToText(TEST_CONFIG["CHANGELOG_ENTRY_FILE"])
|
2013-11-21 09:35:25 +00:00
|
|
|
|
2013-12-03 12:38:25 +00:00
|
|
|
expected_cl = """1999-07-31: Version 3.22.5
|
2013-11-21 09:35:25 +00:00
|
|
|
|
2013-11-25 14:20:39 +00:00
|
|
|
Title text 1.
|
2013-11-21 09:35:25 +00:00
|
|
|
|
2013-12-03 12:38:25 +00:00
|
|
|
Title text 3 (Chromium issue 321).
|
2013-11-21 09:35:25 +00:00
|
|
|
|
2013-12-03 12:38:25 +00:00
|
|
|
Performance and stability improvements on all platforms.
|
2013-11-21 09:35:25 +00:00
|
|
|
#
|
2013-12-03 12:38:25 +00:00
|
|
|
# The change log above is auto-generated. Please review if all relevant
|
|
|
|
# commit messages from the list below are included.
|
|
|
|
# All lines starting with # will be stripped.
|
2013-11-21 09:35:25 +00:00
|
|
|
#
|
2013-11-25 14:20:39 +00:00
|
|
|
# Title text 1.
|
2013-12-03 12:38:25 +00:00
|
|
|
# (author1@chromium.org)
|
2013-11-21 09:35:25 +00:00
|
|
|
#
|
2013-12-03 12:38:25 +00:00
|
|
|
# Title text 2 (Chromium issue 123).
|
|
|
|
# (author2@chromium.org)
|
2013-11-21 09:35:25 +00:00
|
|
|
#
|
2013-12-03 12:38:25 +00:00
|
|
|
# Title text 3 (Chromium issue 321).
|
|
|
|
# (author3@chromium.org)
|
2013-11-21 09:35:25 +00:00
|
|
|
#
|
2013-12-03 12:38:25 +00:00
|
|
|
# Title text 4 (Chromium issue 456).
|
|
|
|
# (author4@chromium.org)
|
2013-11-25 14:20:39 +00:00
|
|
|
#
|
2013-11-21 09:35:25 +00:00
|
|
|
#"""
|
|
|
|
|
2013-12-03 12:38:25 +00:00
|
|
|
self.assertEquals(expected_cl, actual_cl)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
|
|
|
def testEditChangeLog(self):
|
2014-09-23 14:41:36 +00:00
|
|
|
TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
|
|
|
|
TextToFile(" New \n\tLines \n", TEST_CONFIG["CHANGELOG_ENTRY_FILE"])
|
2013-11-08 14:27:16 +00:00
|
|
|
os.environ["EDITOR"] = "vi"
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2014-03-12 14:39:04 +00:00
|
|
|
RL(""), # Open editor.
|
2014-09-23 14:41:36 +00:00
|
|
|
Cmd("vi %s" % TEST_CONFIG["CHANGELOG_ENTRY_FILE"], ""),
|
2013-11-22 07:56:00 +00:00
|
|
|
])
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
self.RunStep(PushToCandidates, EditChangeLog)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-03-18 12:46:48 +00:00
|
|
|
self.assertEquals("New\n Lines",
|
2014-09-23 14:41:36 +00:00
|
|
|
FileToText(TEST_CONFIG["CHANGELOG_ENTRY_FILE"]))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2015-01-23 10:30:32 +00:00
|
|
|
TAGS = """
|
|
|
|
4425.0
|
|
|
|
0.0.0.0
|
|
|
|
3.9.6
|
|
|
|
3.22.4
|
|
|
|
test_tag
|
|
|
|
"""
|
2014-03-19 13:10:41 +00:00
|
|
|
|
2015-01-23 10:30:32 +00:00
|
|
|
# Version as tag: 3.22.4.0. Version on master: 3.22.6.
|
|
|
|
# Make sure that the latest version is 3.22.6.0.
|
2015-01-27 08:53:28 +00:00
|
|
|
def testIncrementVersion(self):
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2015-01-27 08:53:28 +00:00
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
2015-01-23 10:30:32 +00:00
|
|
|
Cmd("git tag", self.TAGS),
|
2015-02-26 08:59:17 +00:00
|
|
|
Cmd("git checkout -f origin/master -- include/v8-version.h",
|
2015-02-16 17:00:44 +00:00
|
|
|
"", cb=lambda: self.WriteFakeVersionFile(3, 22, 6)),
|
2013-11-22 07:56:00 +00:00
|
|
|
])
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2015-01-27 08:53:28 +00:00
|
|
|
self.RunStep(PushToCandidates, IncrementVersion)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2015-01-27 08:53:28 +00:00
|
|
|
self.assertEquals("3", self._state["new_major"])
|
|
|
|
self.assertEquals("22", self._state["new_minor"])
|
|
|
|
self.assertEquals("7", self._state["new_build"])
|
|
|
|
self.assertEquals("0", self._state["new_patch"])
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2013-12-11 15:05:53 +00:00
|
|
|
def _TestSquashCommits(self, change_log, expected_msg):
|
2014-09-23 14:41:36 +00:00
|
|
|
TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
|
|
|
|
with open(TEST_CONFIG["CHANGELOG_ENTRY_FILE"], "w") as f:
|
2013-12-11 15:05:53 +00:00
|
|
|
f.write(change_log)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2014-10-23 14:27:15 +00:00
|
|
|
Cmd("git diff origin/candidates hash1", "patch content"),
|
2013-11-22 07:56:00 +00:00
|
|
|
])
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-03-19 10:46:24 +00:00
|
|
|
self._state["push_hash"] = "hash1"
|
2014-02-19 11:56:48 +00:00
|
|
|
self._state["date"] = "1999-11-11"
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
self.RunStep(PushToCandidates, SquashCommits)
|
2014-09-23 14:41:36 +00:00
|
|
|
self.assertEquals(FileToText(TEST_CONFIG["COMMITMSG_FILE"]), expected_msg)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
patch = FileToText(TEST_CONFIG["PATCH_FILE"])
|
2013-11-08 14:27:16 +00:00
|
|
|
self.assertTrue(re.search(r"patch content", patch))
|
|
|
|
|
2013-12-11 15:05:53 +00:00
|
|
|
def testSquashCommitsUnformatted(self):
|
|
|
|
change_log = """1999-11-11: Version 3.22.5
|
|
|
|
|
|
|
|
Log text 1.
|
|
|
|
Chromium issue 12345
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms.\n"""
|
2014-10-29 14:19:59 +00:00
|
|
|
commit_msg = """Version 3.22.5 (based on hash1)
|
2013-12-11 15:05:53 +00:00
|
|
|
|
|
|
|
Log text 1. Chromium issue 12345
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms."""
|
|
|
|
self._TestSquashCommits(change_log, commit_msg)
|
|
|
|
|
|
|
|
def testSquashCommitsFormatted(self):
|
|
|
|
change_log = """1999-11-11: Version 3.22.5
|
|
|
|
|
|
|
|
Long commit message that fills more than 80 characters (Chromium issue
|
|
|
|
12345).
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms.\n"""
|
2014-10-29 14:19:59 +00:00
|
|
|
commit_msg = """Version 3.22.5 (based on hash1)
|
2013-12-11 15:05:53 +00:00
|
|
|
|
|
|
|
Long commit message that fills more than 80 characters (Chromium issue 12345).
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms."""
|
|
|
|
self._TestSquashCommits(change_log, commit_msg)
|
|
|
|
|
|
|
|
def testSquashCommitsQuotationMarks(self):
|
|
|
|
change_log = """Line with "quotation marks".\n"""
|
|
|
|
commit_msg = """Line with "quotation marks"."""
|
|
|
|
self._TestSquashCommits(change_log, commit_msg)
|
|
|
|
|
2014-11-03 09:31:13 +00:00
|
|
|
def testBootstrapper(self):
|
|
|
|
work_dir = self.MakeEmptyTempDirectory()
|
|
|
|
class FakeScript(ScriptsBase):
|
|
|
|
def _Steps(self):
|
|
|
|
return []
|
|
|
|
|
|
|
|
# Use the test configuration without the fake testing default work dir.
|
|
|
|
fake_config = dict(TEST_CONFIG)
|
|
|
|
del(fake_config["DEFAULT_CWD"])
|
|
|
|
|
|
|
|
self.Expect([
|
|
|
|
Cmd("fetch v8", "", cwd=work_dir),
|
|
|
|
])
|
|
|
|
FakeScript(fake_config, self).Run(["--work-dir", work_dir])
|
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
def _PushToCandidates(self, force=False, manual=False):
|
2014-09-19 13:37:34 +00:00
|
|
|
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
|
2014-03-19 13:10:41 +00:00
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
# The version file on master has build level 5, while the version
|
|
|
|
# file from candidates has build level 4.
|
2014-03-19 13:10:41 +00:00
|
|
|
self.WriteFakeVersionFile(build=5)
|
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
|
2015-01-26 13:29:23 +00:00
|
|
|
master_change_log = "2014-03-17: Sentinel\n"
|
|
|
|
TextToFile(master_change_log,
|
2014-11-10 11:52:00 +00:00
|
|
|
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
|
2013-11-08 14:27:16 +00:00
|
|
|
os.environ["EDITOR"] = "vi"
|
|
|
|
|
2015-01-23 14:58:49 +00:00
|
|
|
commit_msg_squashed = """Version 3.22.5 (squashed - based on push_hash)
|
|
|
|
|
|
|
|
Log text 1 (issue 321).
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms."""
|
|
|
|
|
|
|
|
commit_msg = """Version 3.22.5 (based on push_hash)
|
|
|
|
|
|
|
|
Log text 1 (issue 321).
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms."""
|
|
|
|
|
2014-03-15 13:06:08 +00:00
|
|
|
def ResetChangeLog():
|
2015-01-26 13:29:23 +00:00
|
|
|
"""On 'git co -b new_branch origin/candidates',
|
|
|
|
and 'git checkout -- ChangeLog',
|
|
|
|
the ChangLog will be reset to its content on candidates."""
|
|
|
|
candidates_change_log = """1999-04-05: Version 3.22.4
|
2014-03-15 13:06:08 +00:00
|
|
|
|
|
|
|
Performance and stability improvements on all platforms.\n"""
|
2015-01-26 13:29:23 +00:00
|
|
|
TextToFile(candidates_change_log,
|
2014-11-10 11:52:00 +00:00
|
|
|
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
|
2014-03-15 13:06:08 +00:00
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
def ResetToCandidates():
|
2014-03-19 10:46:24 +00:00
|
|
|
ResetChangeLog()
|
|
|
|
self.WriteFakeVersionFile()
|
|
|
|
|
2015-01-23 14:58:49 +00:00
|
|
|
def CheckVersionCommit():
|
2014-09-23 14:41:36 +00:00
|
|
|
commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
|
2015-01-23 14:58:49 +00:00
|
|
|
self.assertEquals(commit_msg, commit)
|
2014-09-23 09:35:49 +00:00
|
|
|
version = FileToText(
|
|
|
|
os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
|
2015-02-26 08:59:17 +00:00
|
|
|
self.assertTrue(re.search(r"#define V8_MINOR_VERSION\s+22", version))
|
|
|
|
self.assertTrue(re.search(r"#define V8_BUILD_NUMBER\s+5", version))
|
|
|
|
self.assertFalse(re.search(r"#define V8_BUILD_NUMBER\s+6", version))
|
|
|
|
self.assertTrue(re.search(r"#define V8_PATCH_LEVEL\s+0", version))
|
|
|
|
self.assertTrue(
|
|
|
|
re.search(r"#define V8_IS_CANDIDATE_VERSION\s+0", version))
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
# Check that the change log on the candidates branch got correctly
|
|
|
|
# modified.
|
2014-11-10 11:52:00 +00:00
|
|
|
change_log = FileToText(
|
|
|
|
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
|
2014-03-15 13:06:08 +00:00
|
|
|
self.assertEquals(
|
|
|
|
"""1999-07-31: Version 3.22.5
|
|
|
|
|
|
|
|
Log text 1 (issue 321).
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms.
|
|
|
|
|
|
|
|
|
|
|
|
1999-04-05: Version 3.22.4
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms.\n""",
|
|
|
|
change_log)
|
|
|
|
|
2013-12-04 08:47:18 +00:00
|
|
|
force_flag = " -f" if not manual else ""
|
2014-09-05 09:19:48 +00:00
|
|
|
expectations = []
|
|
|
|
if not force:
|
|
|
|
expectations.append(Cmd("which vi", "/usr/bin/vi"))
|
|
|
|
expectations += [
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git status -s -uno", ""),
|
2015-03-14 01:20:45 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
2014-10-29 14:19:59 +00:00
|
|
|
Cmd("git fetch", ""),
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git branch", " branch1\n* branch2\n"),
|
|
|
|
Cmd("git branch", " branch1\n* branch2\n"),
|
2014-10-29 14:19:59 +00:00
|
|
|
Cmd(("git new-branch %s --upstream origin/master" %
|
2015-01-28 10:08:53 +00:00
|
|
|
TEST_CONFIG["BRANCHNAME"]), ""),
|
2015-01-27 08:53:28 +00:00
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
2015-01-23 10:30:32 +00:00
|
|
|
Cmd("git tag", self.TAGS),
|
2015-02-26 08:59:17 +00:00
|
|
|
Cmd("git checkout -f origin/master -- include/v8-version.h",
|
2014-07-21 12:13:36 +00:00
|
|
|
"", cb=self.WriteFakeVersionFile),
|
2015-01-28 10:08:53 +00:00
|
|
|
Cmd("git log -1 --format=%H 3.22.4", "release_hash\n"),
|
|
|
|
Cmd("git log -1 --format=%s release_hash",
|
|
|
|
"Version 3.22.4 (based on abc3)\n"),
|
2014-10-29 14:19:59 +00:00
|
|
|
Cmd("git log --format=%H abc3..push_hash", "rev1\n"),
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git log -1 --format=%s rev1", "Log text 1.\n"),
|
|
|
|
Cmd("git log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
|
|
|
|
Cmd("git log -1 --format=%an rev1", "author1@chromium.org\n"),
|
2014-09-02 13:20:37 +00:00
|
|
|
]
|
2014-09-02 15:21:45 +00:00
|
|
|
if manual:
|
|
|
|
expectations.append(RL("")) # Open editor.
|
2014-09-02 13:20:37 +00:00
|
|
|
if not force:
|
2014-09-23 14:41:36 +00:00
|
|
|
expectations.append(
|
|
|
|
Cmd("vi %s" % TEST_CONFIG["CHANGELOG_ENTRY_FILE"], ""))
|
2014-09-02 13:20:37 +00:00
|
|
|
expectations += [
|
2014-10-29 14:19:59 +00:00
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git checkout -f origin/master", ""),
|
|
|
|
Cmd("git diff origin/candidates push_hash", "patch content\n"),
|
|
|
|
Cmd(("git new-branch %s --upstream origin/candidates" %
|
2015-01-26 13:29:23 +00:00
|
|
|
TEST_CONFIG["CANDIDATESBRANCH"]), "", cb=ResetToCandidates),
|
2014-09-23 14:41:36 +00:00
|
|
|
Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG["PATCH_FILE"], ""),
|
2015-01-23 15:30:17 +00:00
|
|
|
Cmd("git checkout -f origin/candidates -- ChangeLog", "",
|
|
|
|
cb=ResetChangeLog),
|
2015-02-26 08:59:17 +00:00
|
|
|
Cmd("git checkout -f origin/candidates -- include/v8-version.h", "",
|
2015-01-23 15:30:17 +00:00
|
|
|
cb=self.WriteFakeVersionFile),
|
2015-01-23 14:58:49 +00:00
|
|
|
Cmd("git commit -am \"%s\"" % commit_msg_squashed, ""),
|
|
|
|
]
|
|
|
|
if manual:
|
|
|
|
expectations.append(RL("Y")) # Sanity check.
|
|
|
|
expectations += [
|
|
|
|
Cmd("git cl land -f --bypass-hooks", ""),
|
|
|
|
Cmd("git checkout -f master", ""),
|
|
|
|
Cmd("git fetch", ""),
|
2015-01-26 13:29:23 +00:00
|
|
|
Cmd("git branch -D %s" % TEST_CONFIG["CANDIDATESBRANCH"], ""),
|
2015-01-23 14:58:49 +00:00
|
|
|
Cmd(("git new-branch %s --upstream origin/candidates" %
|
2015-01-26 13:29:23 +00:00
|
|
|
TEST_CONFIG["CANDIDATESBRANCH"]), "", cb=ResetToCandidates),
|
2014-09-23 14:41:36 +00:00
|
|
|
Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], "",
|
2015-01-23 14:58:49 +00:00
|
|
|
cb=CheckVersionCommit),
|
2014-11-13 09:22:45 +00:00
|
|
|
Cmd("git cl land -f --bypass-hooks", ""),
|
2014-10-29 14:19:59 +00:00
|
|
|
Cmd("git fetch", ""),
|
2014-10-29 14:58:03 +00:00
|
|
|
Cmd("git log -1 --format=%H --grep="
|
|
|
|
"\"Version 3.22.5 (based on push_hash)\""
|
2014-10-29 14:19:59 +00:00
|
|
|
" origin/candidates", "hsh_to_tag"),
|
|
|
|
Cmd("git tag 3.22.5 hsh_to_tag", ""),
|
2017-07-03 08:29:51 +00:00
|
|
|
Cmd("git push origin refs/tags/3.22.5:refs/tags/3.22.5", ""),
|
2015-03-14 01:20:45 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
2014-09-23 14:41:36 +00:00
|
|
|
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
2015-01-26 13:29:23 +00:00
|
|
|
Cmd("git branch -D %s" % TEST_CONFIG["CANDIDATESBRANCH"], ""),
|
2014-09-02 13:20:37 +00:00
|
|
|
]
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect(expectations)
|
2013-12-04 08:47:18 +00:00
|
|
|
|
2014-11-12 17:54:11 +00:00
|
|
|
args = ["-a", "author@chromium.org", "--revision", "push_hash"]
|
2014-02-26 15:13:31 +00:00
|
|
|
if force: args.append("-f")
|
|
|
|
if manual: args.append("-m")
|
|
|
|
else: args += ["-r", "reviewer@chromium.org"]
|
2015-01-26 13:29:23 +00:00
|
|
|
PushToCandidates(TEST_CONFIG, self).Run(args)
|
2013-11-08 14:27:16 +00:00
|
|
|
|
2014-11-10 11:52:00 +00:00
|
|
|
cl = FileToText(os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
|
2013-11-25 14:20:39 +00:00
|
|
|
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))
|
2013-11-08 14:27:16 +00:00
|
|
|
self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl))
|
|
|
|
|
|
|
|
# Note: The version file is on build number 5 again in the end of this test
|
2015-01-26 13:29:23 +00:00
|
|
|
# since the git command that merges to master is mocked out.
|
2013-11-20 08:49:42 +00:00
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
def testPushToCandidatesManual(self):
|
|
|
|
self._PushToCandidates(manual=True)
|
2013-12-04 08:47:18 +00:00
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
def testPushToCandidatesSemiAutomatic(self):
|
|
|
|
self._PushToCandidates()
|
2013-11-20 08:49:42 +00:00
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
def testPushToCandidatesForced(self):
|
|
|
|
self._PushToCandidates(force=True)
|
2013-11-22 07:56:00 +00:00
|
|
|
|
2015-01-30 16:46:41 +00:00
|
|
|
def testCreateRelease(self):
|
|
|
|
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
|
|
|
|
|
|
|
|
# The version file on master has build level 5.
|
|
|
|
self.WriteFakeVersionFile(build=5)
|
|
|
|
|
|
|
|
master_change_log = "2014-03-17: Sentinel\n"
|
|
|
|
TextToFile(master_change_log,
|
|
|
|
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
|
|
|
|
|
|
|
|
commit_msg = """Version 3.22.5
|
|
|
|
|
|
|
|
Log text 1 (issue 321).
|
|
|
|
|
2017-07-03 08:29:51 +00:00
|
|
|
Performance and stability improvements on all platforms.
|
|
|
|
|
|
|
|
TBR=reviewer@chromium.org"""
|
2015-01-30 16:46:41 +00:00
|
|
|
|
|
|
|
def ResetChangeLog():
|
|
|
|
last_change_log = """1999-04-05: Version 3.22.4
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms.\n"""
|
|
|
|
TextToFile(last_change_log,
|
|
|
|
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
|
|
|
|
|
|
|
|
|
|
|
|
def CheckVersionCommit():
|
|
|
|
commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
|
|
|
|
self.assertEquals(commit_msg, commit)
|
|
|
|
version = FileToText(
|
|
|
|
os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
|
2015-02-26 08:59:17 +00:00
|
|
|
self.assertTrue(re.search(r"#define V8_MINOR_VERSION\s+22", version))
|
|
|
|
self.assertTrue(re.search(r"#define V8_BUILD_NUMBER\s+5", version))
|
|
|
|
self.assertFalse(re.search(r"#define V8_BUILD_NUMBER\s+6", version))
|
|
|
|
self.assertTrue(re.search(r"#define V8_PATCH_LEVEL\s+0", version))
|
|
|
|
self.assertTrue(
|
|
|
|
re.search(r"#define V8_IS_CANDIDATE_VERSION\s+0", version))
|
2015-01-30 16:46:41 +00:00
|
|
|
|
|
|
|
# Check that the change log on the candidates branch got correctly
|
|
|
|
# modified.
|
|
|
|
change_log = FileToText(
|
|
|
|
os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
|
|
|
|
self.assertEquals(
|
|
|
|
"""1999-07-31: Version 3.22.5
|
|
|
|
|
|
|
|
Log text 1 (issue 321).
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms.
|
|
|
|
|
|
|
|
|
|
|
|
1999-04-05: Version 3.22.4
|
|
|
|
|
|
|
|
Performance and stability improvements on all platforms.\n""",
|
|
|
|
change_log)
|
|
|
|
|
|
|
|
expectations = [
|
2016-12-15 11:48:54 +00:00
|
|
|
Cmd("git fetch origin +refs/heads/*:refs/heads/*", ""),
|
2015-01-30 16:46:41 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
|
|
|
Cmd("git branch", ""),
|
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
|
|
|
Cmd("git tag", self.TAGS),
|
2015-02-26 08:59:17 +00:00
|
|
|
Cmd("git checkout -f origin/master -- include/v8-version.h",
|
2015-01-30 16:46:41 +00:00
|
|
|
"", cb=self.WriteFakeVersionFile),
|
|
|
|
Cmd("git log -1 --format=%H 3.22.4", "release_hash\n"),
|
2015-02-16 12:21:34 +00:00
|
|
|
Cmd("git log -1 --format=%s release_hash", "Version 3.22.4\n"),
|
|
|
|
Cmd("git log -1 --format=%H release_hash^", "abc3\n"),
|
2015-01-30 16:46:41 +00:00
|
|
|
Cmd("git log --format=%H abc3..push_hash", "rev1\n"),
|
|
|
|
Cmd("git log -1 --format=%s rev1", "Log text 1.\n"),
|
|
|
|
Cmd("git log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
|
|
|
|
Cmd("git log -1 --format=%an rev1", "author1@chromium.org\n"),
|
2016-12-15 11:48:54 +00:00
|
|
|
Cmd("git push origin push_hash:refs/heads/3.22.5", ""),
|
2015-01-30 16:46:41 +00:00
|
|
|
Cmd("git reset --hard origin/master", ""),
|
2016-12-15 11:48:54 +00:00
|
|
|
Cmd("git new-branch work-branch --upstream origin/3.22.5", ""),
|
2015-01-30 16:46:41 +00:00
|
|
|
Cmd("git checkout -f 3.22.4 -- ChangeLog", "", cb=ResetChangeLog),
|
2015-02-26 08:59:17 +00:00
|
|
|
Cmd("git checkout -f 3.22.4 -- include/v8-version.h", "",
|
2015-01-30 16:46:41 +00:00
|
|
|
cb=self.WriteFakeVersionFile),
|
2016-02-04 09:02:51 +00:00
|
|
|
Cmd("git checkout -f 3.22.4 -- WATCHLISTS", "",
|
|
|
|
cb=self.WriteFakeWatchlistsFile),
|
2015-01-30 16:46:41 +00:00
|
|
|
Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], "",
|
|
|
|
cb=CheckVersionCommit),
|
2017-07-03 08:29:51 +00:00
|
|
|
Cmd("git cl upload --send-mail --email \"author@chromium.org\" "
|
2017-07-10 14:10:34 +00:00
|
|
|
"-f --bypass-hooks --gerrit --private", ""),
|
2016-12-15 11:48:54 +00:00
|
|
|
Cmd("git cl land --bypass-hooks -f", ""),
|
2015-01-30 16:46:41 +00:00
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git log -1 --format=%H --grep="
|
2015-02-12 18:34:21 +00:00
|
|
|
"\"Version 3.22.5\" origin/3.22.5", "hsh_to_tag"),
|
2015-01-30 16:46:41 +00:00
|
|
|
Cmd("git tag 3.22.5 hsh_to_tag", ""),
|
2017-07-03 08:29:51 +00:00
|
|
|
Cmd("git push origin refs/tags/3.22.5:refs/tags/3.22.5", ""),
|
2015-01-30 16:46:41 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
|
|
|
Cmd("git branch", "* master\n work-branch\n"),
|
|
|
|
Cmd("git branch -D work-branch", ""),
|
|
|
|
Cmd("git gc", ""),
|
|
|
|
]
|
|
|
|
self.Expect(expectations)
|
|
|
|
|
|
|
|
args = ["-a", "author@chromium.org",
|
|
|
|
"-r", "reviewer@chromium.org",
|
|
|
|
"--revision", "push_hash"]
|
|
|
|
CreateRelease(TEST_CONFIG, self).Run(args)
|
|
|
|
|
|
|
|
cl = FileToText(os.path.join(TEST_CONFIG["DEFAULT_CWD"], 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))
|
|
|
|
|
|
|
|
# Note: The version file is on build number 5 again in the end of this test
|
|
|
|
# since the git command that merges to master is mocked out.
|
|
|
|
|
2016-02-04 09:02:51 +00:00
|
|
|
# Check for correct content of the WATCHLISTS file
|
|
|
|
|
|
|
|
watchlists_content = FileToText(os.path.join(TEST_CONFIG["DEFAULT_CWD"],
|
|
|
|
WATCHLISTS_FILE))
|
|
|
|
expected_watchlists_content = """
|
|
|
|
'merges': [
|
|
|
|
# Only enabled on branches created with tools/release/create_release.py
|
|
|
|
'v8-merges@googlegroups.com',
|
|
|
|
],
|
|
|
|
"""
|
|
|
|
self.assertEqual(watchlists_content, expected_watchlists_content)
|
|
|
|
|
2014-09-04 08:42:21 +00:00
|
|
|
C_V8_22624_LOG = """V8 CL.
|
|
|
|
|
|
|
|
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123
|
|
|
|
|
2014-09-04 09:56:29 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
C_V8_123455_LOG = """V8 CL.
|
|
|
|
|
|
|
|
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@123455 123
|
|
|
|
|
2014-09-04 08:42:21 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
C_V8_123456_LOG = """V8 CL.
|
|
|
|
|
|
|
|
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@123456 123
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2015-11-24 08:38:54 +00:00
|
|
|
ROLL_COMMIT_MSG = """Update V8 to version 3.22.4.
|
2015-02-20 08:50:39 +00:00
|
|
|
|
|
|
|
Summary of changes available at:
|
2015-03-05 10:50:00 +00:00
|
|
|
https://chromium.googlesource.com/v8/v8/+log/last_rol..roll_hsh
|
2015-02-20 08:50:39 +00:00
|
|
|
|
|
|
|
Please follow these instructions for assigning/CC'ing issues:
|
2015-11-30 13:55:03 +00:00
|
|
|
https://github.com/v8/v8/wiki/Triaging%20issues
|
2014-04-08 12:07:49 +00:00
|
|
|
|
2015-10-01 13:12:04 +00:00
|
|
|
Please close rolling in case of a roll revert:
|
|
|
|
https://v8-roll.appspot.com/
|
2015-10-30 09:09:12 +00:00
|
|
|
This only works with a Google account.
|
2015-10-01 13:12:04 +00:00
|
|
|
|
2017-03-06 21:26:39 +00:00
|
|
|
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel
|
2016-04-29 09:11:50 +00:00
|
|
|
|
2015-11-23 09:19:12 +00:00
|
|
|
TBR=reviewer@chromium.org"""
|
2015-02-20 08:50:39 +00:00
|
|
|
|
2015-11-24 08:38:54 +00:00
|
|
|
# Snippet from the original DEPS file.
|
|
|
|
FAKE_DEPS = """
|
|
|
|
vars = {
|
|
|
|
"v8_revision": "last_roll_hsh",
|
|
|
|
}
|
|
|
|
deps = {
|
|
|
|
"src/v8":
|
|
|
|
(Var("googlecode_url") % "v8") + "/" + Var("v8_branch") + "@" +
|
|
|
|
Var("v8_revision"),
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
def testChromiumRollUpToDate(self):
|
|
|
|
TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory()
|
2015-11-24 11:00:05 +00:00
|
|
|
json_output_file = os.path.join(TEST_CONFIG["CHROMIUM"], "out.json")
|
2015-11-24 08:38:54 +00:00
|
|
|
TextToFile(self.FAKE_DEPS, os.path.join(TEST_CONFIG["CHROMIUM"], "DEPS"))
|
|
|
|
self.Expect([
|
|
|
|
Cmd("git fetch origin", ""),
|
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
|
|
|
Cmd("git describe --tags last_roll_hsh", "3.22.4"),
|
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
2016-01-04 12:03:39 +00:00
|
|
|
Cmd("git rev-list --max-age=395200 --tags",
|
2015-11-24 08:38:54 +00:00
|
|
|
"bad_tag\nroll_hsh\nhash_123"),
|
|
|
|
Cmd("git describe --tags bad_tag", ""),
|
|
|
|
Cmd("git describe --tags roll_hsh", "3.22.4"),
|
|
|
|
Cmd("git describe --tags hash_123", "3.22.3"),
|
|
|
|
Cmd("git describe --tags roll_hsh", "3.22.4"),
|
|
|
|
Cmd("git describe --tags hash_123", "3.22.3"),
|
|
|
|
])
|
|
|
|
|
|
|
|
result = auto_roll.AutoRoll(TEST_CONFIG, self).Run(
|
2015-11-24 11:00:05 +00:00
|
|
|
AUTO_PUSH_ARGS + [
|
|
|
|
"-c", TEST_CONFIG["CHROMIUM"],
|
|
|
|
"--json-output", json_output_file])
|
2015-11-24 08:38:54 +00:00
|
|
|
self.assertEquals(0, result)
|
2015-11-24 11:00:05 +00:00
|
|
|
json_output = json.loads(FileToText(json_output_file))
|
|
|
|
self.assertEquals("up_to_date", json_output["monitoring_state"])
|
|
|
|
|
2015-11-24 08:38:54 +00:00
|
|
|
|
2015-02-20 08:50:39 +00:00
|
|
|
def testChromiumRoll(self):
|
2014-09-05 09:19:48 +00:00
|
|
|
# Setup fake directory structures.
|
2014-09-23 14:41:36 +00:00
|
|
|
TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory()
|
2015-11-24 11:00:05 +00:00
|
|
|
json_output_file = os.path.join(TEST_CONFIG["CHROMIUM"], "out.json")
|
2015-11-24 08:38:54 +00:00
|
|
|
TextToFile(self.FAKE_DEPS, os.path.join(TEST_CONFIG["CHROMIUM"], "DEPS"))
|
2014-09-23 14:41:36 +00:00
|
|
|
TextToFile("", os.path.join(TEST_CONFIG["CHROMIUM"], ".git"))
|
|
|
|
chrome_dir = TEST_CONFIG["CHROMIUM"]
|
2014-09-05 09:19:48 +00:00
|
|
|
os.makedirs(os.path.join(chrome_dir, "v8"))
|
|
|
|
|
2014-08-25 20:04:23 +00:00
|
|
|
def WriteDeps():
|
2014-09-04 08:42:21 +00:00
|
|
|
TextToFile("Some line\n \"v8_revision\": \"22624\",\n some line",
|
2014-09-05 09:19:48 +00:00
|
|
|
os.path.join(chrome_dir, "DEPS"))
|
2014-03-21 12:15:25 +00:00
|
|
|
|
2014-09-02 15:21:45 +00:00
|
|
|
expectations = [
|
2014-09-04 08:42:21 +00:00
|
|
|
Cmd("git fetch origin", ""),
|
2015-01-28 10:08:53 +00:00
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
2015-11-24 08:38:54 +00:00
|
|
|
Cmd("git describe --tags last_roll_hsh", "3.22.3.1"),
|
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
2016-01-04 12:03:39 +00:00
|
|
|
Cmd("git rev-list --max-age=395200 --tags",
|
2015-11-24 08:38:54 +00:00
|
|
|
"bad_tag\nroll_hsh\nhash_123"),
|
|
|
|
Cmd("git describe --tags bad_tag", ""),
|
|
|
|
Cmd("git describe --tags roll_hsh", "3.22.4"),
|
|
|
|
Cmd("git describe --tags hash_123", "3.22.3"),
|
|
|
|
Cmd("git describe --tags roll_hsh", "3.22.4"),
|
|
|
|
Cmd("git log -1 --format=%s roll_hsh", "Version 3.22.4\n"),
|
2015-03-05 10:50:00 +00:00
|
|
|
Cmd("git describe --tags roll_hsh", "3.22.4"),
|
2015-02-16 12:21:34 +00:00
|
|
|
Cmd("git describe --tags last_roll_hsh", "3.22.2.1"),
|
2014-09-05 09:19:48 +00:00
|
|
|
Cmd("git status -s -uno", "", cwd=chrome_dir),
|
|
|
|
Cmd("git checkout -f master", "", cwd=chrome_dir),
|
2015-04-09 21:37:33 +00:00
|
|
|
Cmd("git branch", "", cwd=chrome_dir),
|
2014-09-05 09:19:48 +00:00
|
|
|
Cmd("git pull", "", cwd=chrome_dir),
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git fetch origin", ""),
|
2015-04-09 21:37:33 +00:00
|
|
|
Cmd("git new-branch work-branch", "", cwd=chrome_dir),
|
2015-05-23 19:24:37 +00:00
|
|
|
Cmd("roll-dep-svn v8 roll_hsh", "rolled", cb=WriteDeps, cwd=chrome_dir),
|
2015-02-20 08:50:39 +00:00
|
|
|
Cmd(("git commit -am \"%s\" "
|
|
|
|
"--author \"author@chromium.org <author@chromium.org>\"" %
|
|
|
|
self.ROLL_COMMIT_MSG),
|
2014-09-05 09:19:48 +00:00
|
|
|
"", cwd=chrome_dir),
|
2015-11-24 08:38:54 +00:00
|
|
|
Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f "
|
2017-11-07 11:36:17 +00:00
|
|
|
"--cq-dry-run --bypass-hooks --gerrit", "",
|
|
|
|
cwd=chrome_dir),
|
2015-04-09 21:37:33 +00:00
|
|
|
Cmd("git checkout -f master", "", cwd=chrome_dir),
|
|
|
|
Cmd("git branch -D work-branch", "", cwd=chrome_dir),
|
2014-09-02 15:21:45 +00:00
|
|
|
]
|
|
|
|
self.Expect(expectations)
|
2014-03-21 12:15:25 +00:00
|
|
|
|
2014-09-05 09:19:48 +00:00
|
|
|
args = ["-a", "author@chromium.org", "-c", chrome_dir,
|
2015-11-24 11:00:05 +00:00
|
|
|
"-r", "reviewer@chromium.org", "--json-output", json_output_file]
|
2015-11-24 08:38:54 +00:00
|
|
|
auto_roll.AutoRoll(TEST_CONFIG, self).Run(args)
|
2014-03-21 12:15:25 +00:00
|
|
|
|
2014-09-05 09:19:48 +00:00
|
|
|
deps = FileToText(os.path.join(chrome_dir, "DEPS"))
|
2014-09-04 08:42:21 +00:00
|
|
|
self.assertTrue(re.search("\"v8_revision\": \"22624\"", deps))
|
2014-03-21 12:15:25 +00:00
|
|
|
|
2015-11-24 11:00:05 +00:00
|
|
|
json_output = json.loads(FileToText(json_output_file))
|
|
|
|
self.assertEquals("success", json_output["monitoring_state"])
|
|
|
|
|
2013-12-11 15:27:38 +00:00
|
|
|
def testCheckLastPushRecently(self):
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2015-01-28 10:08:53 +00:00
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
|
|
|
Cmd("git tag", self.TAGS),
|
|
|
|
Cmd("git log -1 --format=%H 3.22.4", "release_hash\n"),
|
|
|
|
Cmd("git log -1 --format=%s release_hash",
|
|
|
|
"Version 3.22.4 (based on abc3)\n"),
|
|
|
|
Cmd("git log --format=%H abc3..abc123", "\n"),
|
2013-12-11 15:27:38 +00:00
|
|
|
])
|
|
|
|
|
2014-11-26 15:23:35 +00:00
|
|
|
self._state["candidate"] = "abc123"
|
2014-10-31 13:14:58 +00:00
|
|
|
self.assertEquals(0, self.RunStep(
|
2015-01-28 10:08:53 +00:00
|
|
|
auto_push.AutoPush, LastReleaseBailout, AUTO_PUSH_ARGS))
|
2013-12-11 15:27:38 +00:00
|
|
|
|
2014-03-24 15:52:31 +00:00
|
|
|
def testAutoPush(self):
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2014-10-23 14:27:15 +00:00
|
|
|
Cmd("git fetch", ""),
|
2015-10-07 10:28:13 +00:00
|
|
|
Cmd("git fetch origin +refs/heads/lkgr:refs/heads/lkgr", ""),
|
|
|
|
Cmd("git show-ref -s refs/heads/lkgr", "abc123\n"),
|
2015-01-28 10:08:53 +00:00
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
|
|
|
Cmd("git tag", self.TAGS),
|
|
|
|
Cmd("git log -1 --format=%H 3.22.4", "release_hash\n"),
|
|
|
|
Cmd("git log -1 --format=%s release_hash",
|
|
|
|
"Version 3.22.4 (based on abc3)\n"),
|
|
|
|
Cmd("git log --format=%H abc3..abc123", "some_stuff\n"),
|
2013-11-22 07:56:00 +00:00
|
|
|
])
|
|
|
|
|
2014-11-12 17:54:11 +00:00
|
|
|
auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS + ["--push"])
|
2013-11-22 07:56:00 +00:00
|
|
|
|
2014-02-19 11:56:48 +00:00
|
|
|
state = json.loads(FileToText("%s-state.json"
|
2014-09-23 14:41:36 +00:00
|
|
|
% TEST_CONFIG["PERSISTFILE_BASENAME"]))
|
2014-02-19 11:56:48 +00:00
|
|
|
|
2014-11-26 15:23:35 +00:00
|
|
|
self.assertEquals("abc123", state["candidate"])
|
2013-11-25 14:20:39 +00:00
|
|
|
|
2016-07-22 09:27:41 +00:00
|
|
|
def testRollMerge(self):
|
2014-09-23 14:41:36 +00:00
|
|
|
TEST_CONFIG["ALREADY_MERGING_SENTINEL_FILE"] = self.MakeEmptyTempFile()
|
2014-09-19 13:37:34 +00:00
|
|
|
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
|
2014-03-19 13:10:41 +00:00
|
|
|
self.WriteFakeVersionFile(build=5)
|
2014-02-18 13:09:14 +00:00
|
|
|
os.environ["EDITOR"] = "vi"
|
|
|
|
extra_patch = self.MakeEmptyTempFile()
|
|
|
|
|
|
|
|
def VerifyPatch(patch):
|
|
|
|
return lambda: self.assertEquals(patch,
|
2014-09-23 14:41:36 +00:00
|
|
|
FileToText(TEST_CONFIG["TEMPORARY_PATCH_FILE"]))
|
2014-02-18 13:09:14 +00:00
|
|
|
|
2014-11-05 13:30:50 +00:00
|
|
|
msg = """Version 3.22.5.1 (cherry-pick)
|
2014-02-18 13:09:14 +00:00
|
|
|
|
2014-11-05 13:30:50 +00:00
|
|
|
Merged ab12345
|
|
|
|
Merged ab23456
|
|
|
|
Merged ab34567
|
|
|
|
Merged ab45678
|
|
|
|
Merged ab56789
|
2014-09-26 07:40:09 +00:00
|
|
|
|
|
|
|
Title4
|
|
|
|
|
|
|
|
Title2
|
|
|
|
|
|
|
|
Title3
|
|
|
|
|
|
|
|
Title1
|
|
|
|
|
|
|
|
Revert "Something"
|
|
|
|
|
|
|
|
BUG=123,234,345,456,567,v8:123
|
|
|
|
LOG=N
|
|
|
|
"""
|
|
|
|
|
2015-01-26 13:29:23 +00:00
|
|
|
def VerifyLand():
|
2014-09-26 07:40:09 +00:00
|
|
|
commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
|
|
|
|
self.assertEquals(msg, commit)
|
|
|
|
version = FileToText(
|
|
|
|
os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
|
2015-02-26 08:59:17 +00:00
|
|
|
self.assertTrue(re.search(r"#define V8_MINOR_VERSION\s+22", version))
|
|
|
|
self.assertTrue(re.search(r"#define V8_BUILD_NUMBER\s+5", version))
|
|
|
|
self.assertTrue(re.search(r"#define V8_PATCH_LEVEL\s+1", version))
|
|
|
|
self.assertTrue(
|
|
|
|
re.search(r"#define V8_IS_CANDIDATE_VERSION\s+0", version))
|
2014-09-26 07:40:09 +00:00
|
|
|
|
|
|
|
self.Expect([
|
|
|
|
Cmd("git status -s -uno", ""),
|
2015-03-14 01:20:45 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
2014-09-26 07:40:09 +00:00
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git branch", " branch1\n* branch2\n"),
|
2015-02-16 11:57:29 +00:00
|
|
|
Cmd("git new-branch %s --upstream refs/remotes/origin/candidates" %
|
2014-09-26 07:40:09 +00:00
|
|
|
TEST_CONFIG["BRANCHNAME"], ""),
|
2014-11-05 13:30:50 +00:00
|
|
|
Cmd(("git log --format=%H --grep=\"Port ab12345\" "
|
2014-09-26 07:40:09 +00:00
|
|
|
"--reverse origin/master"),
|
2014-11-05 13:30:50 +00:00
|
|
|
"ab45678\nab23456"),
|
|
|
|
Cmd("git log -1 --format=%s ab45678", "Title1"),
|
|
|
|
Cmd("git log -1 --format=%s ab23456", "Title2"),
|
|
|
|
Cmd(("git log --format=%H --grep=\"Port ab23456\" "
|
2014-09-26 07:40:09 +00:00
|
|
|
"--reverse origin/master"),
|
|
|
|
""),
|
2014-11-05 13:30:50 +00:00
|
|
|
Cmd(("git log --format=%H --grep=\"Port ab34567\" "
|
2014-09-26 07:40:09 +00:00
|
|
|
"--reverse origin/master"),
|
2014-11-05 13:30:50 +00:00
|
|
|
"ab56789"),
|
|
|
|
Cmd("git log -1 --format=%s ab56789", "Title3"),
|
|
|
|
RL("Y"), # Automatically add corresponding ports (ab34567, ab56789)?
|
|
|
|
# Simulate git being down which stops the script.
|
|
|
|
Cmd("git log -1 --format=%s ab12345", None),
|
2014-09-26 07:40:09 +00:00
|
|
|
# Restart script in the failing step.
|
2014-11-05 13:30:50 +00:00
|
|
|
Cmd("git log -1 --format=%s ab12345", "Title4"),
|
|
|
|
Cmd("git log -1 --format=%s ab23456", "Title2"),
|
|
|
|
Cmd("git log -1 --format=%s ab34567", "Title3"),
|
|
|
|
Cmd("git log -1 --format=%s ab45678", "Title1"),
|
|
|
|
Cmd("git log -1 --format=%s ab56789", "Revert \"Something\""),
|
|
|
|
Cmd("git log -1 ab12345", "Title4\nBUG=123\nBUG=234"),
|
|
|
|
Cmd("git log -1 ab23456", "Title2\n BUG = v8:123,345"),
|
|
|
|
Cmd("git log -1 ab34567", "Title3\nLOG=n\nBUG=567, 456"),
|
|
|
|
Cmd("git log -1 ab45678", "Title1\nBUG="),
|
|
|
|
Cmd("git log -1 ab56789", "Revert \"Something\"\nBUG=none"),
|
|
|
|
Cmd("git log -1 -p ab12345", "patch4"),
|
2014-09-26 07:40:09 +00:00
|
|
|
Cmd(("git apply --index --reject \"%s\"" %
|
|
|
|
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
|
|
|
|
"", cb=VerifyPatch("patch4")),
|
2014-11-05 13:30:50 +00:00
|
|
|
Cmd("git log -1 -p ab23456", "patch2"),
|
2014-09-26 07:40:09 +00:00
|
|
|
Cmd(("git apply --index --reject \"%s\"" %
|
|
|
|
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
|
|
|
|
"", cb=VerifyPatch("patch2")),
|
2014-11-05 13:30:50 +00:00
|
|
|
Cmd("git log -1 -p ab34567", "patch3"),
|
2014-09-26 07:40:09 +00:00
|
|
|
Cmd(("git apply --index --reject \"%s\"" %
|
|
|
|
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
|
|
|
|
"", cb=VerifyPatch("patch3")),
|
2014-11-05 13:30:50 +00:00
|
|
|
Cmd("git log -1 -p ab45678", "patch1"),
|
2014-09-26 07:40:09 +00:00
|
|
|
Cmd(("git apply --index --reject \"%s\"" %
|
|
|
|
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
|
|
|
|
"", cb=VerifyPatch("patch1")),
|
2014-11-05 13:30:50 +00:00
|
|
|
Cmd("git log -1 -p ab56789", "patch5\n"),
|
2014-09-26 07:40:09 +00:00
|
|
|
Cmd(("git apply --index --reject \"%s\"" %
|
|
|
|
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"], ""),
|
|
|
|
RL("reviewer@chromium.org"), # V8 reviewer.
|
|
|
|
Cmd("git cl upload --send-mail -r \"reviewer@chromium.org\" "
|
2017-07-06 11:16:51 +00:00
|
|
|
"--bypass-hooks --cc \"ulan@chromium.org\" --gerrit", ""),
|
2014-09-26 07:40:09 +00:00
|
|
|
Cmd("git checkout -f %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
|
|
|
RL("LGTM"), # Enter LGTM for V8 CL.
|
|
|
|
Cmd("git cl presubmit", "Presubmit successfull\n"),
|
2014-11-12 17:54:11 +00:00
|
|
|
Cmd("git cl land -f --bypass-hooks", "Closing issue\n",
|
2015-01-26 13:29:23 +00:00
|
|
|
cb=VerifyLand),
|
2014-10-07 10:46:04 +00:00
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git log -1 --format=%H --grep=\""
|
2014-11-05 13:30:50 +00:00
|
|
|
"Version 3.22.5.1 (cherry-pick)"
|
2015-02-16 11:57:29 +00:00
|
|
|
"\" refs/remotes/origin/candidates",
|
2014-10-07 10:46:04 +00:00
|
|
|
""),
|
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git log -1 --format=%H --grep=\""
|
2014-11-05 13:30:50 +00:00
|
|
|
"Version 3.22.5.1 (cherry-pick)"
|
2015-02-16 11:57:29 +00:00
|
|
|
"\" refs/remotes/origin/candidates",
|
2014-10-07 10:46:04 +00:00
|
|
|
"hsh_to_tag"),
|
|
|
|
Cmd("git tag 3.22.5.1 hsh_to_tag", ""),
|
2017-07-03 08:29:51 +00:00
|
|
|
Cmd("git push origin refs/tags/3.22.5.1:refs/tags/3.22.5.1", ""),
|
2015-03-14 01:20:45 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
2014-09-26 07:40:09 +00:00
|
|
|
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
|
|
|
])
|
|
|
|
|
2016-07-22 09:27:41 +00:00
|
|
|
# ab12345 and ab34567 are patches. ab23456 (included) and ab45678 are the
|
|
|
|
# MIPS ports of ab12345. ab56789 is the MIPS port of ab34567.
|
|
|
|
args = ["-f", "-p", extra_patch, "--branch", "candidates",
|
|
|
|
"ab12345", "ab23456", "ab34567"]
|
|
|
|
|
|
|
|
# The first run of the script stops because of git being down.
|
|
|
|
self.assertRaises(GitFailedException,
|
|
|
|
lambda: RollMerge(TEST_CONFIG, self).Run(args))
|
|
|
|
|
|
|
|
# Test that state recovery after restarting the script works.
|
|
|
|
args += ["-s", "4"]
|
|
|
|
RollMerge(TEST_CONFIG, self).Run(args)
|
|
|
|
|
|
|
|
def testReleases(self):
|
|
|
|
c_hash1_commit_log = """Update V8 to Version 4.2.71.
|
|
|
|
|
|
|
|
Cr-Commit-Position: refs/heads/master@{#5678}
|
|
|
|
"""
|
|
|
|
c_hash2_commit_log = """Revert something.
|
|
|
|
|
|
|
|
BUG=12345
|
|
|
|
|
|
|
|
Reason:
|
|
|
|
> Some reason.
|
|
|
|
> Cr-Commit-Position: refs/heads/master@{#12345}
|
|
|
|
> git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12345 003-1c4
|
|
|
|
|
|
|
|
Review URL: https://codereview.chromium.org/12345
|
|
|
|
|
|
|
|
Cr-Commit-Position: refs/heads/master@{#4567}
|
|
|
|
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4567 0039-1c4b
|
|
|
|
|
|
|
|
"""
|
|
|
|
c_hash3_commit_log = """Simple.
|
|
|
|
|
|
|
|
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
|
|
|
|
|
|
|
|
"""
|
|
|
|
c_hash_234_commit_log = """Version 3.3.1.1 (cherry-pick).
|
|
|
|
|
|
|
|
Merged abc12.
|
|
|
|
|
|
|
|
Review URL: fake.com
|
|
|
|
|
|
|
|
Cr-Commit-Position: refs/heads/candidates@{#234}
|
|
|
|
"""
|
|
|
|
c_hash_123_commit_log = """Version 3.3.1.0
|
|
|
|
|
|
|
|
git-svn-id: googlecode@123 0039-1c4b
|
|
|
|
"""
|
|
|
|
c_hash_345_commit_log = """Version 3.4.0.
|
|
|
|
|
|
|
|
Cr-Commit-Position: refs/heads/candidates@{#345}
|
|
|
|
"""
|
|
|
|
c_hash_456_commit_log = """Version 4.2.71.
|
|
|
|
|
|
|
|
Cr-Commit-Position: refs/heads/4.2.71@{#1}
|
|
|
|
"""
|
|
|
|
c_deps = "Line\n \"v8_revision\": \"%s\",\n line\n"
|
|
|
|
|
|
|
|
json_output = self.MakeEmptyTempFile()
|
|
|
|
csv_output = self.MakeEmptyTempFile()
|
|
|
|
self.WriteFakeVersionFile()
|
|
|
|
|
|
|
|
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 ResetVersion(major, minor, build, patch=0):
|
|
|
|
return lambda: self.WriteFakeVersionFile(major=major,
|
|
|
|
minor=minor,
|
|
|
|
build=build,
|
|
|
|
patch=patch)
|
|
|
|
|
|
|
|
self.Expect([
|
|
|
|
Cmd("git status -s -uno", ""),
|
|
|
|
Cmd("git checkout -f origin/master", ""),
|
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git branch", " branch1\n* branch2\n"),
|
|
|
|
Cmd("git new-branch %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
|
|
|
Cmd("git rev-list --max-age=395200 --tags",
|
|
|
|
"bad_tag\nhash_234\nhash_123\nhash_345\nhash_456\n"),
|
|
|
|
Cmd("git describe --tags bad_tag", "3.23.42-1-deadbeef"),
|
|
|
|
Cmd("git describe --tags hash_234", "3.3.1.1"),
|
|
|
|
Cmd("git describe --tags hash_123", "3.21.2"),
|
|
|
|
Cmd("git describe --tags hash_345", "3.22.3"),
|
|
|
|
Cmd("git describe --tags hash_456", "4.2.71"),
|
|
|
|
Cmd("git diff --name-only hash_234 hash_234^", VERSION_FILE),
|
|
|
|
Cmd("git checkout -f hash_234 -- %s" % VERSION_FILE, "",
|
|
|
|
cb=ResetVersion(3, 3, 1, 1)),
|
|
|
|
Cmd("git branch -r --contains hash_234", " branch-heads/3.3\n"),
|
|
|
|
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
|
|
|
|
Cmd("git log -1 --format=%s hash_234", ""),
|
|
|
|
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
|
|
|
|
Cmd("git log -1 --format=%ci hash_234", "18:15"),
|
|
|
|
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
|
|
|
|
cb=ResetVersion(3, 22, 5)),
|
|
|
|
Cmd("git diff --name-only hash_123 hash_123^", VERSION_FILE),
|
|
|
|
Cmd("git checkout -f hash_123 -- %s" % VERSION_FILE, "",
|
|
|
|
cb=ResetVersion(3, 21, 2)),
|
|
|
|
Cmd("git branch -r --contains hash_123", " branch-heads/3.21\n"),
|
|
|
|
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
|
|
|
|
Cmd("git log -1 --format=%s hash_123", ""),
|
|
|
|
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
|
|
|
|
Cmd("git log -1 --format=%ci hash_123", "03:15"),
|
|
|
|
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
|
|
|
|
cb=ResetVersion(3, 22, 5)),
|
|
|
|
Cmd("git diff --name-only hash_345 hash_345^", VERSION_FILE),
|
|
|
|
Cmd("git checkout -f hash_345 -- %s" % VERSION_FILE, "",
|
|
|
|
cb=ResetVersion(3, 22, 3)),
|
|
|
|
Cmd("git branch -r --contains hash_345", " origin/candidates\n"),
|
|
|
|
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
|
|
|
|
Cmd("git log -1 --format=%s hash_345", ""),
|
|
|
|
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
|
|
|
|
Cmd("git log -1 --format=%ci hash_345", ""),
|
|
|
|
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
|
|
|
|
cb=ResetVersion(3, 22, 5)),
|
|
|
|
Cmd("git diff --name-only hash_456 hash_456^", VERSION_FILE),
|
|
|
|
Cmd("git checkout -f hash_456 -- %s" % VERSION_FILE, "",
|
|
|
|
cb=ResetVersion(4, 2, 71)),
|
|
|
|
Cmd("git branch -r --contains hash_456", " origin/4.2.71\n"),
|
|
|
|
Cmd("git log -1 --format=%B hash_456", c_hash_456_commit_log),
|
|
|
|
Cmd("git log -1 --format=%H 4.2.71", "hash_456"),
|
|
|
|
Cmd("git log -1 --format=%s hash_456", "Version 4.2.71"),
|
|
|
|
Cmd("git log -1 --format=%H hash_456^", "master_456"),
|
|
|
|
Cmd("git log -1 --format=%B master_456",
|
|
|
|
"Cr-Commit-Position: refs/heads/master@{#456}"),
|
|
|
|
Cmd("git log -1 --format=%B hash_456", c_hash_456_commit_log),
|
|
|
|
Cmd("git log -1 --format=%ci hash_456", "02:15"),
|
|
|
|
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
|
|
|
|
cb=ResetVersion(3, 22, 5)),
|
|
|
|
Cmd("git fetch origin +refs/heads/*:refs/remotes/origin/* "
|
|
|
|
"+refs/branch-heads/*:refs/remotes/branch-heads/*", "",
|
|
|
|
cwd=chrome_dir),
|
|
|
|
Cmd("git fetch origin", "", cwd=chrome_v8_dir),
|
|
|
|
Cmd("git log --format=%H --grep=\"V8\" origin/master -- DEPS",
|
|
|
|
"c_hash1\nc_hash2\nc_hash3\n",
|
|
|
|
cwd=chrome_dir),
|
|
|
|
Cmd("git show c_hash1:DEPS", c_deps % "hash_456", cwd=chrome_dir),
|
|
|
|
Cmd("git log -1 --format=%B c_hash1", c_hash1_commit_log,
|
|
|
|
cwd=chrome_dir),
|
|
|
|
Cmd("git show c_hash2:DEPS", c_deps % "hash_345", cwd=chrome_dir),
|
|
|
|
Cmd("git log -1 --format=%B c_hash2", c_hash2_commit_log,
|
|
|
|
cwd=chrome_dir),
|
|
|
|
Cmd("git show c_hash3:DEPS", c_deps % "deadbeef", cwd=chrome_dir),
|
|
|
|
Cmd("git log -1 --format=%B c_hash3", c_hash3_commit_log,
|
|
|
|
cwd=chrome_dir),
|
|
|
|
Cmd("git branch -r", " weird/123\n branch-heads/7\n", cwd=chrome_dir),
|
|
|
|
Cmd("git show refs/branch-heads/7:DEPS", c_deps % "hash_345",
|
|
|
|
cwd=chrome_dir),
|
|
|
|
URL("http://omahaproxy.appspot.com/all.json", """[{
|
|
|
|
"os": "win",
|
|
|
|
"versions": [{
|
|
|
|
"version": "2.2.2.2",
|
|
|
|
"v8_version": "22.2.2.2",
|
|
|
|
"current_reldate": "04/09/15",
|
|
|
|
"os": "win",
|
|
|
|
"channel": "canary",
|
|
|
|
"previous_version": "1.1.1.0"
|
|
|
|
}]
|
|
|
|
}]"""),
|
|
|
|
URL("http://omahaproxy.appspot.com/v8.json?version=1.1.1.0", """{
|
|
|
|
"chromium_version": "1.1.1.0",
|
|
|
|
"v8_version": "11.1.1.0"
|
|
|
|
}"""),
|
|
|
|
Cmd("git rev-list -1 11.1.1", "v8_previous_version_hash"),
|
|
|
|
Cmd("git rev-list -1 22.2.2.2", "v8_version_hash"),
|
|
|
|
Cmd("git checkout -f origin/master", ""),
|
|
|
|
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], "")
|
|
|
|
])
|
|
|
|
|
|
|
|
args = ["-c", TEST_CONFIG["CHROMIUM"],
|
|
|
|
"--json", json_output,
|
|
|
|
"--csv", csv_output,
|
|
|
|
"--max-releases", "1"]
|
|
|
|
Releases(TEST_CONFIG, self).Run(args)
|
|
|
|
|
|
|
|
# Check expected output.
|
|
|
|
csv = ("4.2.71,4.2.71,1,5678,\r\n"
|
|
|
|
"3.22.3,candidates,345,4567:5677,\r\n"
|
|
|
|
"3.21.2,3.21,123,,\r\n"
|
|
|
|
"3.3.1.1,3.3,234,,abc12\r\n")
|
|
|
|
self.assertEquals(csv, FileToText(csv_output))
|
|
|
|
|
|
|
|
expected_json = {"chrome_releases":{
|
|
|
|
"canaries": [
|
|
|
|
{
|
|
|
|
"chrome_version": "2.2.2.2",
|
|
|
|
"os": "win",
|
|
|
|
"release_date": "04/09/15",
|
|
|
|
"v8_version": "22.2.2.2",
|
|
|
|
"v8_version_hash": "v8_version_hash",
|
|
|
|
"v8_previous_version": "11.1.1.0",
|
|
|
|
"v8_previous_version_hash": "v8_previous_version_hash"
|
|
|
|
}]},
|
|
|
|
"releases":[
|
|
|
|
{
|
|
|
|
"revision": "1",
|
|
|
|
"revision_git": "hash_456",
|
|
|
|
"master_position": "456",
|
|
|
|
"master_hash": "master_456",
|
|
|
|
"patches_merged": "",
|
|
|
|
"version": "4.2.71",
|
|
|
|
"chromium_revision": "5678",
|
|
|
|
"branch": "4.2.71",
|
|
|
|
"review_link": "",
|
|
|
|
"date": "02:15",
|
|
|
|
"chromium_branch": "",
|
|
|
|
# FIXME(machenbach): Fix revisions link for git.
|
|
|
|
"revision_link": "https://code.google.com/p/v8/source/detail?r=1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"revision": "345",
|
|
|
|
"revision_git": "hash_345",
|
|
|
|
"master_position": "",
|
|
|
|
"master_hash": "",
|
|
|
|
"patches_merged": "",
|
|
|
|
"version": "3.22.3",
|
|
|
|
"chromium_revision": "4567:5677",
|
|
|
|
"branch": "candidates",
|
|
|
|
"review_link": "",
|
|
|
|
"date": "",
|
|
|
|
"chromium_branch": "7",
|
|
|
|
"revision_link": "https://code.google.com/p/v8/source/detail?r=345",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"revision": "123",
|
|
|
|
"revision_git": "hash_123",
|
|
|
|
"patches_merged": "",
|
|
|
|
"master_position": "",
|
|
|
|
"master_hash": "",
|
|
|
|
"version": "3.21.2",
|
|
|
|
"chromium_revision": "",
|
|
|
|
"branch": "3.21",
|
|
|
|
"review_link": "",
|
|
|
|
"date": "03:15",
|
|
|
|
"chromium_branch": "",
|
|
|
|
"revision_link": "https://code.google.com/p/v8/source/detail?r=123",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"revision": "234",
|
|
|
|
"revision_git": "hash_234",
|
|
|
|
"patches_merged": "abc12",
|
|
|
|
"master_position": "",
|
|
|
|
"master_hash": "",
|
|
|
|
"version": "3.3.1.1",
|
|
|
|
"chromium_revision": "",
|
|
|
|
"branch": "3.3",
|
|
|
|
"review_link": "fake.com",
|
|
|
|
"date": "18:15",
|
|
|
|
"chromium_branch": "",
|
|
|
|
"revision_link": "https://code.google.com/p/v8/source/detail?r=234",
|
|
|
|
},],
|
|
|
|
}
|
|
|
|
self.assertEquals(expected_json, json.loads(FileToText(json_output)))
|
|
|
|
|
|
|
|
def testMergeToBranch(self):
|
|
|
|
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"
|
|
|
|
extra_patch = self.MakeEmptyTempFile()
|
|
|
|
|
|
|
|
|
|
|
|
def VerifyPatch(patch):
|
|
|
|
return lambda: self.assertEquals(patch,
|
|
|
|
FileToText(TEST_CONFIG["TEMPORARY_PATCH_FILE"]))
|
|
|
|
|
|
|
|
info_msg = ("NOTE: This script will no longer automatically "
|
|
|
|
"update include/v8-version.h "
|
|
|
|
"and create a tag. This is done automatically by the autotag bot. "
|
|
|
|
"Please call the merge_to_branch.py with --help for more information.")
|
|
|
|
|
|
|
|
msg = """Merged: Squashed multiple commits.
|
|
|
|
|
|
|
|
Merged: Title4
|
|
|
|
Revision: ab12345
|
|
|
|
|
|
|
|
Merged: Title2
|
|
|
|
Revision: ab23456
|
|
|
|
|
|
|
|
Merged: Title3
|
|
|
|
Revision: ab34567
|
|
|
|
|
|
|
|
Merged: Title1
|
|
|
|
Revision: ab45678
|
|
|
|
|
|
|
|
Merged: Revert \"Something\"
|
|
|
|
Revision: ab56789
|
|
|
|
|
|
|
|
BUG=123,234,345,456,567,v8:123
|
|
|
|
LOG=N
|
|
|
|
NOTRY=true
|
|
|
|
NOPRESUBMIT=true
|
|
|
|
NOTREECHECKS=true
|
|
|
|
"""
|
|
|
|
|
|
|
|
def VerifyLand():
|
|
|
|
commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
|
|
|
|
self.assertEquals(msg, commit)
|
|
|
|
|
|
|
|
self.Expect([
|
|
|
|
Cmd("git status -s -uno", ""),
|
|
|
|
Cmd("git checkout -f origin/master", ""),
|
|
|
|
Cmd("git fetch", ""),
|
|
|
|
Cmd("git branch", " branch1\n* branch2\n"),
|
|
|
|
Cmd("git new-branch %s --upstream refs/remotes/origin/candidates" %
|
|
|
|
TEST_CONFIG["BRANCHNAME"], ""),
|
|
|
|
Cmd(("git log --format=%H --grep=\"^[Pp]ort ab12345\" "
|
|
|
|
"--reverse origin/master"),
|
|
|
|
"ab45678\nab23456"),
|
|
|
|
Cmd("git log -1 --format=%s ab45678", "Title1"),
|
|
|
|
Cmd("git log -1 --format=%s ab23456", "Title2"),
|
|
|
|
Cmd(("git log --format=%H --grep=\"^[Pp]ort ab23456\" "
|
|
|
|
"--reverse origin/master"),
|
|
|
|
""),
|
|
|
|
Cmd(("git log --format=%H --grep=\"^[Pp]ort ab34567\" "
|
|
|
|
"--reverse origin/master"),
|
|
|
|
"ab56789"),
|
|
|
|
Cmd("git log -1 --format=%s ab56789", "Title3"),
|
|
|
|
RL("Y"), # Automatically add corresponding ports (ab34567, ab56789)?
|
|
|
|
# Simulate git being down which stops the script.
|
|
|
|
Cmd("git log -1 --format=%s ab12345", None),
|
|
|
|
# Restart script in the failing step.
|
|
|
|
Cmd("git log -1 --format=%s ab12345", "Title4"),
|
|
|
|
Cmd("git log -1 --format=%s ab23456", "Title2"),
|
|
|
|
Cmd("git log -1 --format=%s ab34567", "Title3"),
|
|
|
|
Cmd("git log -1 --format=%s ab45678", "Title1"),
|
|
|
|
Cmd("git log -1 --format=%s ab56789", "Revert \"Something\""),
|
|
|
|
Cmd("git log -1 ab12345", "Title4\nBUG=123\nBUG=234"),
|
|
|
|
Cmd("git log -1 ab23456", "Title2\n BUG = v8:123,345"),
|
2017-06-13 09:59:42 +00:00
|
|
|
Cmd("git log -1 ab34567", "Title3\nLOG=n\nBug: 567, 456,345"),
|
|
|
|
Cmd("git log -1 ab45678", "Title1\nBug:"),
|
2016-07-22 09:27:41 +00:00
|
|
|
Cmd("git log -1 ab56789", "Revert \"Something\"\nBUG=none"),
|
|
|
|
Cmd("git log -1 -p ab12345", "patch4"),
|
|
|
|
Cmd(("git apply --index --reject \"%s\"" %
|
|
|
|
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
|
|
|
|
"", cb=VerifyPatch("patch4")),
|
|
|
|
Cmd("git log -1 -p ab23456", "patch2"),
|
|
|
|
Cmd(("git apply --index --reject \"%s\"" %
|
|
|
|
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
|
|
|
|
"", cb=VerifyPatch("patch2")),
|
|
|
|
Cmd("git log -1 -p ab34567", "patch3"),
|
|
|
|
Cmd(("git apply --index --reject \"%s\"" %
|
|
|
|
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
|
|
|
|
"", cb=VerifyPatch("patch3")),
|
|
|
|
Cmd("git log -1 -p ab45678", "patch1"),
|
|
|
|
Cmd(("git apply --index --reject \"%s\"" %
|
|
|
|
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
|
|
|
|
"", cb=VerifyPatch("patch1")),
|
|
|
|
Cmd("git log -1 -p ab56789", "patch5\n"),
|
|
|
|
Cmd(("git apply --index --reject \"%s\"" %
|
|
|
|
TEST_CONFIG["TEMPORARY_PATCH_FILE"]),
|
|
|
|
"", cb=VerifyPatch("patch5\n")),
|
|
|
|
Cmd("git apply --index --reject \"%s\"" % extra_patch, ""),
|
|
|
|
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\" "
|
2017-07-06 11:16:51 +00:00
|
|
|
"--bypass-hooks --cc \"ulan@chromium.org\" --gerrit", ""),
|
2016-07-22 09:27:41 +00:00
|
|
|
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 land -f --bypass-hooks", "Closing issue\n",
|
|
|
|
cb=VerifyLand),
|
|
|
|
Cmd("git checkout -f origin/master", ""),
|
|
|
|
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
|
|
|
])
|
|
|
|
|
2014-11-05 13:30:50 +00:00
|
|
|
# ab12345 and ab34567 are patches. ab23456 (included) and ab45678 are the
|
|
|
|
# MIPS ports of ab12345. ab56789 is the MIPS port of ab34567.
|
2014-09-26 07:40:09 +00:00
|
|
|
args = ["-f", "-p", extra_patch, "--branch", "candidates",
|
2014-11-05 13:30:50 +00:00
|
|
|
"ab12345", "ab23456", "ab34567"]
|
2014-02-19 11:56:48 +00:00
|
|
|
|
2014-11-05 13:30:50 +00:00
|
|
|
# The first run of the script stops because of git being down.
|
2014-02-20 16:39:41 +00:00
|
|
|
self.assertRaises(GitFailedException,
|
2014-03-04 23:27:27 +00:00
|
|
|
lambda: MergeToBranch(TEST_CONFIG, self).Run(args))
|
2014-02-19 11:56:48 +00:00
|
|
|
|
|
|
|
# Test that state recovery after restarting the script works.
|
2014-11-03 09:31:13 +00:00
|
|
|
args += ["-s", "4"]
|
2014-03-04 23:27:27 +00:00
|
|
|
MergeToBranch(TEST_CONFIG, self).Run(args)
|
2014-02-18 13:09:14 +00:00
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
def testReleases(self):
|
2015-02-16 17:00:44 +00:00
|
|
|
c_hash1_commit_log = """Update V8 to Version 4.2.71.
|
|
|
|
|
|
|
|
Cr-Commit-Position: refs/heads/master@{#5678}
|
|
|
|
"""
|
2014-08-22 14:30:37 +00:00
|
|
|
c_hash2_commit_log = """Revert something.
|
|
|
|
|
|
|
|
BUG=12345
|
|
|
|
|
|
|
|
Reason:
|
|
|
|
> Some reason.
|
|
|
|
> Cr-Commit-Position: refs/heads/master@{#12345}
|
|
|
|
> git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12345 003-1c4
|
|
|
|
|
|
|
|
Review URL: https://codereview.chromium.org/12345
|
|
|
|
|
|
|
|
Cr-Commit-Position: refs/heads/master@{#4567}
|
|
|
|
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4567 0039-1c4b
|
|
|
|
|
|
|
|
"""
|
|
|
|
c_hash3_commit_log = """Simple.
|
|
|
|
|
|
|
|
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3456 0039-1c4b
|
|
|
|
|
2014-07-28 13:49:07 +00:00
|
|
|
"""
|
2014-11-12 17:54:11 +00:00
|
|
|
c_hash_234_commit_log = """Version 3.3.1.1 (cherry-pick).
|
|
|
|
|
|
|
|
Merged abc12.
|
|
|
|
|
|
|
|
Review URL: fake.com
|
|
|
|
|
|
|
|
Cr-Commit-Position: refs/heads/candidates@{#234}
|
|
|
|
"""
|
|
|
|
c_hash_123_commit_log = """Version 3.3.1.0
|
|
|
|
|
|
|
|
git-svn-id: googlecode@123 0039-1c4b
|
|
|
|
"""
|
|
|
|
c_hash_345_commit_log = """Version 3.4.0.
|
|
|
|
|
|
|
|
Cr-Commit-Position: refs/heads/candidates@{#345}
|
2015-02-16 17:00:44 +00:00
|
|
|
"""
|
|
|
|
c_hash_456_commit_log = """Version 4.2.71.
|
|
|
|
|
|
|
|
Cr-Commit-Position: refs/heads/4.2.71@{#1}
|
2014-11-12 17:54:11 +00:00
|
|
|
"""
|
2015-04-07 19:42:32 +00:00
|
|
|
c_deps = "Line\n \"v8_revision\": \"%s\",\n line\n"
|
2014-11-12 17:54:11 +00:00
|
|
|
|
2014-04-09 14:30:02 +00:00
|
|
|
json_output = self.MakeEmptyTempFile()
|
|
|
|
csv_output = self.MakeEmptyTempFile()
|
|
|
|
self.WriteFakeVersionFile()
|
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
TEST_CONFIG["CHROMIUM"] = self.MakeEmptyTempDirectory()
|
|
|
|
chrome_dir = TEST_CONFIG["CHROMIUM"]
|
2014-09-05 09:19:48 +00:00
|
|
|
chrome_v8_dir = os.path.join(chrome_dir, "v8")
|
|
|
|
os.makedirs(chrome_v8_dir)
|
2014-04-09 14:30:02 +00:00
|
|
|
|
2015-02-16 17:00:44 +00:00
|
|
|
def ResetVersion(major, minor, build, patch=0):
|
|
|
|
return lambda: self.WriteFakeVersionFile(major=major,
|
|
|
|
minor=minor,
|
2014-04-09 14:30:02 +00:00
|
|
|
build=build,
|
|
|
|
patch=patch)
|
|
|
|
|
2014-09-02 15:21:45 +00:00
|
|
|
self.Expect([
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git status -s -uno", ""),
|
2015-03-14 01:20:45 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
2014-10-16 13:21:13 +00:00
|
|
|
Cmd("git fetch", ""),
|
2014-09-02 12:51:30 +00:00
|
|
|
Cmd("git branch", " branch1\n* branch2\n"),
|
2014-10-28 13:42:58 +00:00
|
|
|
Cmd("git new-branch %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
2015-01-29 14:21:31 +00:00
|
|
|
Cmd("git fetch origin +refs/tags/*:refs/tags/*", ""),
|
|
|
|
Cmd("git rev-list --max-age=395200 --tags",
|
2015-02-16 17:00:44 +00:00
|
|
|
"bad_tag\nhash_234\nhash_123\nhash_345\nhash_456\n"),
|
2015-01-29 14:21:31 +00:00
|
|
|
Cmd("git describe --tags bad_tag", "3.23.42-1-deadbeef"),
|
|
|
|
Cmd("git describe --tags hash_234", "3.3.1.1"),
|
|
|
|
Cmd("git describe --tags hash_123", "3.21.2"),
|
|
|
|
Cmd("git describe --tags hash_345", "3.22.3"),
|
2015-02-16 17:00:44 +00:00
|
|
|
Cmd("git describe --tags hash_456", "4.2.71"),
|
2014-10-16 13:21:13 +00:00
|
|
|
Cmd("git diff --name-only hash_234 hash_234^", VERSION_FILE),
|
|
|
|
Cmd("git checkout -f hash_234 -- %s" % VERSION_FILE, "",
|
2015-02-16 17:00:44 +00:00
|
|
|
cb=ResetVersion(3, 3, 1, 1)),
|
2015-01-29 14:21:31 +00:00
|
|
|
Cmd("git branch -r --contains hash_234", " branch-heads/3.3\n"),
|
2014-11-12 17:54:11 +00:00
|
|
|
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
|
2014-10-16 13:21:13 +00:00
|
|
|
Cmd("git log -1 --format=%s hash_234", ""),
|
2014-11-12 17:54:11 +00:00
|
|
|
Cmd("git log -1 --format=%B hash_234", c_hash_234_commit_log),
|
2014-10-16 13:21:13 +00:00
|
|
|
Cmd("git log -1 --format=%ci hash_234", "18:15"),
|
2014-09-23 09:35:49 +00:00
|
|
|
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
|
2015-02-16 17:00:44 +00:00
|
|
|
cb=ResetVersion(3, 22, 5)),
|
2014-10-16 13:21:13 +00:00
|
|
|
Cmd("git diff --name-only hash_123 hash_123^", VERSION_FILE),
|
|
|
|
Cmd("git checkout -f hash_123 -- %s" % VERSION_FILE, "",
|
2015-02-16 17:00:44 +00:00
|
|
|
cb=ResetVersion(3, 21, 2)),
|
2015-01-29 14:21:31 +00:00
|
|
|
Cmd("git branch -r --contains hash_123", " branch-heads/3.21\n"),
|
2014-11-12 17:54:11 +00:00
|
|
|
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
|
2014-10-16 13:21:13 +00:00
|
|
|
Cmd("git log -1 --format=%s hash_123", ""),
|
2014-11-12 17:54:11 +00:00
|
|
|
Cmd("git log -1 --format=%B hash_123", c_hash_123_commit_log),
|
2014-10-16 13:21:13 +00:00
|
|
|
Cmd("git log -1 --format=%ci hash_123", "03:15"),
|
2014-09-23 09:35:49 +00:00
|
|
|
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
|
2015-02-16 17:00:44 +00:00
|
|
|
cb=ResetVersion(3, 22, 5)),
|
2014-10-16 13:21:13 +00:00
|
|
|
Cmd("git diff --name-only hash_345 hash_345^", VERSION_FILE),
|
|
|
|
Cmd("git checkout -f hash_345 -- %s" % VERSION_FILE, "",
|
2015-02-16 17:00:44 +00:00
|
|
|
cb=ResetVersion(3, 22, 3)),
|
2015-01-29 14:21:31 +00:00
|
|
|
Cmd("git branch -r --contains hash_345", " origin/candidates\n"),
|
2014-11-12 17:54:11 +00:00
|
|
|
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
|
2014-10-16 13:21:13 +00:00
|
|
|
Cmd("git log -1 --format=%s hash_345", ""),
|
2014-11-12 17:54:11 +00:00
|
|
|
Cmd("git log -1 --format=%B hash_345", c_hash_345_commit_log),
|
2014-10-16 13:21:13 +00:00
|
|
|
Cmd("git log -1 --format=%ci hash_345", ""),
|
2014-09-23 09:35:49 +00:00
|
|
|
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
|
2015-02-16 17:00:44 +00:00
|
|
|
cb=ResetVersion(3, 22, 5)),
|
|
|
|
Cmd("git diff --name-only hash_456 hash_456^", VERSION_FILE),
|
|
|
|
Cmd("git checkout -f hash_456 -- %s" % VERSION_FILE, "",
|
|
|
|
cb=ResetVersion(4, 2, 71)),
|
|
|
|
Cmd("git branch -r --contains hash_456", " origin/4.2.71\n"),
|
|
|
|
Cmd("git log -1 --format=%B hash_456", c_hash_456_commit_log),
|
|
|
|
Cmd("git log -1 --format=%H 4.2.71", "hash_456"),
|
|
|
|
Cmd("git log -1 --format=%s hash_456", "Version 4.2.71"),
|
|
|
|
Cmd("git log -1 --format=%H hash_456^", "master_456"),
|
|
|
|
Cmd("git log -1 --format=%B master_456",
|
|
|
|
"Cr-Commit-Position: refs/heads/master@{#456}"),
|
|
|
|
Cmd("git log -1 --format=%B hash_456", c_hash_456_commit_log),
|
|
|
|
Cmd("git log -1 --format=%ci hash_456", "02:15"),
|
|
|
|
Cmd("git checkout -f HEAD -- %s" % VERSION_FILE, "",
|
|
|
|
cb=ResetVersion(3, 22, 5)),
|
2015-04-07 19:42:32 +00:00
|
|
|
Cmd("git fetch origin +refs/heads/*:refs/remotes/origin/* "
|
|
|
|
"+refs/branch-heads/*:refs/remotes/branch-heads/*", "",
|
2014-10-16 13:21:13 +00:00
|
|
|
cwd=chrome_dir),
|
2014-09-05 09:19:48 +00:00
|
|
|
Cmd("git fetch origin", "", cwd=chrome_v8_dir),
|
2015-04-07 19:42:32 +00:00
|
|
|
Cmd("git log --format=%H --grep=\"V8\" origin/master -- DEPS",
|
|
|
|
"c_hash1\nc_hash2\nc_hash3\n",
|
2015-02-16 17:00:44 +00:00
|
|
|
cwd=chrome_dir),
|
2015-04-07 19:42:32 +00:00
|
|
|
Cmd("git show c_hash1:DEPS", c_deps % "hash_456", cwd=chrome_dir),
|
2015-02-16 17:00:44 +00:00
|
|
|
Cmd("git log -1 --format=%B c_hash1", c_hash1_commit_log,
|
2014-09-05 09:19:48 +00:00
|
|
|
cwd=chrome_dir),
|
2015-04-07 19:42:32 +00:00
|
|
|
Cmd("git show c_hash2:DEPS", c_deps % "hash_345", cwd=chrome_dir),
|
2014-09-05 09:19:48 +00:00
|
|
|
Cmd("git log -1 --format=%B c_hash2", c_hash2_commit_log,
|
|
|
|
cwd=chrome_dir),
|
2015-04-07 19:42:32 +00:00
|
|
|
Cmd("git show c_hash3:DEPS", c_deps % "deadbeef", cwd=chrome_dir),
|
2014-09-05 09:19:48 +00:00
|
|
|
Cmd("git log -1 --format=%B c_hash3", c_hash3_commit_log,
|
|
|
|
cwd=chrome_dir),
|
|
|
|
Cmd("git branch -r", " weird/123\n branch-heads/7\n", cwd=chrome_dir),
|
2015-04-07 19:42:32 +00:00
|
|
|
Cmd("git show refs/branch-heads/7:DEPS", c_deps % "hash_345",
|
2014-09-05 09:19:48 +00:00
|
|
|
cwd=chrome_dir),
|
2015-04-15 12:25:28 +00:00
|
|
|
URL("http://omahaproxy.appspot.com/all.json", """[{
|
|
|
|
"os": "win",
|
|
|
|
"versions": [{
|
2015-04-16 12:51:51 +00:00
|
|
|
"version": "2.2.2.2",
|
|
|
|
"v8_version": "22.2.2.2",
|
2015-04-15 12:25:28 +00:00
|
|
|
"current_reldate": "04/09/15",
|
|
|
|
"os": "win",
|
2015-04-16 12:51:51 +00:00
|
|
|
"channel": "canary",
|
|
|
|
"previous_version": "1.1.1.0"
|
2015-04-15 12:25:28 +00:00
|
|
|
}]
|
|
|
|
}]"""),
|
2015-04-16 12:51:51 +00:00
|
|
|
URL("http://omahaproxy.appspot.com/v8.json?version=1.1.1.0", """{
|
|
|
|
"chromium_version": "1.1.1.0",
|
|
|
|
"v8_version": "11.1.1.0"
|
|
|
|
}"""),
|
|
|
|
Cmd("git rev-list -1 11.1.1", "v8_previous_version_hash"),
|
|
|
|
Cmd("git rev-list -1 22.2.2.2", "v8_version_hash"),
|
2015-03-14 01:20:45 +00:00
|
|
|
Cmd("git checkout -f origin/master", ""),
|
2015-04-15 12:25:28 +00:00
|
|
|
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], "")
|
2014-04-09 14:30:02 +00:00
|
|
|
])
|
|
|
|
|
2014-09-23 14:41:36 +00:00
|
|
|
args = ["-c", TEST_CONFIG["CHROMIUM"],
|
2014-04-09 14:30:02 +00:00
|
|
|
"--json", json_output,
|
|
|
|
"--csv", csv_output,
|
|
|
|
"--max-releases", "1"]
|
|
|
|
Releases(TEST_CONFIG, self).Run(args)
|
|
|
|
|
|
|
|
# Check expected output.
|
2015-02-16 17:00:44 +00:00
|
|
|
csv = ("4.2.71,4.2.71,1,5678,\r\n"
|
|
|
|
"3.22.3,candidates,345,4567:5677,\r\n"
|
2014-04-09 14:30:02 +00:00
|
|
|
"3.21.2,3.21,123,,\r\n"
|
2014-11-05 13:30:50 +00:00
|
|
|
"3.3.1.1,3.3,234,,abc12\r\n")
|
2014-04-09 14:30:02 +00:00
|
|
|
self.assertEquals(csv, FileToText(csv_output))
|
|
|
|
|
2015-04-15 12:25:28 +00:00
|
|
|
expected_json = {"chrome_releases":{
|
|
|
|
"canaries": [
|
|
|
|
{
|
2015-04-16 12:51:51 +00:00
|
|
|
"chrome_version": "2.2.2.2",
|
2015-04-15 12:25:28 +00:00
|
|
|
"os": "win",
|
|
|
|
"release_date": "04/09/15",
|
2015-04-16 12:51:51 +00:00
|
|
|
"v8_version": "22.2.2.2",
|
|
|
|
"v8_version_hash": "v8_version_hash",
|
|
|
|
"v8_previous_version": "11.1.1.0",
|
|
|
|
"v8_previous_version_hash": "v8_previous_version_hash"
|
2015-04-15 12:25:28 +00:00
|
|
|
}]},
|
|
|
|
"releases":[
|
2015-02-16 17:00:44 +00:00
|
|
|
{
|
|
|
|
"revision": "1",
|
|
|
|
"revision_git": "hash_456",
|
|
|
|
"master_position": "456",
|
|
|
|
"master_hash": "master_456",
|
|
|
|
"patches_merged": "",
|
|
|
|
"version": "4.2.71",
|
|
|
|
"chromium_revision": "5678",
|
|
|
|
"branch": "4.2.71",
|
|
|
|
"review_link": "",
|
|
|
|
"date": "02:15",
|
|
|
|
"chromium_branch": "",
|
|
|
|
# FIXME(machenbach): Fix revisions link for git.
|
|
|
|
"revision_link": "https://code.google.com/p/v8/source/detail?r=1",
|
|
|
|
},
|
2014-10-16 13:21:13 +00:00
|
|
|
{
|
|
|
|
"revision": "345",
|
|
|
|
"revision_git": "hash_345",
|
2015-01-26 14:20:59 +00:00
|
|
|
"master_position": "",
|
|
|
|
"master_hash": "",
|
2014-10-16 13:21:13 +00:00
|
|
|
"patches_merged": "",
|
|
|
|
"version": "3.22.3",
|
2015-02-16 17:00:44 +00:00
|
|
|
"chromium_revision": "4567:5677",
|
2014-10-16 13:21:13 +00:00
|
|
|
"branch": "candidates",
|
|
|
|
"review_link": "",
|
|
|
|
"date": "",
|
|
|
|
"chromium_branch": "7",
|
|
|
|
"revision_link": "https://code.google.com/p/v8/source/detail?r=345",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"revision": "123",
|
|
|
|
"revision_git": "hash_123",
|
|
|
|
"patches_merged": "",
|
2015-01-26 14:20:59 +00:00
|
|
|
"master_position": "",
|
|
|
|
"master_hash": "",
|
2014-10-16 13:21:13 +00:00
|
|
|
"version": "3.21.2",
|
|
|
|
"chromium_revision": "",
|
|
|
|
"branch": "3.21",
|
|
|
|
"review_link": "",
|
|
|
|
"date": "03:15",
|
|
|
|
"chromium_branch": "",
|
|
|
|
"revision_link": "https://code.google.com/p/v8/source/detail?r=123",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"revision": "234",
|
|
|
|
"revision_git": "hash_234",
|
2014-11-05 13:30:50 +00:00
|
|
|
"patches_merged": "abc12",
|
2015-01-26 14:20:59 +00:00
|
|
|
"master_position": "",
|
|
|
|
"master_hash": "",
|
2014-10-16 13:21:13 +00:00
|
|
|
"version": "3.3.1.1",
|
|
|
|
"chromium_revision": "",
|
|
|
|
"branch": "3.3",
|
|
|
|
"review_link": "fake.com",
|
|
|
|
"date": "18:15",
|
|
|
|
"chromium_branch": "",
|
|
|
|
"revision_link": "https://code.google.com/p/v8/source/detail?r=234",
|
2015-04-15 12:25:28 +00:00
|
|
|
},],
|
|
|
|
}
|
2014-04-09 14:30:02 +00:00
|
|
|
self.assertEquals(expected_json, json.loads(FileToText(json_output)))
|
2017-03-14 16:06:31 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|