Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: tools/push-to-trunk/test_scripts.py

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/push-to-trunk/push_to_trunk.py ('k') | tools/run-deopt-fuzzer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 the V8 project authors. All rights reserved. 2 # Copyright 2013 the V8 project authors. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 10 matching lines...) Expand all
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 import os 29 import os
30 import tempfile 30 import tempfile
31 import traceback
31 import unittest 32 import unittest
32 33
33 import common_includes
34 from common_includes import *
35 import push_to_trunk
36 from push_to_trunk import *
37 import auto_roll 34 import auto_roll
38 from auto_roll import AutoRollOptions 35 from auto_roll import AutoRollOptions
39 from auto_roll import CheckLastPush 36 from auto_roll import CheckLastPush
40 from auto_roll import FetchLatestRevision 37 from auto_roll import FetchLatestRevision
41 from auto_roll import SETTINGS_LOCATION 38 from auto_roll import SETTINGS_LOCATION
39 import common_includes
40 from common_includes import *
41 import merge_to_branch
42 from merge_to_branch import *
43 import push_to_trunk
44 from push_to_trunk import *
42 45
43 46
44 TEST_CONFIG = { 47 TEST_CONFIG = {
45 BRANCHNAME: "test-prepare-push", 48 BRANCHNAME: "test-prepare-push",
46 TRUNKBRANCH: "test-trunk-push", 49 TRUNKBRANCH: "test-trunk-push",
47 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", 50 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile",
48 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", 51 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script",
49 DOT_GIT_LOCATION: None, 52 DOT_GIT_LOCATION: None,
50 VERSION_FILE: None, 53 VERSION_FILE: None,
51 CHANGELOG_FILE: None, 54 CHANGELOG_FILE: None,
52 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", 55 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry",
53 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", 56 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch",
54 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", 57 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg",
55 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", 58 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium",
56 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", 59 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS",
57 SETTINGS_LOCATION: None, 60 SETTINGS_LOCATION: None,
61 ALREADY_MERGING_SENTINEL_FILE:
62 "/tmp/test-merge-to-branch-tempfile-already-merging",
63 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES",
64 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch",
58 } 65 }
59 66
60 67
61 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None, 68 AUTO_ROLL_ARGS = [
62 status_password=None): 69 "-a", "author@chromium.org",
70 "-c", TEST_CONFIG[CHROMIUM],
71 "-r", "reviewer@chromium.org",
72 ]
73
74
75 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None, a=None,
76 status_password=None, revert_bleeding_edge=None, p=None):
63 """Convenience wrapper.""" 77 """Convenience wrapper."""
64 class Options(object): 78 class Options(object):
65 pass 79 pass
66 options = Options() 80 options = Options()
67 options.s = s 81 options.step = s
68 options.l = l 82 options.last_push = l
69 options.f = f 83 options.force = f
70 options.m = m 84 options.manual = m
71 options.r = r 85 options.reviewer = r
72 options.c = c 86 options.chromium = c
87 options.author = a
88 options.push = p
73 options.status_password = status_password 89 options.status_password = status_password
90 options.revert_bleeding_edge = revert_bleeding_edge
74 return options 91 return options
75 92
76 93
77 class ToplevelTest(unittest.TestCase): 94 class ToplevelTest(unittest.TestCase):
78 def testMakeComment(self): 95 def testMakeComment(self):
79 self.assertEquals("# Line 1\n# Line 2\n#", 96 self.assertEquals("# Line 1\n# Line 2\n#",
80 MakeComment(" Line 1\n Line 2\n")) 97 MakeComment(" Line 1\n Line 2\n"))
81 self.assertEquals("#Line 1\n#Line 2", 98 self.assertEquals("#Line 1\n#Line 2",
82 MakeComment("Line 1\n Line 2")) 99 MakeComment("Line 1\n Line 2"))
83 100
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 self._index = -1 236 self._index = -1
220 237
221 def Expect(self, recipe): 238 def Expect(self, recipe):
222 self._recipe = recipe 239 self._recipe = recipe
223 240
224 def Call(self, *args): 241 def Call(self, *args):
225 self._index += 1 242 self._index += 1
226 try: 243 try:
227 expected_call = self._recipe[self._index] 244 expected_call = self._recipe[self._index]
228 except IndexError: 245 except IndexError:
229 raise Exception("Calling %s %s" % (self._name, " ".join(args))) 246 raise NoRetryException("Calling %s %s" % (self._name, " ".join(args)))
230 247
231 # Pack expectations without arguments into a list. 248 # Pack expectations without arguments into a list.
232 if not isinstance(expected_call, list): 249 if not isinstance(expected_call, list):
233 expected_call = [expected_call] 250 expected_call = [expected_call]
234 251
235 # The number of arguments in the expectation must match the actual 252 # The number of arguments in the expectation must match the actual
236 # arguments. 253 # arguments.
237 if len(args) > len(expected_call): 254 if len(args) > len(expected_call):
238 raise NoRetryException("When calling %s with arguments, the " 255 raise NoRetryException("When calling %s with arguments, the "
239 "expectations must consist of at least as many arguments.") 256 "expectations must consist of at least as many arguments.")
240 257
241 # Compare expected and actual arguments. 258 # Compare expected and actual arguments.
242 for (expected_arg, actual_arg) in zip(expected_call, args): 259 for (expected_arg, actual_arg) in zip(expected_call, args):
243 if expected_arg != actual_arg: 260 if expected_arg != actual_arg:
244 raise NoRetryException("Expected: %s - Actual: %s" 261 raise NoRetryException("Expected: %s - Actual: %s"
245 % (expected_arg, actual_arg)) 262 % (expected_arg, actual_arg))
246 263
247 # The expectation list contains a mandatory return value and an optional 264 # The expectation list contains a mandatory return value and an optional
248 # callback for checking the context at the time of the call. 265 # callback for checking the context at the time of the call.
249 if len(expected_call) == len(args) + 2: 266 if len(expected_call) == len(args) + 2:
250 expected_call[len(args) + 1]() 267 try:
268 expected_call[len(args) + 1]()
269 except:
270 tb = traceback.format_exc()
271 raise NoRetryException("Caught exception from callback: %s" % tb)
251 return_value = expected_call[len(args)] 272 return_value = expected_call[len(args)]
252 273
253 # If the return value is an exception, raise it instead of returning. 274 # If the return value is an exception, raise it instead of returning.
254 if isinstance(return_value, Exception): 275 if isinstance(return_value, Exception):
255 raise return_value 276 raise return_value
256 return return_value 277 return return_value
257 278
258 def AssertFinished(self): 279 def AssertFinished(self):
259 if self._index < len(self._recipe) -1: 280 if self._index < len(self._recipe) -1:
260 raise NoRetryException("Called %s too seldom: %d vs. %d" 281 raise NoRetryException("Called %s too seldom: %d vs. %d"
(...skipping 16 matching lines...) Expand all
277 f.write("#define MINOR_VERSION 22\n") 298 f.write("#define MINOR_VERSION 22\n")
278 f.write("#define BUILD_NUMBER 5\n") 299 f.write("#define BUILD_NUMBER 5\n")
279 f.write("#define PATCH_LEVEL 0\n") 300 f.write("#define PATCH_LEVEL 0\n")
280 f.write(" // Some line...\n") 301 f.write(" // Some line...\n")
281 f.write("#define IS_CANDIDATE_VERSION 0\n") 302 f.write("#define IS_CANDIDATE_VERSION 0\n")
282 return name 303 return name
283 304
284 def MakeStep(self, step_class=Step, state=None, options=None): 305 def MakeStep(self, step_class=Step, state=None, options=None):
285 """Convenience wrapper.""" 306 """Convenience wrapper."""
286 options = options or CommonOptions(MakeOptions()) 307 options = options or CommonOptions(MakeOptions())
308 state = state if state is not None else self._state
287 return MakeStep(step_class=step_class, number=0, state=state, 309 return MakeStep(step_class=step_class, number=0, state=state,
288 config=TEST_CONFIG, options=options, 310 config=TEST_CONFIG, options=options,
289 side_effect_handler=self) 311 side_effect_handler=self)
290 312
291 def GitMock(self, cmd, args="", pipe=True): 313 def GitMock(self, cmd, args="", pipe=True):
292 print "%s %s" % (cmd, args) 314 print "%s %s" % (cmd, args)
293 return self._git_mock.Call(args) 315 return self._git_mock.Call(args)
294 316
295 def LogMock(self, cmd, args=""): 317 def LogMock(self, cmd, args=""):
296 print "Log: %s %s" % (cmd, args) 318 print "Log: %s %s" % (cmd, args)
297 319
298 MOCKS = { 320 MOCKS = {
299 "git": GitMock, 321 "git": GitMock,
322 # TODO(machenbach): Little hack to reuse the git mock for the one svn call
323 # in merge-to-branch. The command should be made explicit in the test
324 # expectations.
325 "svn": GitMock,
300 "vi": LogMock, 326 "vi": LogMock,
301 } 327 }
302 328
303 def Call(self, fun, *args, **kwargs): 329 def Call(self, fun, *args, **kwargs):
304 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs)) 330 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs))
305 331
306 def Command(self, cmd, args="", prefix="", pipe=True): 332 def Command(self, cmd, args="", prefix="", pipe=True):
307 return ScriptTest.MOCKS[cmd](self, cmd, args) 333 return ScriptTest.MOCKS[cmd](self, cmd, args)
308 334
309 def ReadLine(self): 335 def ReadLine(self):
(...skipping 21 matching lines...) Expand all
331 357
332 def ExpectReadURL(self, *args): 358 def ExpectReadURL(self, *args):
333 """Convenience wrapper.""" 359 """Convenience wrapper."""
334 self._url_mock.Expect(*args) 360 self._url_mock.Expect(*args)
335 361
336 def setUp(self): 362 def setUp(self):
337 self._git_mock = SimpleMock("git") 363 self._git_mock = SimpleMock("git")
338 self._rl_mock = SimpleMock("readline") 364 self._rl_mock = SimpleMock("readline")
339 self._url_mock = SimpleMock("readurl") 365 self._url_mock = SimpleMock("readurl")
340 self._tmp_files = [] 366 self._tmp_files = []
367 self._state = {}
341 368
342 def tearDown(self): 369 def tearDown(self):
343 Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME]) 370 Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME])
344 371
345 # Clean up temps. Doesn't work automatically. 372 # Clean up temps. Doesn't work automatically.
346 for name in self._tmp_files: 373 for name in self._tmp_files:
347 if os.path.exists(name): 374 if os.path.exists(name):
348 os.remove(name) 375 os.remove(name)
349 376
350 self._git_mock.AssertFinished() 377 self._git_mock.AssertFinished()
351 self._rl_mock.AssertFinished() 378 self._rl_mock.AssertFinished()
352 self._url_mock.AssertFinished() 379 self._url_mock.AssertFinished()
353 380
354 def testPersistRestore(self):
355 self.MakeStep().Persist("test1", "")
356 self.assertEquals("", self.MakeStep().Restore("test1"))
357 self.MakeStep().Persist("test2", "AB123")
358 self.assertEquals("AB123", self.MakeStep().Restore("test2"))
359
360 def testGitOrig(self): 381 def testGitOrig(self):
361 self.assertTrue(Command("git", "--version").startswith("git version")) 382 self.assertTrue(Command("git", "--version").startswith("git version"))
362 383
363 def testGitMock(self): 384 def testGitMock(self):
364 self.ExpectGit([["--version", "git version 1.2.3"], ["dummy", ""]]) 385 self.ExpectGit([["--version", "git version 1.2.3"], ["dummy", ""]])
365 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) 386 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version"))
366 self.assertEquals("", self.MakeStep().Git("dummy")) 387 self.assertEquals("", self.MakeStep().Git("dummy"))
367 388
368 def testCommonPrepareDefault(self): 389 def testCommonPrepareDefault(self):
369 self.ExpectGit([ 390 self.ExpectGit([
370 ["status -s -uno", ""], 391 ["status -s -uno", ""],
371 ["status -s -b -uno", "## some_branch"], 392 ["status -s -b -uno", "## some_branch"],
372 ["svn fetch", ""], 393 ["svn fetch", ""],
373 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 394 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]],
374 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], 395 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""],
375 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], 396 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""],
376 ["branch", ""], 397 ["branch", ""],
377 ]) 398 ])
378 self.ExpectReadline(["Y"]) 399 self.ExpectReadline(["Y"])
379 self.MakeStep().CommonPrepare() 400 self.MakeStep().CommonPrepare()
380 self.MakeStep().PrepareBranch() 401 self.MakeStep().PrepareBranch()
381 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) 402 self.assertEquals("some_branch", self._state["current_branch"])
382 403
383 def testCommonPrepareNoConfirm(self): 404 def testCommonPrepareNoConfirm(self):
384 self.ExpectGit([ 405 self.ExpectGit([
385 ["status -s -uno", ""], 406 ["status -s -uno", ""],
386 ["status -s -b -uno", "## some_branch"], 407 ["status -s -b -uno", "## some_branch"],
387 ["svn fetch", ""], 408 ["svn fetch", ""],
388 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 409 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]],
389 ]) 410 ])
390 self.ExpectReadline(["n"]) 411 self.ExpectReadline(["n"])
391 self.MakeStep().CommonPrepare() 412 self.MakeStep().CommonPrepare()
392 self.assertRaises(Exception, self.MakeStep().PrepareBranch) 413 self.assertRaises(Exception, self.MakeStep().PrepareBranch)
393 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) 414 self.assertEquals("some_branch", self._state["current_branch"])
394 415
395 def testCommonPrepareDeleteBranchFailure(self): 416 def testCommonPrepareDeleteBranchFailure(self):
396 self.ExpectGit([ 417 self.ExpectGit([
397 ["status -s -uno", ""], 418 ["status -s -uno", ""],
398 ["status -s -b -uno", "## some_branch"], 419 ["status -s -b -uno", "## some_branch"],
399 ["svn fetch", ""], 420 ["svn fetch", ""],
400 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 421 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]],
401 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None], 422 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None],
402 ]) 423 ])
403 self.ExpectReadline(["Y"]) 424 self.ExpectReadline(["Y"])
404 self.MakeStep().CommonPrepare() 425 self.MakeStep().CommonPrepare()
405 self.assertRaises(Exception, self.MakeStep().PrepareBranch) 426 self.assertRaises(Exception, self.MakeStep().PrepareBranch)
406 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) 427 self.assertEquals("some_branch", self._state["current_branch"])
407 428
408 def testInitialEnvironmentChecks(self): 429 def testInitialEnvironmentChecks(self):
409 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 430 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
410 os.environ["EDITOR"] = "vi" 431 os.environ["EDITOR"] = "vi"
411 self.MakeStep().InitialEnvironmentChecks() 432 self.MakeStep().InitialEnvironmentChecks()
412 433
413 def testReadAndPersistVersion(self): 434 def testReadAndPersistVersion(self):
414 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 435 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
415 step = self.MakeStep() 436 step = self.MakeStep()
416 step.ReadAndPersistVersion() 437 step.ReadAndPersistVersion()
417 self.assertEquals("3", self.MakeStep().Restore("major")) 438 self.assertEquals("3", step["major"])
418 self.assertEquals("22", self.MakeStep().Restore("minor")) 439 self.assertEquals("22", step["minor"])
419 self.assertEquals("5", self.MakeStep().Restore("build")) 440 self.assertEquals("5", step["build"])
420 self.assertEquals("0", self.MakeStep().Restore("patch")) 441 self.assertEquals("0", step["patch"])
421 self.assertEquals("3", step._state["major"])
422 self.assertEquals("22", step._state["minor"])
423 self.assertEquals("5", step._state["build"])
424 self.assertEquals("0", step._state["patch"])
425 442
426 def testRegex(self): 443 def testRegex(self):
427 self.assertEqual("(issue 321)", 444 self.assertEqual("(issue 321)",
428 re.sub(r"BUG=v8:(.*)$", r"(issue \1)", "BUG=v8:321")) 445 re.sub(r"BUG=v8:(.*)$", r"(issue \1)", "BUG=v8:321"))
429 self.assertEqual("(Chromium issue 321)", 446 self.assertEqual("(Chromium issue 321)",
430 re.sub(r"BUG=(.*)$", r"(Chromium issue \1)", "BUG=321")) 447 re.sub(r"BUG=(.*)$", r"(Chromium issue \1)", "BUG=321"))
431 448
432 cl = " too little\n\ttab\ttab\n too much\n trailing " 449 cl = " too little\n\ttab\ttab\n too much\n trailing "
433 cl = MSub(r"\t", r" ", cl) 450 cl = MSub(r"\t", r" ", cl)
434 cl = MSub(r"^ {1,7}([^ ])", r" \1", cl) 451 cl = MSub(r"^ {1,7}([^ ])", r" \1", cl)
435 cl = MSub(r"^ {9,80}([^ ])", r" \1", cl) 452 cl = MSub(r"^ {9,80}([^ ])", r" \1", cl)
436 cl = MSub(r" +$", r"", cl) 453 cl = MSub(r" +$", r"", cl)
437 self.assertEqual(" too little\n" 454 self.assertEqual(" too little\n"
438 " tab tab\n" 455 " tab tab\n"
439 " too much\n" 456 " too much\n"
440 " trailing", cl) 457 " trailing", cl)
441 458
442 self.assertEqual("//\n#define BUILD_NUMBER 3\n", 459 self.assertEqual("//\n#define BUILD_NUMBER 3\n",
443 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", 460 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
444 r"\g<space>3", 461 r"\g<space>3",
445 "//\n#define BUILD_NUMBER 321\n")) 462 "//\n#define BUILD_NUMBER 321\n"))
446 463
447 def testPrepareChangeLog(self): 464 def testPrepareChangeLog(self):
448 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 465 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
449 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 466 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
450 467
451 self.ExpectGit([ 468 self.ExpectGit([
452 ["log 1234..HEAD --format=%H", "rev1\nrev2\nrev3\nrev4"], 469 ["log --format=%H 1234..HEAD", "rev1\nrev2\nrev3\nrev4"],
453 ["log -1 rev1 --format=\"%s\"", "Title text 1"], 470 ["log -1 --format=%s rev1", "Title text 1"],
454 ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\nLOG=y\n"], 471 ["log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"],
455 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org"], 472 ["log -1 --format=%an rev1", "author1@chromium.org"],
456 ["log -1 rev2 --format=\"%s\"", "Title text 2."], 473 ["log -1 --format=%s rev2", "Title text 2."],
457 ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=123\nLOG= \n"], 474 ["log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"],
458 ["log -1 rev2 --format=\"%an\"", "author2@chromium.org"], 475 ["log -1 --format=%an rev2", "author2@chromium.org"],
459 ["log -1 rev3 --format=\"%s\"", "Title text 3"], 476 ["log -1 --format=%s rev3", "Title text 3"],
460 ["log -1 rev3 --format=\"%B\"", "Title\n\nBUG=321\nLOG=true\n"], 477 ["log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"],
461 ["log -1 rev3 --format=\"%an\"", "author3@chromium.org"], 478 ["log -1 --format=%an rev3", "author3@chromium.org"],
462 ["log -1 rev4 --format=\"%s\"", "Title text 4"], 479 ["log -1 --format=%s rev4", "Title text 4"],
463 ["log -1 rev4 --format=\"%B\"", 480 ["log -1 --format=%B rev4",
464 ("Title\n\nBUG=456\nLOG=Y\n\n" 481 ("Title\n\nBUG=456\nLOG=Y\n\n"
465 "Review URL: https://codereview.chromium.org/9876543210\n")], 482 "Review URL: https://codereview.chromium.org/9876543210\n")],
466 ["log -1 rev4 --format=\"%an\"", "author4@chromium.org"], 483 ["log -1 --format=%an rev4", "author4@chromium.org"],
467 ]) 484 ])
468 485
469 # The cl for rev4 on rietveld has an updated LOG flag. 486 # The cl for rev4 on rietveld has an updated LOG flag.
470 self.ExpectReadURL([ 487 self.ExpectReadURL([
471 ["https://codereview.chromium.org/9876543210/description", 488 ["https://codereview.chromium.org/9876543210/description",
472 "Title\n\nBUG=456\nLOG=N\n\n"], 489 "Title\n\nBUG=456\nLOG=N\n\n"],
473 ]) 490 ])
474 491
475 self.MakeStep().Persist("last_push", "1234") 492 self._state["last_push_bleeding_edge"] = "1234"
476 self.MakeStep(PrepareChangeLog).Run() 493 self.MakeStep(PrepareChangeLog).Run()
477 494
478 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 495 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
479 496
480 expected_cl = """1999-07-31: Version 3.22.5 497 expected_cl = """1999-07-31: Version 3.22.5
481 498
482 Title text 1. 499 Title text 1.
483 500
484 Title text 3 (Chromium issue 321). 501 Title text 3 (Chromium issue 321).
485 502
(...skipping 11 matching lines...) Expand all
497 # 514 #
498 # Title text 3 (Chromium issue 321). 515 # Title text 3 (Chromium issue 321).
499 # (author3@chromium.org) 516 # (author3@chromium.org)
500 # 517 #
501 # Title text 4 (Chromium issue 456). 518 # Title text 4 (Chromium issue 456).
502 # (author4@chromium.org) 519 # (author4@chromium.org)
503 # 520 #
504 #""" 521 #"""
505 522
506 self.assertEquals(expected_cl, actual_cl) 523 self.assertEquals(expected_cl, actual_cl)
507 self.assertEquals("3", self.MakeStep().Restore("major")) 524 self.assertEquals("3", self._state["major"])
508 self.assertEquals("22", self.MakeStep().Restore("minor")) 525 self.assertEquals("22", self._state["minor"])
509 self.assertEquals("5", self.MakeStep().Restore("build")) 526 self.assertEquals("5", self._state["build"])
510 self.assertEquals("0", self.MakeStep().Restore("patch")) 527 self.assertEquals("0", self._state["patch"])
511 528
512 def testEditChangeLog(self): 529 def testEditChangeLog(self):
513 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 530 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
514 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 531 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
515 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) 532 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE])
516 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 533 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE])
517 os.environ["EDITOR"] = "vi" 534 os.environ["EDITOR"] = "vi"
518 535
519 self.ExpectReadline([ 536 self.ExpectReadline([
520 "", # Open editor. 537 "", # Open editor.
521 ]) 538 ])
522 539
523 self.MakeStep(EditChangeLog).Run() 540 self.MakeStep(EditChangeLog).Run()
524 541
525 self.assertEquals("New\n Lines\n\n\n Original CL", 542 self.assertEquals("New\n Lines\n\n\n Original CL",
526 FileToText(TEST_CONFIG[CHANGELOG_FILE])) 543 FileToText(TEST_CONFIG[CHANGELOG_FILE]))
527 544
528 def testIncrementVersion(self): 545 def testIncrementVersion(self):
529 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 546 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
530 self.MakeStep().Persist("build", "5") 547 self._state["build"] = "5"
531 548
532 self.ExpectReadline([ 549 self.ExpectReadline([
533 "Y", # Increment build number. 550 "Y", # Increment build number.
534 ]) 551 ])
535 552
536 self.MakeStep(IncrementVersion).Run() 553 self.MakeStep(IncrementVersion).Run()
537 554
538 self.assertEquals("3", self.MakeStep().Restore("new_major")) 555 self.assertEquals("3", self._state["new_major"])
539 self.assertEquals("22", self.MakeStep().Restore("new_minor")) 556 self.assertEquals("22", self._state["new_minor"])
540 self.assertEquals("6", self.MakeStep().Restore("new_build")) 557 self.assertEquals("6", self._state["new_build"])
541 self.assertEquals("0", self.MakeStep().Restore("new_patch")) 558 self.assertEquals("0", self._state["new_patch"])
542 559
543 def testLastChangeLogEntries(self): 560 def testLastChangeLogEntries(self):
544 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 561 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
545 l = """ 562 l = """
546 Fixed something. 563 Fixed something.
547 (issue 1234)\n""" 564 (issue 1234)\n"""
548 for _ in xrange(10): l = l + l 565 for _ in xrange(10): l = l + l
549 566
550 cl_chunk = """2013-11-12: Version 3.23.2\n%s 567 cl_chunk = """2013-11-12: Version 3.23.2\n%s
551 Performance and stability improvements on all platforms.\n\n\n""" % l 568 Performance and stability improvements on all platforms.\n\n\n""" % l
552 569
553 cl_chunk_full = cl_chunk + cl_chunk + cl_chunk 570 cl_chunk_full = cl_chunk + cl_chunk + cl_chunk
554 TextToFile(cl_chunk_full, TEST_CONFIG[CHANGELOG_FILE]) 571 TextToFile(cl_chunk_full, TEST_CONFIG[CHANGELOG_FILE])
555 572
556 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE]) 573 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE])
557 self.assertEquals(cl_chunk, cl) 574 self.assertEquals(cl_chunk, cl)
558 575
559 def _TestSquashCommits(self, change_log, expected_msg): 576 def _TestSquashCommits(self, change_log, expected_msg):
560 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 577 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
561 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: 578 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f:
562 f.write(change_log) 579 f.write(change_log)
563 580
564 self.ExpectGit([ 581 self.ExpectGit([
565 ["diff svn/trunk hash1", "patch content"], 582 ["diff svn/trunk hash1", "patch content"],
583 ["svn find-rev hash1", "123455\n"],
566 ]) 584 ])
567 585
568 self.MakeStep().Persist("prepare_commit_hash", "hash1") 586 self._state["prepare_commit_hash"] = "hash1"
569 self.MakeStep().Persist("date", "1999-11-11") 587 self._state["date"] = "1999-11-11"
570 588
571 self.MakeStep(SquashCommits).Run() 589 self.MakeStep(SquashCommits).Run()
572 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg) 590 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg)
573 591
574 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) 592 patch = FileToText(TEST_CONFIG[ PATCH_FILE])
575 self.assertTrue(re.search(r"patch content", patch)) 593 self.assertTrue(re.search(r"patch content", patch))
576 594
577 def testSquashCommitsUnformatted(self): 595 def testSquashCommitsUnformatted(self):
578 change_log = """1999-11-11: Version 3.22.5 596 change_log = """1999-11-11: Version 3.22.5
579 597
580 Log text 1. 598 Log text 1.
581 Chromium issue 12345 599 Chromium issue 12345
582 600
583 Performance and stability improvements on all platforms.\n""" 601 Performance and stability improvements on all platforms.\n"""
584 commit_msg = """Version 3.22.5 602 commit_msg = """Version 3.22.5 (based on bleeding_edge revision r123455)
585 603
586 Log text 1. Chromium issue 12345 604 Log text 1. Chromium issue 12345
587 605
588 Performance and stability improvements on all platforms.""" 606 Performance and stability improvements on all platforms."""
589 self._TestSquashCommits(change_log, commit_msg) 607 self._TestSquashCommits(change_log, commit_msg)
590 608
591 def testSquashCommitsFormatted(self): 609 def testSquashCommitsFormatted(self):
592 change_log = """1999-11-11: Version 3.22.5 610 change_log = """1999-11-11: Version 3.22.5
593 611
594 Long commit message that fills more than 80 characters (Chromium issue 612 Long commit message that fills more than 80 characters (Chromium issue
595 12345). 613 12345).
596 614
597 Performance and stability improvements on all platforms.\n""" 615 Performance and stability improvements on all platforms.\n"""
598 commit_msg = """Version 3.22.5 616 commit_msg = """Version 3.22.5 (based on bleeding_edge revision r123455)
599 617
600 Long commit message that fills more than 80 characters (Chromium issue 12345). 618 Long commit message that fills more than 80 characters (Chromium issue 12345).
601 619
602 Performance and stability improvements on all platforms.""" 620 Performance and stability improvements on all platforms."""
603 self._TestSquashCommits(change_log, commit_msg) 621 self._TestSquashCommits(change_log, commit_msg)
604 622
605 def testSquashCommitsQuotationMarks(self): 623 def testSquashCommitsQuotationMarks(self):
606 change_log = """Line with "quotation marks".\n""" 624 change_log = """Line with "quotation marks".\n"""
607 commit_msg = """Line with "quotation marks".""" 625 commit_msg = """Line with "quotation marks"."""
608 self._TestSquashCommits(change_log, commit_msg) 626 self._TestSquashCommits(change_log, commit_msg)
(...skipping 15 matching lines...) Expand all
624 self.assertTrue(re.search(r"Version 3.22.5", cl)) 642 self.assertTrue(re.search(r"Version 3.22.5", cl))
625 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) 643 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl))
626 self.assertFalse(re.search(r" \(author1@chromium\.org\)", cl)) 644 self.assertFalse(re.search(r" \(author1@chromium\.org\)", cl))
627 645
628 # Make sure all comments got stripped. 646 # Make sure all comments got stripped.
629 self.assertFalse(re.search(r"^#", cl, flags=re.M)) 647 self.assertFalse(re.search(r"^#", cl, flags=re.M))
630 648
631 version = FileToText(TEST_CONFIG[VERSION_FILE]) 649 version = FileToText(TEST_CONFIG[VERSION_FILE])
632 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version)) 650 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version))
633 651
634 def CheckUpload():
635 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
636
637 def CheckSVNCommit(): 652 def CheckSVNCommit():
638 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) 653 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE])
639 self.assertTrue(re.search(r"Version 3.22.5", commit)) 654 self.assertEquals(
640 self.assertTrue(re.search(r"Log text 1 \(issue 321\).", commit)) 655 """Version 3.22.5 (based on bleeding_edge revision r123455)
656
657 Log text 1 (issue 321).
658
659 Performance and stability improvements on all platforms.""", commit)
641 version = FileToText(TEST_CONFIG[VERSION_FILE]) 660 version = FileToText(TEST_CONFIG[VERSION_FILE])
642 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) 661 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
643 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) 662 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
644 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) 663 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version))
645 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) 664 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version))
646 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) 665 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
647 666
648 force_flag = " -f" if not manual else "" 667 force_flag = " -f" if not manual else ""
649 review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else "" 668 review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else ""
650 self.ExpectGit([ 669 self.ExpectGit([
651 ["status -s -uno", ""], 670 ["status -s -uno", ""],
652 ["status -s -b -uno", "## some_branch\n"], 671 ["status -s -b -uno", "## some_branch\n"],
653 ["svn fetch", ""], 672 ["svn fetch", ""],
654 ["branch", " branch1\n* branch2\n"], 673 ["branch", " branch1\n* branch2\n"],
655 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], 674 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""],
656 ["branch", " branch1\n* branch2\n"], 675 ["branch", " branch1\n* branch2\n"],
657 ["branch", " branch1\n* branch2\n"], 676 ["branch", " branch1\n* branch2\n"],
658 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], 677 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""],
659 ["log -1 --format=%H ChangeLog", "1234\n"], 678 [("log -1 --format=%H --grep="
660 ["log -1 1234", "Last push ouput\n"], 679 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
661 ["log 1234..HEAD --format=%H", "rev1\n"], 680 "svn/trunk"), "hash2\n"],
662 ["log -1 rev1 --format=\"%s\"", "Log text 1.\n"], 681 ["log -1 hash2", "Log message\n"],
663 ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"], 682 ["log -1 --format=%s hash2",
664 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org\n"], 683 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"],
665 [("commit -a -m \"Prepare push to trunk. " 684 ["svn find-rev r1234", "hash3\n"],
685 ["log --format=%H hash3..HEAD", "rev1\n"],
686 ["log -1 --format=%s rev1", "Log text 1.\n"],
687 ["log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"],
688 ["log -1 --format=%an rev1", "author1@chromium.org\n"],
689 [("commit -am \"Prepare push to trunk. "
666 "Now working on version 3.22.6.%s\"" % review_suffix), 690 "Now working on version 3.22.6.%s\"" % review_suffix),
667 " 2 files changed\n", 691 " 2 files changed\n",
668 CheckPreparePush], 692 CheckPreparePush],
669 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag, 693 [("cl upload --send-mail --email \"author@chromium.org\" "
694 "-r \"reviewer@chromium.org\"%s" % force_flag),
670 "done\n"], 695 "done\n"],
671 ["cl presubmit", "Presubmit successfull\n"], 696 ["cl presubmit", "Presubmit successfull\n"],
672 ["cl dcommit -f --bypass-hooks", "Closing issue\n"], 697 ["cl dcommit -f --bypass-hooks", "Closing issue\n"],
673 ["svn fetch", "fetch result\n"], 698 ["svn fetch", "fetch result\n"],
674 ["checkout svn/bleeding_edge", ""], 699 ["checkout -f svn/bleeding_edge", ""],
675 [("log -1 --format=%H --grep=\"Prepare push to trunk. " 700 [("log -1 --format=%H --grep=\"Prepare push to trunk. "
676 "Now working on version 3.22.6.\""), 701 "Now working on version 3.22.6.\""),
677 "hash1\n"], 702 "hash1\n"],
678 ["diff svn/trunk hash1", "patch content\n"], 703 ["diff svn/trunk hash1", "patch content\n"],
704 ["svn find-rev hash1", "123455\n"],
679 ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""], 705 ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""],
680 ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""], 706 ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""],
681 ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""], 707 ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""],
682 ["commit -F \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit], 708 ["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit],
683 ["svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"], 709 ["svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"],
684 ["svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""], 710 ["svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""],
685 ["status -s -uno", ""], 711 ["status -s -uno", ""],
686 ["checkout master", ""], 712 ["checkout -f master", ""],
687 ["pull", ""], 713 ["pull", ""],
688 ["checkout -b v8-roll-123456", ""], 714 ["checkout -b v8-roll-123456", ""],
689 [("commit -am \"Update V8 to version 3.22.5.\n\n" 715 [("commit -am \"Update V8 to version 3.22.5 "
716 "(based on bleeding_edge revision r123455).\n\n"
690 "TBR=reviewer@chromium.org\""), 717 "TBR=reviewer@chromium.org\""),
691 ""], 718 ""],
692 ["cl upload --send-mail%s" % force_flag, ""], 719 ["cl upload --send-mail --email \"author@chromium.org\"%s" % force_flag,
720 ""],
693 ["checkout -f some_branch", ""], 721 ["checkout -f some_branch", ""],
694 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], 722 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""],
695 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], 723 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""],
696 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], 724 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""],
697 ]) 725 ])
698 726
699 # Expected keyboard input in manual mode: 727 # Expected keyboard input in manual mode:
700 if manual: 728 if manual:
701 self.ExpectReadline([ 729 self.ExpectReadline([
702 "Y", # Confirm last push. 730 "Y", # Confirm last push.
703 "", # Open editor. 731 "", # Open editor.
704 "Y", # Increment build number. 732 "Y", # Increment build number.
705 "reviewer@chromium.org", # V8 reviewer. 733 "reviewer@chromium.org", # V8 reviewer.
706 "LGTX", # Enter LGTM for V8 CL (wrong). 734 "LGTX", # Enter LGTM for V8 CL (wrong).
707 "LGTM", # Enter LGTM for V8 CL. 735 "LGTM", # Enter LGTM for V8 CL.
708 "Y", # Sanity check. 736 "Y", # Sanity check.
709 "reviewer@chromium.org", # Chromium reviewer. 737 "reviewer@chromium.org", # Chromium reviewer.
710 ]) 738 ])
711 739
712 # Expected keyboard input in semi-automatic mode: 740 # Expected keyboard input in semi-automatic mode:
713 if not manual and not force: 741 if not manual and not force:
714 self.ExpectReadline([ 742 self.ExpectReadline([
715 "LGTM", # Enter LGTM for V8 CL. 743 "LGTM", # Enter LGTM for V8 CL.
716 ]) 744 ])
717 745
718 # No keyboard input in forced mode: 746 # No keyboard input in forced mode:
719 if force: 747 if force:
720 self.ExpectReadline([]) 748 self.ExpectReadline([])
721 749
722 options = MakeOptions(f=force, m=manual, 750 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM]]
723 r="reviewer@chromium.org" if not manual else None, 751 if force: args.append("-f")
724 c = TEST_CONFIG[CHROMIUM]) 752 if manual: args.append("-m")
753 else: args += ["-r", "reviewer@chromium.org"]
754 options = push_to_trunk.BuildOptions().parse_args(args)
725 RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self) 755 RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self)
726 756
727 deps = FileToText(TEST_CONFIG[DEPS_FILE]) 757 deps = FileToText(TEST_CONFIG[DEPS_FILE])
728 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) 758 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps))
729 759
730 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) 760 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
731 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) 761 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl))
732 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) 762 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl))
733 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) 763 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl))
734 764
(...skipping 14 matching lines...) Expand all
749 self.ExpectGit([ 779 self.ExpectGit([
750 ["svn log -1 --oneline", "r101 | Text"], 780 ["svn log -1 --oneline", "r101 | Text"],
751 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], 781 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."],
752 ]) 782 ])
753 783
754 state = {} 784 state = {}
755 self.MakeStep(FetchLatestRevision, state=state).Run() 785 self.MakeStep(FetchLatestRevision, state=state).Run()
756 self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run) 786 self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run)
757 787
758 def testAutoRoll(self): 788 def testAutoRoll(self):
759 status_password = self.MakeEmptyTempFile() 789 password = self.MakeEmptyTempFile()
760 TextToFile("PW", status_password) 790 TextToFile("PW", password)
761 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 791 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
762 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" 792 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist"
763 793
764 self.ExpectReadURL([ 794 self.ExpectReadURL([
765 ["https://v8-status.appspot.com/current?format=json", 795 ["https://v8-status.appspot.com/current?format=json",
766 "{\"message\": \"Tree is throttled\"}"], 796 "{\"message\": \"Tree is throttled\"}"],
767 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], 797 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")],
768 ["https://v8-status.appspot.com/lkgr", "100"], 798 ["https://v8-status.appspot.com/lkgr", "100"],
769 ["https://v8-status.appspot.com/status", 799 ["https://v8-status.appspot.com/status",
770 ("username=v8-auto-roll%40chromium.org&" 800 ("username=v8-auto-roll%40chromium.org&"
771 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), 801 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"),
772 ""], 802 ""],
773 ["https://v8-status.appspot.com/status", 803 ["https://v8-status.appspot.com/status",
774 ("username=v8-auto-roll%40chromium.org&" 804 ("username=v8-auto-roll%40chromium.org&"
775 "message=Tree+is+throttled&password=PW"), ""], 805 "message=Tree+is+throttled&password=PW"), ""],
776 ]) 806 ])
777 807
778 self.ExpectGit([ 808 self.ExpectGit([
779 ["status -s -uno", ""], 809 ["status -s -uno", ""],
780 ["status -s -b -uno", "## some_branch\n"], 810 ["status -s -b -uno", "## some_branch\n"],
781 ["svn fetch", ""], 811 ["svn fetch", ""],
782 ["svn log -1 --oneline", "r100 | Text"], 812 ["svn log -1 --oneline", "r100 | Text"],
783 ["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."], 813 [("log -1 --format=%H --grep=\""
814 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\""
815 " svn/trunk"), "push_hash\n"],
816 ["svn find-rev push_hash", "65"],
784 ]) 817 ])
785 818
786 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions( 819 options = auto_roll.BuildOptions().parse_args(
787 MakeOptions(status_password=status_password)), self) 820 AUTO_ROLL_ARGS + ["--status-password", password])
821 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(options), self)
788 822
789 self.assertEquals("100", self.MakeStep().Restore("lkgr")) 823 state = json.loads(FileToText("%s-state.json"
790 self.assertEquals("100", self.MakeStep().Restore("latest")) 824 % TEST_CONFIG[PERSISTFILE_BASENAME]))
825
826 self.assertEquals("100", state["lkgr"])
827 self.assertEquals("100", state["latest"])
791 828
792 def testAutoRollStoppedBySettings(self): 829 def testAutoRollStoppedBySettings(self):
793 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 830 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
794 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() 831 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile()
795 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) 832 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION])
796 833
797 self.ExpectReadURL([]) 834 self.ExpectReadURL([])
798 835
799 self.ExpectGit([ 836 self.ExpectGit([
800 ["status -s -uno", ""], 837 ["status -s -uno", ""],
801 ["status -s -b -uno", "## some_branch\n"], 838 ["status -s -b -uno", "## some_branch\n"],
802 ["svn fetch", ""], 839 ["svn fetch", ""],
803 ]) 840 ])
804 841
842 options = auto_roll.BuildOptions().parse_args(AUTO_ROLL_ARGS)
805 def RunAutoRoll(): 843 def RunAutoRoll():
806 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) 844 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(options), self)
807 self.assertRaises(Exception, RunAutoRoll) 845 self.assertRaises(Exception, RunAutoRoll)
808 846
809 def testAutoRollStoppedByTreeStatus(self): 847 def testAutoRollStoppedByTreeStatus(self):
810 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 848 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
811 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" 849 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist"
812 850
813 self.ExpectReadURL([ 851 self.ExpectReadURL([
814 ["https://v8-status.appspot.com/current?format=json", 852 ["https://v8-status.appspot.com/current?format=json",
815 "{\"message\": \"Tree is throttled (no push)\"}"], 853 "{\"message\": \"Tree is throttled (no push)\"}"],
816 ]) 854 ])
817 855
818 self.ExpectGit([ 856 self.ExpectGit([
819 ["status -s -uno", ""], 857 ["status -s -uno", ""],
820 ["status -s -b -uno", "## some_branch\n"], 858 ["status -s -b -uno", "## some_branch\n"],
821 ["svn fetch", ""], 859 ["svn fetch", ""],
822 ]) 860 ])
823 861
862 options = auto_roll.BuildOptions().parse_args(AUTO_ROLL_ARGS)
824 def RunAutoRoll(): 863 def RunAutoRoll():
825 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) 864 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(options), self)
826 self.assertRaises(Exception, RunAutoRoll) 865 self.assertRaises(Exception, RunAutoRoll)
827 866
867 def testMergeToBranch(self):
868 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile()
869 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
870 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
871 os.environ["EDITOR"] = "vi"
872 extra_patch = self.MakeEmptyTempFile()
873
874 def VerifyPatch(patch):
875 return lambda: self.assertEquals(patch,
876 FileToText(TEST_CONFIG[TEMPORARY_PATCH_FILE]))
877
878 msg = """Merged r12345, r23456, r34567, r45678, r56789 into trunk branch.
879
880 Title4
881
882 Title2
883
884 Title3
885
886 Title1
887
888 Title5
889
890 BUG=123,234,345,456,567,v8:123
891 LOG=N
892 """
893
894 def VerifySVNCommit():
895 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE])
896 self.assertEquals(msg, commit)
897 version = FileToText(TEST_CONFIG[VERSION_FILE])
898 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
899 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
900 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version))
901 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
902
903 self.ExpectGit([
904 ["status -s -uno", ""],
905 ["status -s -b -uno", "## some_branch\n"],
906 ["svn fetch", ""],
907 ["branch", " branch1\n* branch2\n"],
908 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""],
909 ["branch", " branch1\n* branch2\n"],
910 ["checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""],
911 ["log --format=%H --grep=\"Port r12345\" --reverse svn/bleeding_edge",
912 "hash1\nhash2"],
913 ["svn find-rev hash1 svn/bleeding_edge", "45678"],
914 ["log -1 --format=%s hash1", "Title1"],
915 ["svn find-rev hash2 svn/bleeding_edge", "23456"],
916 ["log -1 --format=%s hash2", "Title2"],
917 ["log --format=%H --grep=\"Port r23456\" --reverse svn/bleeding_edge",
918 ""],
919 ["log --format=%H --grep=\"Port r34567\" --reverse svn/bleeding_edge",
920 "hash3"],
921 ["svn find-rev hash3 svn/bleeding_edge", "56789"],
922 ["log -1 --format=%s hash3", "Title3"],
923 ["svn find-rev r12345 svn/bleeding_edge", "hash4"],
924 # Simulate svn being down which stops the script.
925 ["svn find-rev r23456 svn/bleeding_edge", None],
926 # Restart script in the failing step.
927 ["svn find-rev r12345 svn/bleeding_edge", "hash4"],
928 ["svn find-rev r23456 svn/bleeding_edge", "hash2"],
929 ["svn find-rev r34567 svn/bleeding_edge", "hash3"],
930 ["svn find-rev r45678 svn/bleeding_edge", "hash1"],
931 ["svn find-rev r56789 svn/bleeding_edge", "hash5"],
932 ["log -1 --format=%s hash4", "Title4"],
933 ["log -1 --format=%s hash2", "Title2"],
934 ["log -1 --format=%s hash3", "Title3"],
935 ["log -1 --format=%s hash1", "Title1"],
936 ["log -1 --format=%s hash5", "Title5"],
937 ["log -1 hash4", "Title4\nBUG=123\nBUG=234"],
938 ["log -1 hash2", "Title2\n BUG = v8:123,345"],
939 ["log -1 hash3", "Title3\nLOG=n\nBUG=567, 456"],
940 ["log -1 hash1", "Title1"],
941 ["log -1 hash5", "Title5"],
942 ["log -1 -p hash4", "patch4"],
943 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
944 "", VerifyPatch("patch4")],
945 ["log -1 -p hash2", "patch2"],
946 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
947 "", VerifyPatch("patch2")],
948 ["log -1 -p hash3", "patch3"],
949 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
950 "", VerifyPatch("patch3")],
951 ["log -1 -p hash1", "patch1"],
952 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
953 "", VerifyPatch("patch1")],
954 ["log -1 -p hash5", "patch5\n"],
955 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
956 "", VerifyPatch("patch5\n")],
957 ["apply --index --reject \"%s\"" % extra_patch, ""],
958 ["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""],
959 ["cl upload --send-mail -r \"reviewer@chromium.org\"", ""],
960 ["checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""],
961 ["cl presubmit", "Presubmit successfull\n"],
962 ["cl dcommit -f --bypass-hooks", "Closing issue\n", VerifySVNCommit],
963 ["svn fetch", ""],
964 ["log -1 --format=%%H --grep=\"%s\" svn/trunk" % msg, "hash6"],
965 ["svn find-rev hash6", "1324"],
966 [("copy -r 1324 https://v8.googlecode.com/svn/trunk "
967 "https://v8.googlecode.com/svn/tags/3.22.5.1 -m "
968 "\"Tagging version 3.22.5.1\""), ""],
969 ["checkout -f some_branch", ""],
970 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""],
971 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""],
972 ])
973
974 self.ExpectReadline([
975 "Y", # Automatically add corresponding ports (34567, 56789)?
976 "Y", # Automatically increment patch level?
977 "reviewer@chromium.org", # V8 reviewer.
978 "LGTM", # Enter LGTM for V8 CL.
979 ])
980
981 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS
982 # ports of r12345. r56789 is the MIPS port of r34567.
983 args = ["-f", "-p", extra_patch, "--branch", "trunk", "12345", "23456",
984 "34567"]
985 options = merge_to_branch.BuildOptions().parse_args(args)
986 self.assertTrue(merge_to_branch.ProcessOptions(options))
987
988 # The first run of the script stops because of the svn being down.
989 self.assertRaises(GitFailedException,
990 lambda: RunMergeToBranch(TEST_CONFIG,
991 MergeToBranchOptions(options),
992 self))
993
994 # Test that state recovery after restarting the script works.
995 options.step = 3
996 RunMergeToBranch(TEST_CONFIG, MergeToBranchOptions(options), self)
997
998
828 class SystemTest(unittest.TestCase): 999 class SystemTest(unittest.TestCase):
829 def testReload(self): 1000 def testReload(self):
830 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, 1001 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={},
831 options=CommonOptions(MakeOptions()), 1002 options=CommonOptions(MakeOptions()),
832 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) 1003 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER)
833 body = step.Reload( 1004 body = step.Reload(
834 """------------------------------------------------------------------------ 1005 """------------------------------------------------------------------------
835 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines 1006 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines
836 1007
837 Prepare push to trunk. Now working on version 3.23.11. 1008 Prepare push to trunk. Now working on version 3.23.11.
838 1009
839 R=danno@chromium.org 1010 R=danno@chromium.org
840 1011
841 Review URL: https://codereview.chromium.org/83173002 1012 Review URL: https://codereview.chromium.org/83173002
842 1013
843 ------------------------------------------------------------------------""") 1014 ------------------------------------------------------------------------""")
844 self.assertEquals( 1015 self.assertEquals(
845 """Prepare push to trunk. Now working on version 3.23.11. 1016 """Prepare push to trunk. Now working on version 3.23.11.
846 1017
847 R=danno@chromium.org 1018 R=danno@chromium.org
848 1019
849 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) 1020 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body)
OLDNEW
« no previous file with comments | « tools/push-to-trunk/push_to_trunk.py ('k') | tools/run-deopt-fuzzer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698