| OLD | NEW |
| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 self.assertEquals("(Chromium issues 234, 1234567890" | 246 self.assertEquals("(Chromium issues 234, 1234567890" |
| 247 ", 12345678901234567, " | 247 ", 12345678901234567, " |
| 248 "1234567890123456789)", | 248 "1234567890123456789)", |
| 249 MakeChangeLogBugReference("BUG=234\n" | 249 MakeChangeLogBugReference("BUG=234\n" |
| 250 "BUG=12345678901234567\n" | 250 "BUG=12345678901234567\n" |
| 251 "BUG=1234567890123456789\n" | 251 "BUG=1234567890123456789\n" |
| 252 "BUG=1234567890\n")) | 252 "BUG=1234567890\n")) |
| 253 | 253 |
| 254 | 254 |
| 255 def Cmd(*args, **kwargs): | 255 def Cmd(*args, **kwargs): |
| 256 """Convenience function returning a git test expectation.""" | 256 """Convenience function returning a shell command test expectation.""" |
| 257 return { | 257 return { |
| 258 "name": "git", | 258 "name": "command", |
| 259 "args": args, | 259 "args": args, |
| 260 "ret": args[-1], | 260 "ret": args[-1], |
| 261 "cb": kwargs.get("cb"), | 261 "cb": kwargs.get("cb"), |
| 262 } | 262 } |
| 263 | 263 |
| 264 | 264 |
| 265 def RL(text, cb=None): | 265 def RL(text, cb=None): |
| 266 """Convenience function returning a readline test expectation.""" | 266 """Convenience function returning a readline test expectation.""" |
| 267 return {"name": "readline", "args": [], "ret": text, "cb": cb} | 267 return {"name": "readline", "args": [], "ret": text, "cb": cb} |
| 268 | 268 |
| 269 | 269 |
| 270 def URL(*args, **kwargs): | 270 def URL(*args, **kwargs): |
| 271 """Convenience function returning a readurl test expectation.""" | 271 """Convenience function returning a readurl test expectation.""" |
| 272 return { | 272 return { |
| 273 "name": "readurl", | 273 "name": "readurl", |
| 274 "args": args[:-1], | 274 "args": args[:-1], |
| 275 "ret": args[-1], | 275 "ret": args[-1], |
| 276 "cb": kwargs.get("cb"), | 276 "cb": kwargs.get("cb"), |
| 277 } | 277 } |
| 278 | 278 |
| 279 | 279 |
| 280 class SimpleMock(object): | 280 class SimpleMock(object): |
| 281 def __init__(self, name): | 281 def __init__(self): |
| 282 self._name = name | |
| 283 self._recipe = [] | 282 self._recipe = [] |
| 284 self._index = -1 | 283 self._index = -1 |
| 285 | 284 |
| 286 def Expect(self, recipe): | 285 def Expect(self, recipe): |
| 287 self._recipe = recipe | 286 self._recipe = recipe |
| 288 | 287 |
| 289 def Call(self, *args): # pragma: no cover | 288 def Call(self, name, *args): # pragma: no cover |
| 290 self._index += 1 | 289 self._index += 1 |
| 291 try: | 290 try: |
| 292 expected_call = self._recipe[self._index] | 291 expected_call = self._recipe[self._index] |
| 293 except IndexError: | 292 except IndexError: |
| 294 raise NoRetryException("Calling %s %s" % (self._name, " ".join(args))) | 293 raise NoRetryException("Calling %s %s" % (name, " ".join(args))) |
| 295 | 294 |
| 296 if not isinstance(expected_call, dict): | 295 if not isinstance(expected_call, dict): |
| 297 raise NoRetryException("Found wrong expectation type for %s %s" | 296 raise NoRetryException("Found wrong expectation type for %s %s" % |
| 298 % (self._name, " ".join(args))) | 297 (name, " ".join(args))) |
| 299 | 298 |
| 299 if expected_call["name"] != name: |
| 300 raise NoRetryException("Expected action: %s %s - Actual: %s" % |
| 301 (expected_call["name"], expected_call["args"], name)) |
| 300 | 302 |
| 301 # The number of arguments in the expectation must match the actual | 303 # The number of arguments in the expectation must match the actual |
| 302 # arguments. | 304 # arguments. |
| 303 if len(args) > len(expected_call['args']): | 305 if len(args) > len(expected_call['args']): |
| 304 raise NoRetryException("When calling %s with arguments, the " | 306 raise NoRetryException("When calling %s with arguments, the " |
| 305 "expectations must consist of at least as many arguments." % | 307 "expectations must consist of at least as many arguments." % |
| 306 self._name) | 308 name) |
| 307 | 309 |
| 308 # Compare expected and actual arguments. | 310 # Compare expected and actual arguments. |
| 309 for (expected_arg, actual_arg) in zip(expected_call['args'], args): | 311 for (expected_arg, actual_arg) in zip(expected_call['args'], args): |
| 310 if expected_arg != actual_arg: | 312 if expected_arg != actual_arg: |
| 311 raise NoRetryException("Expected: %s - Actual: %s" | 313 raise NoRetryException("Expected: %s - Actual: %s" % |
| 312 % (expected_arg, actual_arg)) | 314 (expected_arg, actual_arg)) |
| 313 | 315 |
| 314 # The expected call contains an optional callback for checking the context | 316 # The expected call contains an optional callback for checking the context |
| 315 # at the time of the call. | 317 # at the time of the call. |
| 316 if expected_call['cb']: | 318 if expected_call['cb']: |
| 317 try: | 319 try: |
| 318 expected_call['cb']() | 320 expected_call['cb']() |
| 319 except: | 321 except: |
| 320 tb = traceback.format_exc() | 322 tb = traceback.format_exc() |
| 321 raise NoRetryException("Caught exception from callback: %s" % tb) | 323 raise NoRetryException("Caught exception from callback: %s" % tb) |
| 322 | 324 |
| 323 # If the return value is an exception, raise it instead of returning. | 325 # If the return value is an exception, raise it instead of returning. |
| 324 if isinstance(expected_call['ret'], Exception): | 326 if isinstance(expected_call['ret'], Exception): |
| 325 raise expected_call['ret'] | 327 raise expected_call['ret'] |
| 326 return expected_call['ret'] | 328 return expected_call['ret'] |
| 327 | 329 |
| 328 def AssertFinished(self): # pragma: no cover | 330 def AssertFinished(self): # pragma: no cover |
| 329 if self._index < len(self._recipe) -1: | 331 if self._index < len(self._recipe) -1: |
| 330 raise NoRetryException("Called %s too seldom: %d vs. %d" | 332 raise NoRetryException("Called mock too seldom: %d vs. %d" % |
| 331 % (self._name, self._index, len(self._recipe))) | 333 (self._index, len(self._recipe))) |
| 332 | 334 |
| 333 | 335 |
| 334 class ScriptTest(unittest.TestCase): | 336 class ScriptTest(unittest.TestCase): |
| 335 def MakeEmptyTempFile(self): | 337 def MakeEmptyTempFile(self): |
| 336 handle, name = tempfile.mkstemp() | 338 handle, name = tempfile.mkstemp() |
| 337 os.close(handle) | 339 os.close(handle) |
| 338 self._tmp_files.append(name) | 340 self._tmp_files.append(name) |
| 339 return name | 341 return name |
| 340 | 342 |
| 341 def WriteFakeVersionFile(self, minor=22, build=4, patch=0): | 343 def WriteFakeVersionFile(self, minor=22, build=4, patch=0): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 354 options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([]) | 356 options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([]) |
| 355 return MakeStep(step_class=Step, state=self._state, | 357 return MakeStep(step_class=Step, state=self._state, |
| 356 config=TEST_CONFIG, side_effect_handler=self, | 358 config=TEST_CONFIG, side_effect_handler=self, |
| 357 options=options) | 359 options=options) |
| 358 | 360 |
| 359 def RunStep(self, script=PushToTrunk, step_class=Step, args=None): | 361 def RunStep(self, script=PushToTrunk, step_class=Step, args=None): |
| 360 """Convenience wrapper.""" | 362 """Convenience wrapper.""" |
| 361 args = args if args is not None else ["-m"] | 363 args = args if args is not None else ["-m"] |
| 362 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args) | 364 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args) |
| 363 | 365 |
| 364 def CmdMock(self, cmd, args="", pipe=True): | |
| 365 print "%s %s" % (cmd, args) | |
| 366 return self._cmd_mock.Call(cmd + " " + args) | |
| 367 | |
| 368 def Call(self, fun, *args, **kwargs): | 366 def Call(self, fun, *args, **kwargs): |
| 369 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs)) | 367 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs)) |
| 370 | 368 |
| 371 def Command(self, cmd, args="", prefix="", pipe=True): | 369 def Command(self, cmd, args="", prefix="", pipe=True): |
| 372 return self.CmdMock(cmd, args) | 370 print "%s %s" % (cmd, args) |
| 371 return self._mock.Call("command", cmd + " " + args) |
| 373 | 372 |
| 374 def ReadLine(self): | 373 def ReadLine(self): |
| 375 return self._rl_mock.Call() | 374 return self._mock.Call("readline") |
| 376 | 375 |
| 377 def ReadURL(self, url, params): | 376 def ReadURL(self, url, params): |
| 378 if params is not None: | 377 if params is not None: |
| 379 return self._url_mock.Call(url, params) | 378 return self._mock.Call("readurl", url, params) |
| 380 else: | 379 else: |
| 381 return self._url_mock.Call(url) | 380 return self._mock.Call("readurl", url) |
| 382 | 381 |
| 383 def ReadClusterFuzzAPI(self, api_key, **params): | 382 def ReadClusterFuzzAPI(self, api_key, **params): |
| 384 # TODO(machenbach): Use a mock for this and add a test that stops rolling | 383 # TODO(machenbach): Use a mock for this and add a test that stops rolling |
| 385 # due to clustefuzz results. | 384 # due to clustefuzz results. |
| 386 return [] | 385 return [] |
| 387 | 386 |
| 388 def Sleep(self, seconds): | 387 def Sleep(self, seconds): |
| 389 pass | 388 pass |
| 390 | 389 |
| 391 def GetDate(self): | 390 def GetDate(self): |
| 392 return "1999-07-31" | 391 return "1999-07-31" |
| 393 | 392 |
| 394 def GetUTCStamp(self): | 393 def GetUTCStamp(self): |
| 395 return "100000" | 394 return "100000" |
| 396 | 395 |
| 397 def ExpectCmd(self, *args): | 396 def Expect(self, *args): |
| 398 """Convenience wrapper.""" | 397 """Convenience wrapper.""" |
| 399 self._cmd_mock.Expect(*args) | 398 self._mock.Expect(*args) |
| 400 | |
| 401 def ExpectReadline(self, *args): | |
| 402 """Convenience wrapper.""" | |
| 403 self._rl_mock.Expect(*args) | |
| 404 | |
| 405 def ExpectReadURL(self, *args): | |
| 406 """Convenience wrapper.""" | |
| 407 self._url_mock.Expect(*args) | |
| 408 | 399 |
| 409 def setUp(self): | 400 def setUp(self): |
| 410 self._cmd_mock = SimpleMock("command") | 401 self._mock = SimpleMock() |
| 411 self._rl_mock = SimpleMock("readline") | |
| 412 self._url_mock = SimpleMock("readurl") | |
| 413 self._tmp_files = [] | 402 self._tmp_files = [] |
| 414 self._state = {} | 403 self._state = {} |
| 415 | 404 |
| 416 def tearDown(self): | 405 def tearDown(self): |
| 417 Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME]) | 406 Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME]) |
| 418 | 407 |
| 419 # Clean up temps. Doesn't work automatically. | 408 # Clean up temps. Doesn't work automatically. |
| 420 for name in self._tmp_files: | 409 for name in self._tmp_files: |
| 421 if os.path.exists(name): | 410 if os.path.exists(name): |
| 422 os.remove(name) | 411 os.remove(name) |
| 423 | 412 |
| 424 self._cmd_mock.AssertFinished() | 413 self._mock.AssertFinished() |
| 425 self._rl_mock.AssertFinished() | |
| 426 self._url_mock.AssertFinished() | |
| 427 | 414 |
| 428 def testGitOrig(self): | 415 def testGitOrig(self): |
| 429 self.assertTrue(Command("git", "--version").startswith("git version")) | 416 self.assertTrue(Command("git", "--version").startswith("git version")) |
| 430 | 417 |
| 431 def testGitMock(self): | 418 def testGitMock(self): |
| 432 self.ExpectCmd([Cmd("git --version", "git version 1.2.3"), | 419 self.Expect([Cmd("git --version", "git version 1.2.3"), |
| 433 Cmd("git dummy", "")]) | 420 Cmd("git dummy", "")]) |
| 434 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) | 421 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) |
| 435 self.assertEquals("", self.MakeStep().Git("dummy")) | 422 self.assertEquals("", self.MakeStep().Git("dummy")) |
| 436 | 423 |
| 437 def testCommonPrepareDefault(self): | 424 def testCommonPrepareDefault(self): |
| 438 self.ExpectCmd([ | 425 self.Expect([ |
| 439 Cmd("git status -s -uno", ""), | 426 Cmd("git status -s -uno", ""), |
| 440 Cmd("git status -s -b -uno", "## some_branch"), | 427 Cmd("git status -s -b -uno", "## some_branch"), |
| 441 Cmd("git svn fetch", ""), | 428 Cmd("git svn fetch", ""), |
| 442 Cmd("git branch", " branch1\n* %s" % TEST_CONFIG[BRANCHNAME]), | 429 Cmd("git branch", " branch1\n* %s" % TEST_CONFIG[BRANCHNAME]), |
| 430 RL("Y"), |
| 443 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), | 431 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), |
| 444 ]) | 432 ]) |
| 445 self.ExpectReadline([RL("Y")]) | |
| 446 self.MakeStep().CommonPrepare() | 433 self.MakeStep().CommonPrepare() |
| 447 self.MakeStep().PrepareBranch() | 434 self.MakeStep().PrepareBranch() |
| 448 self.assertEquals("some_branch", self._state["current_branch"]) | 435 self.assertEquals("some_branch", self._state["current_branch"]) |
| 449 | 436 |
| 450 def testCommonPrepareNoConfirm(self): | 437 def testCommonPrepareNoConfirm(self): |
| 451 self.ExpectCmd([ | 438 self.Expect([ |
| 452 Cmd("git status -s -uno", ""), | 439 Cmd("git status -s -uno", ""), |
| 453 Cmd("git status -s -b -uno", "## some_branch"), | 440 Cmd("git status -s -b -uno", "## some_branch"), |
| 454 Cmd("git svn fetch", ""), | 441 Cmd("git svn fetch", ""), |
| 455 Cmd("git branch", " branch1\n* %s" % TEST_CONFIG[BRANCHNAME]), | 442 Cmd("git branch", " branch1\n* %s" % TEST_CONFIG[BRANCHNAME]), |
| 443 RL("n"), |
| 456 ]) | 444 ]) |
| 457 self.ExpectReadline([RL("n")]) | |
| 458 self.MakeStep().CommonPrepare() | 445 self.MakeStep().CommonPrepare() |
| 459 self.assertRaises(Exception, self.MakeStep().PrepareBranch) | 446 self.assertRaises(Exception, self.MakeStep().PrepareBranch) |
| 460 self.assertEquals("some_branch", self._state["current_branch"]) | 447 self.assertEquals("some_branch", self._state["current_branch"]) |
| 461 | 448 |
| 462 def testCommonPrepareDeleteBranchFailure(self): | 449 def testCommonPrepareDeleteBranchFailure(self): |
| 463 self.ExpectCmd([ | 450 self.Expect([ |
| 464 Cmd("git status -s -uno", ""), | 451 Cmd("git status -s -uno", ""), |
| 465 Cmd("git status -s -b -uno", "## some_branch"), | 452 Cmd("git status -s -b -uno", "## some_branch"), |
| 466 Cmd("git svn fetch", ""), | 453 Cmd("git svn fetch", ""), |
| 467 Cmd("git branch", " branch1\n* %s" % TEST_CONFIG[BRANCHNAME]), | 454 Cmd("git branch", " branch1\n* %s" % TEST_CONFIG[BRANCHNAME]), |
| 455 RL("Y"), |
| 468 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], None), | 456 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], None), |
| 469 ]) | 457 ]) |
| 470 self.ExpectReadline([RL("Y")]) | |
| 471 self.MakeStep().CommonPrepare() | 458 self.MakeStep().CommonPrepare() |
| 472 self.assertRaises(Exception, self.MakeStep().PrepareBranch) | 459 self.assertRaises(Exception, self.MakeStep().PrepareBranch) |
| 473 self.assertEquals("some_branch", self._state["current_branch"]) | 460 self.assertEquals("some_branch", self._state["current_branch"]) |
| 474 | 461 |
| 475 def testInitialEnvironmentChecks(self): | 462 def testInitialEnvironmentChecks(self): |
| 476 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 463 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 477 os.environ["EDITOR"] = "vi" | 464 os.environ["EDITOR"] = "vi" |
| 478 self.MakeStep().InitialEnvironmentChecks() | 465 self.MakeStep().InitialEnvironmentChecks() |
| 479 | 466 |
| 480 def testReadAndPersistVersion(self): | 467 def testReadAndPersistVersion(self): |
| (...skipping 22 matching lines...) Expand all Loading... |
| 503 " too much\n" | 490 " too much\n" |
| 504 " trailing", cl) | 491 " trailing", cl) |
| 505 | 492 |
| 506 self.assertEqual("//\n#define BUILD_NUMBER 3\n", | 493 self.assertEqual("//\n#define BUILD_NUMBER 3\n", |
| 507 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", | 494 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", |
| 508 r"\g<space>3", | 495 r"\g<space>3", |
| 509 "//\n#define BUILD_NUMBER 321\n")) | 496 "//\n#define BUILD_NUMBER 321\n")) |
| 510 | 497 |
| 511 def testPreparePushRevision(self): | 498 def testPreparePushRevision(self): |
| 512 # Tests the default push hash used when the --revision option is not set. | 499 # Tests the default push hash used when the --revision option is not set. |
| 513 self.ExpectCmd([ | 500 self.Expect([ |
| 514 Cmd("git log -1 --format=%H HEAD", "push_hash") | 501 Cmd("git log -1 --format=%H HEAD", "push_hash") |
| 515 ]) | 502 ]) |
| 516 | 503 |
| 517 self.RunStep(PushToTrunk, PreparePushRevision) | 504 self.RunStep(PushToTrunk, PreparePushRevision) |
| 518 self.assertEquals("push_hash", self._state["push_hash"]) | 505 self.assertEquals("push_hash", self._state["push_hash"]) |
| 519 | 506 |
| 520 def testPrepareChangeLog(self): | 507 def testPrepareChangeLog(self): |
| 521 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 508 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 522 self.WriteFakeVersionFile() | 509 self.WriteFakeVersionFile() |
| 523 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 510 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 524 | 511 |
| 525 self.ExpectCmd([ | 512 self.Expect([ |
| 526 Cmd("git log --format=%H 1234..push_hash", "rev1\nrev2\nrev3\nrev4"), | 513 Cmd("git log --format=%H 1234..push_hash", "rev1\nrev2\nrev3\nrev4"), |
| 527 Cmd("git log -1 --format=%s rev1", "Title text 1"), | 514 Cmd("git log -1 --format=%s rev1", "Title text 1"), |
| 528 Cmd("git log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"), | 515 Cmd("git log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"), |
| 529 Cmd("git log -1 --format=%an rev1", "author1@chromium.org"), | 516 Cmd("git log -1 --format=%an rev1", "author1@chromium.org"), |
| 530 Cmd("git log -1 --format=%s rev2", "Title text 2."), | 517 Cmd("git log -1 --format=%s rev2", "Title text 2."), |
| 531 Cmd("git log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"), | 518 Cmd("git log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"), |
| 532 Cmd("git log -1 --format=%an rev2", "author2@chromium.org"), | 519 Cmd("git log -1 --format=%an rev2", "author2@chromium.org"), |
| 533 Cmd("git log -1 --format=%s rev3", "Title text 3"), | 520 Cmd("git log -1 --format=%s rev3", "Title text 3"), |
| 534 Cmd("git log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"), | 521 Cmd("git log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"), |
| 535 Cmd("git log -1 --format=%an rev3", "author3@chromium.org"), | 522 Cmd("git log -1 --format=%an rev3", "author3@chromium.org"), |
| 536 Cmd("git log -1 --format=%s rev4", "Title text 4"), | 523 Cmd("git log -1 --format=%s rev4", "Title text 4"), |
| 537 Cmd("git log -1 --format=%B rev4", | 524 Cmd("git log -1 --format=%B rev4", |
| 538 ("Title\n\nBUG=456\nLOG=Y\n\n" | 525 ("Title\n\nBUG=456\nLOG=Y\n\n" |
| 539 "Review URL: https://codereview.chromium.org/9876543210\n")), | 526 "Review URL: https://codereview.chromium.org/9876543210\n")), |
| 527 URL("https://codereview.chromium.org/9876543210/description", |
| 528 "Title\n\nBUG=456\nLOG=N\n\n"), |
| 540 Cmd("git log -1 --format=%an rev4", "author4@chromium.org"), | 529 Cmd("git log -1 --format=%an rev4", "author4@chromium.org"), |
| 541 ]) | 530 ]) |
| 542 | 531 |
| 543 # The cl for rev4 on rietveld has an updated LOG flag. | |
| 544 self.ExpectReadURL([ | |
| 545 URL("https://codereview.chromium.org/9876543210/description", | |
| 546 "Title\n\nBUG=456\nLOG=N\n\n"), | |
| 547 ]) | |
| 548 | |
| 549 self._state["last_push_bleeding_edge"] = "1234" | 532 self._state["last_push_bleeding_edge"] = "1234" |
| 550 self._state["push_hash"] = "push_hash" | 533 self._state["push_hash"] = "push_hash" |
| 551 self._state["version"] = "3.22.5" | 534 self._state["version"] = "3.22.5" |
| 552 self.RunStep(PushToTrunk, PrepareChangeLog) | 535 self.RunStep(PushToTrunk, PrepareChangeLog) |
| 553 | 536 |
| 554 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 537 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| 555 | 538 |
| 556 expected_cl = """1999-07-31: Version 3.22.5 | 539 expected_cl = """1999-07-31: Version 3.22.5 |
| 557 | 540 |
| 558 Title text 1. | 541 Title text 1. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 578 # (author4@chromium.org) | 561 # (author4@chromium.org) |
| 579 # | 562 # |
| 580 #""" | 563 #""" |
| 581 | 564 |
| 582 self.assertEquals(expected_cl, actual_cl) | 565 self.assertEquals(expected_cl, actual_cl) |
| 583 | 566 |
| 584 def testEditChangeLog(self): | 567 def testEditChangeLog(self): |
| 585 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 568 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 586 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 569 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| 587 os.environ["EDITOR"] = "vi" | 570 os.environ["EDITOR"] = "vi" |
| 588 self.ExpectCmd([ | 571 self.Expect([ |
| 572 RL(""), # Open editor. |
| 589 Cmd("vi %s" % TEST_CONFIG[CHANGELOG_ENTRY_FILE], ""), | 573 Cmd("vi %s" % TEST_CONFIG[CHANGELOG_ENTRY_FILE], ""), |
| 590 ]) | 574 ]) |
| 591 self.ExpectReadline([ | |
| 592 RL(""), # Open editor. | |
| 593 ]) | |
| 594 | 575 |
| 595 self.RunStep(PushToTrunk, EditChangeLog) | 576 self.RunStep(PushToTrunk, EditChangeLog) |
| 596 | 577 |
| 597 self.assertEquals("New\n Lines", | 578 self.assertEquals("New\n Lines", |
| 598 FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])) | 579 FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])) |
| 599 | 580 |
| 600 # Version on trunk: 3.22.4.0. Version on master (bleeding_edge): 3.22.6. | 581 # Version on trunk: 3.22.4.0. Version on master (bleeding_edge): 3.22.6. |
| 601 # Make sure that the increment is 3.22.7.0. | 582 # Make sure that the increment is 3.22.7.0. |
| 602 def testIncrementVersion(self): | 583 def testIncrementVersion(self): |
| 603 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 584 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 604 self.WriteFakeVersionFile() | 585 self.WriteFakeVersionFile() |
| 605 self._state["last_push_trunk"] = "hash1" | 586 self._state["last_push_trunk"] = "hash1" |
| 606 self._state["latest_build"] = "6" | 587 self._state["latest_build"] = "6" |
| 607 self._state["latest_version"] = "3.22.6.0" | 588 self._state["latest_version"] = "3.22.6.0" |
| 608 | 589 |
| 609 self.ExpectCmd([ | 590 self.Expect([ |
| 610 Cmd("git checkout -f hash1 -- %s" % TEST_CONFIG[VERSION_FILE], ""), | 591 Cmd("git checkout -f hash1 -- %s" % TEST_CONFIG[VERSION_FILE], ""), |
| 611 Cmd(("git checkout -f svn/bleeding_edge -- %s" % | 592 Cmd(("git checkout -f svn/bleeding_edge -- %s" % |
| 612 TEST_CONFIG[VERSION_FILE]), | 593 TEST_CONFIG[VERSION_FILE]), |
| 613 "", cb=lambda: self.WriteFakeVersionFile(22, 6)), | 594 "", cb=lambda: self.WriteFakeVersionFile(22, 6)), |
| 614 ]) | |
| 615 | |
| 616 self.ExpectReadline([ | |
| 617 RL("Y"), # Increment build number. | 595 RL("Y"), # Increment build number. |
| 618 ]) | 596 ]) |
| 619 | 597 |
| 620 self.RunStep(PushToTrunk, IncrementVersion) | 598 self.RunStep(PushToTrunk, IncrementVersion) |
| 621 | 599 |
| 622 self.assertEquals("3", self._state["new_major"]) | 600 self.assertEquals("3", self._state["new_major"]) |
| 623 self.assertEquals("22", self._state["new_minor"]) | 601 self.assertEquals("22", self._state["new_minor"]) |
| 624 self.assertEquals("7", self._state["new_build"]) | 602 self.assertEquals("7", self._state["new_build"]) |
| 625 self.assertEquals("0", self._state["new_patch"]) | 603 self.assertEquals("0", self._state["new_patch"]) |
| 626 | 604 |
| 627 def _TestSquashCommits(self, change_log, expected_msg): | 605 def _TestSquashCommits(self, change_log, expected_msg): |
| 628 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 606 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 629 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: | 607 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: |
| 630 f.write(change_log) | 608 f.write(change_log) |
| 631 | 609 |
| 632 self.ExpectCmd([ | 610 self.Expect([ |
| 633 Cmd("git diff svn/trunk hash1", "patch content"), | 611 Cmd("git diff svn/trunk hash1", "patch content"), |
| 634 Cmd("git svn find-rev hash1", "123455\n"), | 612 Cmd("git svn find-rev hash1", "123455\n"), |
| 635 ]) | 613 ]) |
| 636 | 614 |
| 637 self._state["push_hash"] = "hash1" | 615 self._state["push_hash"] = "hash1" |
| 638 self._state["date"] = "1999-11-11" | 616 self._state["date"] = "1999-11-11" |
| 639 | 617 |
| 640 self.RunStep(PushToTrunk, SquashCommits) | 618 self.RunStep(PushToTrunk, SquashCommits) |
| 641 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg) | 619 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg) |
| 642 | 620 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 Cmd("git svn fetch", ""), | 717 Cmd("git svn fetch", ""), |
| 740 Cmd("git branch", " branch1\n* branch2\n"), | 718 Cmd("git branch", " branch1\n* branch2\n"), |
| 741 Cmd("git branch", " branch1\n* branch2\n"), | 719 Cmd("git branch", " branch1\n* branch2\n"), |
| 742 Cmd("git checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], | 720 Cmd("git checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], |
| 743 ""), | 721 ""), |
| 744 Cmd("git svn find-rev r123455", "push_hash\n"), | 722 Cmd("git svn find-rev r123455", "push_hash\n"), |
| 745 Cmd(("git log -1 --format=%H --grep=" | 723 Cmd(("git log -1 --format=%H --grep=" |
| 746 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " | 724 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " |
| 747 "svn/trunk"), "hash2\n"), | 725 "svn/trunk"), "hash2\n"), |
| 748 Cmd("git log -1 hash2", "Log message\n"), | 726 Cmd("git log -1 hash2", "Log message\n"), |
| 727 ] |
| 728 if manual: |
| 729 expectations.append(RL("Y")) # Confirm last push. |
| 730 expectations += [ |
| 749 Cmd("git log -1 --format=%s hash2", | 731 Cmd("git log -1 --format=%s hash2", |
| 750 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"), | 732 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"), |
| 751 Cmd("git svn find-rev r1234", "hash3\n"), | 733 Cmd("git svn find-rev r1234", "hash3\n"), |
| 752 Cmd(("git checkout -f svn/bleeding_edge -- %s" % | 734 Cmd(("git checkout -f svn/bleeding_edge -- %s" % |
| 753 TEST_CONFIG[VERSION_FILE]), | 735 TEST_CONFIG[VERSION_FILE]), |
| 754 "", cb=self.WriteFakeVersionFile), | 736 "", cb=self.WriteFakeVersionFile), |
| 755 Cmd("git checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "", | 737 Cmd("git checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 756 cb=self.WriteFakeVersionFile), | 738 cb=self.WriteFakeVersionFile), |
| 739 ] |
| 740 if manual: |
| 741 expectations.append(RL("")) # Increment build number. |
| 742 expectations += [ |
| 757 Cmd("git log --format=%H hash3..push_hash", "rev1\n"), | 743 Cmd("git log --format=%H hash3..push_hash", "rev1\n"), |
| 758 Cmd("git log -1 --format=%s rev1", "Log text 1.\n"), | 744 Cmd("git log -1 --format=%s rev1", "Log text 1.\n"), |
| 759 Cmd("git log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"), | 745 Cmd("git log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"), |
| 760 Cmd("git log -1 --format=%an rev1", "author1@chromium.org\n"), | 746 Cmd("git log -1 --format=%an rev1", "author1@chromium.org\n"), |
| 761 ] | 747 ] |
| 748 if manual: |
| 749 expectations.append(RL("")) # Open editor. |
| 762 if not force: | 750 if not force: |
| 763 expectations.append(Cmd("vi %s" % TEST_CONFIG[CHANGELOG_ENTRY_FILE], "")) | 751 expectations.append(Cmd("vi %s" % TEST_CONFIG[CHANGELOG_ENTRY_FILE], "")) |
| 764 expectations += [ | 752 expectations += [ |
| 765 Cmd("git svn fetch", "fetch result\n"), | 753 Cmd("git svn fetch", "fetch result\n"), |
| 766 Cmd("git checkout -f svn/bleeding_edge", ""), | 754 Cmd("git checkout -f svn/bleeding_edge", ""), |
| 767 Cmd("git diff svn/trunk push_hash", "patch content\n"), | 755 Cmd("git diff svn/trunk push_hash", "patch content\n"), |
| 768 Cmd("git svn find-rev push_hash", "123455\n"), | 756 Cmd("git svn find-rev push_hash", "123455\n"), |
| 769 Cmd("git checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], "", | 757 Cmd("git checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], "", |
| 770 cb=ResetToTrunk), | 758 cb=ResetToTrunk), |
| 771 Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""), | 759 Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""), |
| 772 Cmd("git checkout -f svn/trunk -- %s" % TEST_CONFIG[CHANGELOG_FILE], "", | 760 Cmd("git checkout -f svn/trunk -- %s" % TEST_CONFIG[CHANGELOG_FILE], "", |
| 773 cb=ResetChangeLog), | 761 cb=ResetChangeLog), |
| 774 Cmd("git checkout -f svn/trunk -- %s" % TEST_CONFIG[VERSION_FILE], "", | 762 Cmd("git checkout -f svn/trunk -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 775 cb=self.WriteFakeVersionFile), | 763 cb=self.WriteFakeVersionFile), |
| 776 Cmd("git commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", | 764 Cmd("git commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", |
| 777 cb=CheckSVNCommit), | 765 cb=CheckSVNCommit), |
| 766 ] |
| 767 if manual: |
| 768 expectations.append(RL("Y")) # Sanity check. |
| 769 expectations += [ |
| 778 Cmd("git svn dcommit 2>&1", | 770 Cmd("git svn dcommit 2>&1", |
| 779 "Some output\nCommitted r123456\nSome output\n"), | 771 "Some output\nCommitted r123456\nSome output\n"), |
| 780 Cmd("git svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""), | 772 Cmd("git svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""), |
| 781 Cmd("git checkout -f some_branch", ""), | 773 Cmd("git checkout -f some_branch", ""), |
| 782 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), | 774 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), |
| 783 Cmd("git branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""), | 775 Cmd("git branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""), |
| 784 ] | 776 ] |
| 785 self.ExpectCmd(expectations) | 777 self.Expect(expectations) |
| 786 | |
| 787 # Expected keyboard input in manual mode: | |
| 788 if manual: | |
| 789 self.ExpectReadline([ | |
| 790 RL("Y"), # Confirm last push. | |
| 791 RL(""), # Open editor. | |
| 792 RL("Y"), # Increment build number. | |
| 793 RL("Y"), # Sanity check. | |
| 794 ]) | |
| 795 | |
| 796 # Expected keyboard input in semi-automatic mode and forced mode: | |
| 797 if not manual: | |
| 798 self.ExpectReadline([]) | |
| 799 | 778 |
| 800 args = ["-a", "author@chromium.org", "--revision", "123455"] | 779 args = ["-a", "author@chromium.org", "--revision", "123455"] |
| 801 if force: args.append("-f") | 780 if force: args.append("-f") |
| 802 if manual: args.append("-m") | 781 if manual: args.append("-m") |
| 803 else: args += ["-r", "reviewer@chromium.org"] | 782 else: args += ["-r", "reviewer@chromium.org"] |
| 804 PushToTrunk(TEST_CONFIG, self).Run(args) | 783 PushToTrunk(TEST_CONFIG, self).Run(args) |
| 805 | 784 |
| 806 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) | 785 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) |
| 807 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) | 786 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) |
| 808 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) | 787 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 836 if not os.path.exists(os.path.join(TEST_CONFIG[CHROMIUM], "v8")): | 815 if not os.path.exists(os.path.join(TEST_CONFIG[CHROMIUM], "v8")): |
| 837 os.makedirs(os.path.join(TEST_CONFIG[CHROMIUM], "v8")) | 816 os.makedirs(os.path.join(TEST_CONFIG[CHROMIUM], "v8")) |
| 838 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", | 817 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", |
| 839 TEST_CONFIG[DEPS_FILE]) | 818 TEST_CONFIG[DEPS_FILE]) |
| 840 def WriteDeps(): | 819 def WriteDeps(): |
| 841 TextToFile("Some line\n \"v8_revision\": \"123455\",\n some line", | 820 TextToFile("Some line\n \"v8_revision\": \"123455\",\n some line", |
| 842 TEST_CONFIG[DEPS_FILE]) | 821 TEST_CONFIG[DEPS_FILE]) |
| 843 | 822 |
| 844 os.environ["EDITOR"] = "vi" | 823 os.environ["EDITOR"] = "vi" |
| 845 force_flag = " -f" if not manual else "" | 824 force_flag = " -f" if not manual else "" |
| 846 self.ExpectCmd([ | 825 expectations = [ |
| 847 Cmd("git status -s -uno", ""), | 826 Cmd("git status -s -uno", ""), |
| 848 Cmd("git status -s -b -uno", "## some_branch\n"), | 827 Cmd("git status -s -b -uno", "## some_branch\n"), |
| 849 Cmd("git svn fetch", ""), | 828 Cmd("git svn fetch", ""), |
| 850 Cmd(("git log -1 --format=%H --grep=" | 829 Cmd(("git log -1 --format=%H --grep=" |
| 851 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" " | 830 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" " |
| 852 "svn/trunk"), "push_hash\n"), | 831 "svn/trunk"), "push_hash\n"), |
| 853 Cmd("git svn find-rev push_hash", "123455\n"), | 832 Cmd("git svn find-rev push_hash", "123455\n"), |
| 854 Cmd("git log -1 --format=%s push_hash", | 833 Cmd("git log -1 --format=%s push_hash", |
| 855 "Version 3.22.5 (based on bleeding_edge revision r123454)\n"), | 834 "Version 3.22.5 (based on bleeding_edge revision r123454)\n"), |
| 835 URL("https://chromium-build.appspot.com/p/chromium/sheriff_v8.js", |
| 836 "document.write('g_name')"), |
| 856 Cmd("git status -s -uno", ""), | 837 Cmd("git status -s -uno", ""), |
| 857 Cmd("git checkout -f master", ""), | 838 Cmd("git checkout -f master", ""), |
| 858 Cmd("gclient sync --nohooks", "syncing..."), | 839 Cmd("gclient sync --nohooks", "syncing..."), |
| 859 Cmd("git pull", ""), | 840 Cmd("git pull", ""), |
| 860 Cmd("git fetch origin", ""), | 841 Cmd("git fetch origin", ""), |
| 861 Cmd("git checkout -b v8-roll-123455", ""), | 842 Cmd("git checkout -b v8-roll-123455", ""), |
| 862 Cmd("roll-dep v8 123455", "rolled", cb=WriteDeps), | 843 Cmd("roll-dep v8 123455", "rolled", cb=WriteDeps), |
| 844 ] |
| 845 if manual: |
| 846 expectations.append(RL("c_name@chromium.org")) # Chromium reviewer. |
| 847 expectations += [ |
| 863 Cmd(("git commit -am \"Update V8 to version 3.22.5 " | 848 Cmd(("git commit -am \"Update V8 to version 3.22.5 " |
| 864 "(based on bleeding_edge revision r123454).\n\n" | 849 "(based on bleeding_edge revision r123454).\n\n" |
| 865 "Please reply to the V8 sheriff c_name@chromium.org in " | 850 "Please reply to the V8 sheriff c_name@chromium.org in " |
| 866 "case of problems.\n\nTBR=c_name@chromium.org\""), | 851 "case of problems.\n\nTBR=c_name@chromium.org\""), |
| 867 ""), | 852 ""), |
| 868 Cmd(("git cl upload --send-mail --email \"author@chromium.org\"%s" | 853 Cmd(("git cl upload --send-mail --email \"author@chromium.org\"%s" |
| 869 % force_flag), ""), | 854 % force_flag), ""), |
| 870 ]) | 855 ] |
| 871 | 856 self.Expect(expectations) |
| 872 self.ExpectReadURL([ | |
| 873 URL("https://chromium-build.appspot.com/p/chromium/sheriff_v8.js", | |
| 874 "document.write('g_name')"), | |
| 875 ]) | |
| 876 | |
| 877 # Expected keyboard input in manual mode: | |
| 878 if manual: | |
| 879 self.ExpectReadline([ | |
| 880 RL("c_name@chromium.org"), # Chromium reviewer. | |
| 881 ]) | |
| 882 | |
| 883 # Expected keyboard input in semi-automatic mode and forced mode: | |
| 884 if not manual: | |
| 885 self.ExpectReadline([]) | |
| 886 | 857 |
| 887 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM], | 858 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM], |
| 888 "--sheriff", "--googlers-mapping", googlers_mapping_py] | 859 "--sheriff", "--googlers-mapping", googlers_mapping_py] |
| 889 if force: args.append("-f") | 860 if force: args.append("-f") |
| 890 if manual: args.append("-m") | 861 if manual: args.append("-m") |
| 891 else: args += ["-r", "reviewer@chromium.org"] | 862 else: args += ["-r", "reviewer@chromium.org"] |
| 892 ChromiumRoll(TEST_CONFIG, self).Run(args) | 863 ChromiumRoll(TEST_CONFIG, self).Run(args) |
| 893 | 864 |
| 894 deps = FileToText(TEST_CONFIG[DEPS_FILE]) | 865 deps = FileToText(TEST_CONFIG[DEPS_FILE]) |
| 895 self.assertTrue(re.search("\"v8_revision\": \"123455\"", deps)) | 866 self.assertTrue(re.search("\"v8_revision\": \"123455\"", deps)) |
| 896 | 867 |
| 897 def testChromiumRollManual(self): | 868 def testChromiumRollManual(self): |
| 898 self._ChromiumRoll(manual=True) | 869 self._ChromiumRoll(manual=True) |
| 899 | 870 |
| 900 def testChromiumRollSemiAutomatic(self): | 871 def testChromiumRollSemiAutomatic(self): |
| 901 self._ChromiumRoll() | 872 self._ChromiumRoll() |
| 902 | 873 |
| 903 def testChromiumRollForced(self): | 874 def testChromiumRollForced(self): |
| 904 self._ChromiumRoll(force=True) | 875 self._ChromiumRoll(force=True) |
| 905 | 876 |
| 906 def testCheckLastPushRecently(self): | 877 def testCheckLastPushRecently(self): |
| 907 self.ExpectCmd([ | 878 self.Expect([ |
| 908 Cmd(("git log -1 --format=%H --grep=" | 879 Cmd(("git log -1 --format=%H --grep=" |
| 909 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " | 880 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " |
| 910 "svn/trunk"), "hash2\n"), | 881 "svn/trunk"), "hash2\n"), |
| 911 Cmd("git log -1 --format=%s hash2", | 882 Cmd("git log -1 --format=%s hash2", |
| 912 "Version 3.4.5 (based on bleeding_edge revision r99)\n"), | 883 "Version 3.4.5 (based on bleeding_edge revision r99)\n"), |
| 913 ]) | 884 ]) |
| 914 | 885 |
| 915 self._state["lkgr"] = "101" | 886 self._state["lkgr"] = "101" |
| 916 | 887 |
| 917 self.assertRaises(Exception, lambda: self.RunStep(auto_push.AutoPush, | 888 self.assertRaises(Exception, lambda: self.RunStep(auto_push.AutoPush, |
| 918 CheckLastPush, | 889 CheckLastPush, |
| 919 AUTO_PUSH_ARGS)) | 890 AUTO_PUSH_ARGS)) |
| 920 | 891 |
| 921 def testAutoPush(self): | 892 def testAutoPush(self): |
| 922 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 893 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 923 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" | 894 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
| 924 | 895 |
| 925 self.ExpectReadURL([ | 896 self.Expect([ |
| 897 Cmd("git status -s -uno", ""), |
| 898 Cmd("git status -s -b -uno", "## some_branch\n"), |
| 899 Cmd("git svn fetch", ""), |
| 926 URL("https://v8-status.appspot.com/current?format=json", | 900 URL("https://v8-status.appspot.com/current?format=json", |
| 927 "{\"message\": \"Tree is throttled\"}"), | 901 "{\"message\": \"Tree is throttled\"}"), |
| 928 URL("https://v8-status.appspot.com/lkgr", Exception("Network problem")), | 902 URL("https://v8-status.appspot.com/lkgr", Exception("Network problem")), |
| 929 URL("https://v8-status.appspot.com/lkgr", "100"), | 903 URL("https://v8-status.appspot.com/lkgr", "100"), |
| 930 ]) | |
| 931 | |
| 932 self.ExpectCmd([ | |
| 933 Cmd("git status -s -uno", ""), | |
| 934 Cmd("git status -s -b -uno", "## some_branch\n"), | |
| 935 Cmd("git svn fetch", ""), | |
| 936 Cmd(("git log -1 --format=%H --grep=\"" | 904 Cmd(("git log -1 --format=%H --grep=\"" |
| 937 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" | 905 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" |
| 938 " svn/trunk"), "push_hash\n"), | 906 " svn/trunk"), "push_hash\n"), |
| 939 Cmd("git log -1 --format=%s push_hash", | 907 Cmd("git log -1 --format=%s push_hash", |
| 940 "Version 3.4.5 (based on bleeding_edge revision r79)\n"), | 908 "Version 3.4.5 (based on bleeding_edge revision r79)\n"), |
| 941 ]) | 909 ]) |
| 942 | 910 |
| 943 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS + ["--push"]) | 911 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS + ["--push"]) |
| 944 | 912 |
| 945 state = json.loads(FileToText("%s-state.json" | 913 state = json.loads(FileToText("%s-state.json" |
| 946 % TEST_CONFIG[PERSISTFILE_BASENAME])) | 914 % TEST_CONFIG[PERSISTFILE_BASENAME])) |
| 947 | 915 |
| 948 self.assertEquals("100", state["lkgr"]) | 916 self.assertEquals("100", state["lkgr"]) |
| 949 | 917 |
| 950 def testAutoPushStoppedBySettings(self): | 918 def testAutoPushStoppedBySettings(self): |
| 951 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 919 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 952 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() | 920 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() |
| 953 TextToFile("{\"enable_auto_push\": false}", TEST_CONFIG[SETTINGS_LOCATION]) | 921 TextToFile("{\"enable_auto_push\": false}", TEST_CONFIG[SETTINGS_LOCATION]) |
| 954 | 922 |
| 955 self.ExpectReadURL([]) | 923 self.Expect([ |
| 956 | |
| 957 self.ExpectCmd([ | |
| 958 Cmd("git status -s -uno", ""), | 924 Cmd("git status -s -uno", ""), |
| 959 Cmd("git status -s -b -uno", "## some_branch\n"), | 925 Cmd("git status -s -b -uno", "## some_branch\n"), |
| 960 Cmd("git svn fetch", ""), | 926 Cmd("git svn fetch", ""), |
| 961 ]) | 927 ]) |
| 962 | 928 |
| 963 def RunAutoPush(): | 929 def RunAutoPush(): |
| 964 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS) | 930 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS) |
| 965 self.assertRaises(Exception, RunAutoPush) | 931 self.assertRaises(Exception, RunAutoPush) |
| 966 | 932 |
| 967 def testAutoPushStoppedByTreeStatus(self): | 933 def testAutoPushStoppedByTreeStatus(self): |
| 968 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 934 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 969 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" | 935 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
| 970 | 936 |
| 971 self.ExpectReadURL([ | 937 self.Expect([ |
| 938 Cmd("git status -s -uno", ""), |
| 939 Cmd("git status -s -b -uno", "## some_branch\n"), |
| 940 Cmd("git svn fetch", ""), |
| 972 URL("https://v8-status.appspot.com/current?format=json", | 941 URL("https://v8-status.appspot.com/current?format=json", |
| 973 "{\"message\": \"Tree is throttled (no push)\"}"), | 942 "{\"message\": \"Tree is throttled (no push)\"}"), |
| 974 ]) | 943 ]) |
| 975 | 944 |
| 976 self.ExpectCmd([ | |
| 977 Cmd("git status -s -uno", ""), | |
| 978 Cmd("git status -s -b -uno", "## some_branch\n"), | |
| 979 Cmd("git svn fetch", ""), | |
| 980 ]) | |
| 981 | |
| 982 def RunAutoPush(): | 945 def RunAutoPush(): |
| 983 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS) | 946 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS) |
| 984 self.assertRaises(Exception, RunAutoPush) | 947 self.assertRaises(Exception, RunAutoPush) |
| 985 | 948 |
| 986 def testAutoRollExistingRoll(self): | 949 def testAutoRollExistingRoll(self): |
| 987 self.ExpectReadURL([ | 950 self.Expect([ |
| 988 URL("https://codereview.chromium.org/search", | 951 URL("https://codereview.chromium.org/search", |
| 989 "owner=author%40chromium.org&limit=30&closed=3&format=json", | 952 "owner=author%40chromium.org&limit=30&closed=3&format=json", |
| 990 ("{\"results\": [{\"subject\": \"different\"}," | 953 ("{\"results\": [{\"subject\": \"different\"}," |
| 991 "{\"subject\": \"Update V8 to Version...\"}]}")), | 954 "{\"subject\": \"Update V8 to Version...\"}]}")), |
| 992 ]) | 955 ]) |
| 993 | 956 |
| 994 result = auto_roll.AutoRoll(TEST_CONFIG, self).Run( | 957 result = auto_roll.AutoRoll(TEST_CONFIG, self).Run( |
| 995 AUTO_PUSH_ARGS + ["-c", TEST_CONFIG[CHROMIUM]]) | 958 AUTO_PUSH_ARGS + ["-c", TEST_CONFIG[CHROMIUM]]) |
| 996 self.assertEquals(1, result) | 959 self.assertEquals(1, result) |
| 997 | 960 |
| 998 # Snippet from the original DEPS file. | 961 # Snippet from the original DEPS file. |
| 999 FAKE_DEPS = """ | 962 FAKE_DEPS = """ |
| 1000 vars = { | 963 vars = { |
| 1001 "v8_revision": "123455", | 964 "v8_revision": "123455", |
| 1002 } | 965 } |
| 1003 deps = { | 966 deps = { |
| 1004 "src/v8": | 967 "src/v8": |
| 1005 (Var("googlecode_url") % "v8") + "/" + Var("v8_branch") + "@" + | 968 (Var("googlecode_url") % "v8") + "/" + Var("v8_branch") + "@" + |
| 1006 Var("v8_revision"), | 969 Var("v8_revision"), |
| 1007 } | 970 } |
| 1008 """ | 971 """ |
| 1009 | 972 |
| 1010 def testAutoRollUpToDate(self): | 973 def testAutoRollUpToDate(self): |
| 1011 self.ExpectReadURL([ | 974 self.Expect([ |
| 1012 URL("https://codereview.chromium.org/search", | 975 URL("https://codereview.chromium.org/search", |
| 1013 "owner=author%40chromium.org&limit=30&closed=3&format=json", | 976 "owner=author%40chromium.org&limit=30&closed=3&format=json", |
| 1014 ("{\"results\": [{\"subject\": \"different\"}]}")), | 977 ("{\"results\": [{\"subject\": \"different\"}]}")), |
| 978 Cmd(("git log -1 --format=%H --grep=" |
| 979 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" " |
| 980 "svn/trunk"), "push_hash\n"), |
| 981 Cmd("git svn find-rev push_hash", "123455\n"), |
| 1015 URL("http://src.chromium.org/svn/trunk/src/DEPS", | 982 URL("http://src.chromium.org/svn/trunk/src/DEPS", |
| 1016 self.FAKE_DEPS), | 983 self.FAKE_DEPS), |
| 1017 ]) | 984 ]) |
| 1018 | 985 |
| 1019 self.ExpectCmd([ | |
| 1020 Cmd(("git log -1 --format=%H --grep=" | |
| 1021 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" " | |
| 1022 "svn/trunk"), "push_hash\n"), | |
| 1023 Cmd("git svn find-rev push_hash", "123455\n"), | |
| 1024 ]) | |
| 1025 | |
| 1026 result = auto_roll.AutoRoll(TEST_CONFIG, self).Run( | 986 result = auto_roll.AutoRoll(TEST_CONFIG, self).Run( |
| 1027 AUTO_PUSH_ARGS + ["-c", TEST_CONFIG[CHROMIUM]]) | 987 AUTO_PUSH_ARGS + ["-c", TEST_CONFIG[CHROMIUM]]) |
| 1028 self.assertEquals(1, result) | 988 self.assertEquals(1, result) |
| 1029 | 989 |
| 1030 def testAutoRoll(self): | 990 def testAutoRoll(self): |
| 1031 TEST_CONFIG[CLUSTERFUZZ_API_KEY_FILE] = self.MakeEmptyTempFile() | 991 TEST_CONFIG[CLUSTERFUZZ_API_KEY_FILE] = self.MakeEmptyTempFile() |
| 1032 TextToFile("fake key", TEST_CONFIG[CLUSTERFUZZ_API_KEY_FILE]) | 992 TextToFile("fake key", TEST_CONFIG[CLUSTERFUZZ_API_KEY_FILE]) |
| 1033 self.ExpectReadURL([ | 993 |
| 994 self.Expect([ |
| 1034 URL("https://codereview.chromium.org/search", | 995 URL("https://codereview.chromium.org/search", |
| 1035 "owner=author%40chromium.org&limit=30&closed=3&format=json", | 996 "owner=author%40chromium.org&limit=30&closed=3&format=json", |
| 1036 ("{\"results\": [{\"subject\": \"different\"}]}")), | 997 ("{\"results\": [{\"subject\": \"different\"}]}")), |
| 998 Cmd(("git log -1 --format=%H --grep=" |
| 999 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" " |
| 1000 "svn/trunk"), "push_hash\n"), |
| 1001 Cmd("git svn find-rev push_hash", "123456\n"), |
| 1037 URL("http://src.chromium.org/svn/trunk/src/DEPS", | 1002 URL("http://src.chromium.org/svn/trunk/src/DEPS", |
| 1038 self.FAKE_DEPS), | 1003 self.FAKE_DEPS), |
| 1039 ]) | 1004 ]) |
| 1040 | 1005 |
| 1041 self.ExpectCmd([ | |
| 1042 Cmd(("git log -1 --format=%H --grep=" | |
| 1043 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\" " | |
| 1044 "svn/trunk"), "push_hash\n"), | |
| 1045 Cmd("git svn find-rev push_hash", "123456\n"), | |
| 1046 ]) | |
| 1047 | |
| 1048 result = auto_roll.AutoRoll(TEST_CONFIG, self).Run( | 1006 result = auto_roll.AutoRoll(TEST_CONFIG, self).Run( |
| 1049 AUTO_PUSH_ARGS + ["-c", TEST_CONFIG[CHROMIUM], "--roll"]) | 1007 AUTO_PUSH_ARGS + ["-c", TEST_CONFIG[CHROMIUM], "--roll"]) |
| 1050 self.assertEquals(0, result) | 1008 self.assertEquals(0, result) |
| 1051 | 1009 |
| 1052 def testMergeToBranch(self): | 1010 def testMergeToBranch(self): |
| 1053 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() | 1011 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() |
| 1054 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 1012 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 1055 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 1013 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 1056 self.WriteFakeVersionFile(build=5) | 1014 self.WriteFakeVersionFile(build=5) |
| 1057 os.environ["EDITOR"] = "vi" | 1015 os.environ["EDITOR"] = "vi" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1079 | 1037 |
| 1080 def VerifySVNCommit(): | 1038 def VerifySVNCommit(): |
| 1081 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) | 1039 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) |
| 1082 self.assertEquals(msg, commit) | 1040 self.assertEquals(msg, commit) |
| 1083 version = FileToText(TEST_CONFIG[VERSION_FILE]) | 1041 version = FileToText(TEST_CONFIG[VERSION_FILE]) |
| 1084 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) | 1042 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) |
| 1085 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) | 1043 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) |
| 1086 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version)) | 1044 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version)) |
| 1087 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) | 1045 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) |
| 1088 | 1046 |
| 1089 self.ExpectCmd([ | 1047 self.Expect([ |
| 1090 Cmd("git status -s -uno", ""), | 1048 Cmd("git status -s -uno", ""), |
| 1091 Cmd("git status -s -b -uno", "## some_branch\n"), | 1049 Cmd("git status -s -b -uno", "## some_branch\n"), |
| 1092 Cmd("git svn fetch", ""), | 1050 Cmd("git svn fetch", ""), |
| 1093 Cmd("git branch", " branch1\n* branch2\n"), | 1051 Cmd("git branch", " branch1\n* branch2\n"), |
| 1094 Cmd("git checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""), | 1052 Cmd("git checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""), |
| 1095 Cmd(("git log --format=%H --grep=\"Port r12345\" " | 1053 Cmd(("git log --format=%H --grep=\"Port r12345\" " |
| 1096 "--reverse svn/bleeding_edge"), | 1054 "--reverse svn/bleeding_edge"), |
| 1097 "hash1\nhash2"), | 1055 "hash1\nhash2"), |
| 1098 Cmd("git svn find-rev hash1 svn/bleeding_edge", "45678"), | 1056 Cmd("git svn find-rev hash1 svn/bleeding_edge", "45678"), |
| 1099 Cmd("git log -1 --format=%s hash1", "Title1"), | 1057 Cmd("git log -1 --format=%s hash1", "Title1"), |
| 1100 Cmd("git svn find-rev hash2 svn/bleeding_edge", "23456"), | 1058 Cmd("git svn find-rev hash2 svn/bleeding_edge", "23456"), |
| 1101 Cmd("git log -1 --format=%s hash2", "Title2"), | 1059 Cmd("git log -1 --format=%s hash2", "Title2"), |
| 1102 Cmd(("git log --format=%H --grep=\"Port r23456\" " | 1060 Cmd(("git log --format=%H --grep=\"Port r23456\" " |
| 1103 "--reverse svn/bleeding_edge"), | 1061 "--reverse svn/bleeding_edge"), |
| 1104 ""), | 1062 ""), |
| 1105 Cmd(("git log --format=%H --grep=\"Port r34567\" " | 1063 Cmd(("git log --format=%H --grep=\"Port r34567\" " |
| 1106 "--reverse svn/bleeding_edge"), | 1064 "--reverse svn/bleeding_edge"), |
| 1107 "hash3"), | 1065 "hash3"), |
| 1108 Cmd("git svn find-rev hash3 svn/bleeding_edge", "56789"), | 1066 Cmd("git svn find-rev hash3 svn/bleeding_edge", "56789"), |
| 1109 Cmd("git log -1 --format=%s hash3", "Title3"), | 1067 Cmd("git log -1 --format=%s hash3", "Title3"), |
| 1068 RL("Y"), # Automatically add corresponding ports (34567, 56789)? |
| 1110 Cmd("git svn find-rev r12345 svn/bleeding_edge", "hash4"), | 1069 Cmd("git svn find-rev r12345 svn/bleeding_edge", "hash4"), |
| 1111 # Simulate svn being down which stops the script. | 1070 # Simulate svn being down which stops the script. |
| 1112 Cmd("git svn find-rev r23456 svn/bleeding_edge", None), | 1071 Cmd("git svn find-rev r23456 svn/bleeding_edge", None), |
| 1113 # Restart script in the failing step. | 1072 # Restart script in the failing step. |
| 1114 Cmd("git svn find-rev r12345 svn/bleeding_edge", "hash4"), | 1073 Cmd("git svn find-rev r12345 svn/bleeding_edge", "hash4"), |
| 1115 Cmd("git svn find-rev r23456 svn/bleeding_edge", "hash2"), | 1074 Cmd("git svn find-rev r23456 svn/bleeding_edge", "hash2"), |
| 1116 Cmd("git svn find-rev r34567 svn/bleeding_edge", "hash3"), | 1075 Cmd("git svn find-rev r34567 svn/bleeding_edge", "hash3"), |
| 1117 Cmd("git svn find-rev r45678 svn/bleeding_edge", "hash1"), | 1076 Cmd("git svn find-rev r45678 svn/bleeding_edge", "hash1"), |
| 1118 Cmd("git svn find-rev r56789 svn/bleeding_edge", "hash5"), | 1077 Cmd("git svn find-rev r56789 svn/bleeding_edge", "hash5"), |
| 1119 Cmd("git log -1 --format=%s hash4", "Title4"), | 1078 Cmd("git log -1 --format=%s hash4", "Title4"), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1140 "", cb=VerifyPatch("patch3")), | 1099 "", cb=VerifyPatch("patch3")), |
| 1141 Cmd("git log -1 -p hash1", "patch1"), | 1100 Cmd("git log -1 -p hash1", "patch1"), |
| 1142 Cmd(("git apply --index --reject \"%s\"" % | 1101 Cmd(("git apply --index --reject \"%s\"" % |
| 1143 TEST_CONFIG[TEMPORARY_PATCH_FILE]), | 1102 TEST_CONFIG[TEMPORARY_PATCH_FILE]), |
| 1144 "", cb=VerifyPatch("patch1")), | 1103 "", cb=VerifyPatch("patch1")), |
| 1145 Cmd("git log -1 -p hash5", "patch5\n"), | 1104 Cmd("git log -1 -p hash5", "patch5\n"), |
| 1146 Cmd(("git apply --index --reject \"%s\"" % | 1105 Cmd(("git apply --index --reject \"%s\"" % |
| 1147 TEST_CONFIG[TEMPORARY_PATCH_FILE]), | 1106 TEST_CONFIG[TEMPORARY_PATCH_FILE]), |
| 1148 "", cb=VerifyPatch("patch5\n")), | 1107 "", cb=VerifyPatch("patch5\n")), |
| 1149 Cmd("git apply --index --reject \"%s\"" % extra_patch, ""), | 1108 Cmd("git apply --index --reject \"%s\"" % extra_patch, ""), |
| 1109 RL("Y"), # Automatically increment patch level? |
| 1150 Cmd("git commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""), | 1110 Cmd("git commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""), |
| 1111 RL("reviewer@chromium.org"), # V8 reviewer. |
| 1151 Cmd("git cl upload --send-mail -r \"reviewer@chromium.org\"", ""), | 1112 Cmd("git cl upload --send-mail -r \"reviewer@chromium.org\"", ""), |
| 1152 Cmd("git checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""), | 1113 Cmd("git checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""), |
| 1114 RL("LGTM"), # Enter LGTM for V8 CL. |
| 1153 Cmd("git cl presubmit", "Presubmit successfull\n"), | 1115 Cmd("git cl presubmit", "Presubmit successfull\n"), |
| 1154 Cmd("git cl dcommit -f --bypass-hooks", "Closing issue\n", | 1116 Cmd("git cl dcommit -f --bypass-hooks", "Closing issue\n", |
| 1155 cb=VerifySVNCommit), | 1117 cb=VerifySVNCommit), |
| 1156 Cmd("git svn fetch", ""), | 1118 Cmd("git svn fetch", ""), |
| 1157 Cmd(("git log -1 --format=%%H --grep=\"%s\" svn/trunk" | 1119 Cmd(("git log -1 --format=%%H --grep=\"%s\" svn/trunk" |
| 1158 % msg.replace("\"", "\\\"")), "hash6"), | 1120 % msg.replace("\"", "\\\"")), "hash6"), |
| 1159 Cmd("git svn find-rev hash6", "1324"), | 1121 Cmd("git svn find-rev hash6", "1324"), |
| 1160 Cmd(("svn copy -r 1324 https://v8.googlecode.com/svn/trunk " | 1122 Cmd(("svn copy -r 1324 https://v8.googlecode.com/svn/trunk " |
| 1161 "https://v8.googlecode.com/svn/tags/3.22.5.1 -m " | 1123 "https://v8.googlecode.com/svn/tags/3.22.5.1 -m " |
| 1162 "\"Tagging version 3.22.5.1\""), ""), | 1124 "\"Tagging version 3.22.5.1\""), ""), |
| 1163 Cmd("git checkout -f some_branch", ""), | 1125 Cmd("git checkout -f some_branch", ""), |
| 1164 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), | 1126 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), |
| 1165 ]) | 1127 ]) |
| 1166 | 1128 |
| 1167 self.ExpectReadline([ | |
| 1168 RL("Y"), # Automatically add corresponding ports (34567, 56789)? | |
| 1169 RL("Y"), # Automatically increment patch level? | |
| 1170 RL("reviewer@chromium.org"), # V8 reviewer. | |
| 1171 RL("LGTM"), # Enter LGTM for V8 CL. | |
| 1172 ]) | |
| 1173 | |
| 1174 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS | 1129 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS |
| 1175 # ports of r12345. r56789 is the MIPS port of r34567. | 1130 # ports of r12345. r56789 is the MIPS port of r34567. |
| 1176 args = ["-f", "-p", extra_patch, "--branch", "trunk", "12345", "23456", | 1131 args = ["-f", "-p", extra_patch, "--branch", "trunk", "12345", "23456", |
| 1177 "34567"] | 1132 "34567"] |
| 1178 | 1133 |
| 1179 # The first run of the script stops because of the svn being down. | 1134 # The first run of the script stops because of the svn being down. |
| 1180 self.assertRaises(GitFailedException, | 1135 self.assertRaises(GitFailedException, |
| 1181 lambda: MergeToBranch(TEST_CONFIG, self).Run(args)) | 1136 lambda: MergeToBranch(TEST_CONFIG, self).Run(args)) |
| 1182 | 1137 |
| 1183 # Test that state recovery after restarting the script works. | 1138 # Test that state recovery after restarting the script works. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 WriteDEPS(567) | 1208 WriteDEPS(567) |
| 1254 | 1209 |
| 1255 def ResetVersion(minor, build, patch=0): | 1210 def ResetVersion(minor, build, patch=0): |
| 1256 return lambda: self.WriteFakeVersionFile(minor=minor, | 1211 return lambda: self.WriteFakeVersionFile(minor=minor, |
| 1257 build=build, | 1212 build=build, |
| 1258 patch=patch) | 1213 patch=patch) |
| 1259 | 1214 |
| 1260 def ResetDEPS(revision): | 1215 def ResetDEPS(revision): |
| 1261 return lambda: WriteDEPS(revision) | 1216 return lambda: WriteDEPS(revision) |
| 1262 | 1217 |
| 1263 self.ExpectCmd([ | 1218 self.Expect([ |
| 1264 Cmd("git status -s -uno", ""), | 1219 Cmd("git status -s -uno", ""), |
| 1265 Cmd("git status -s -b -uno", "## some_branch\n"), | 1220 Cmd("git status -s -b -uno", "## some_branch\n"), |
| 1266 Cmd("git svn fetch", ""), | 1221 Cmd("git svn fetch", ""), |
| 1267 Cmd("git branch", " branch1\n* branch2\n"), | 1222 Cmd("git branch", " branch1\n* branch2\n"), |
| 1268 Cmd("git checkout -b %s" % TEST_CONFIG[BRANCHNAME], ""), | 1223 Cmd("git checkout -b %s" % TEST_CONFIG[BRANCHNAME], ""), |
| 1269 Cmd("git branch -r", " svn/3.21\n svn/3.3\n"), | 1224 Cmd("git branch -r", " svn/3.21\n svn/3.3\n"), |
| 1270 Cmd("git reset --hard svn/3.3", ""), | 1225 Cmd("git reset --hard svn/3.3", ""), |
| 1271 Cmd("git log --format=%H", "hash1\nhash2"), | 1226 Cmd("git log --format=%H", "hash1\nhash2"), |
| 1272 Cmd("git diff --name-only hash1 hash1^", ""), | 1227 Cmd("git diff --name-only hash1 hash1^", ""), |
| 1273 Cmd("git diff --name-only hash2 hash2^", TEST_CONFIG[VERSION_FILE]), | 1228 Cmd("git diff --name-only hash2 hash2^", TEST_CONFIG[VERSION_FILE]), |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1385 | 1340 |
| 1386 def testBumpUpVersion(self): | 1341 def testBumpUpVersion(self): |
| 1387 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 1342 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 1388 self.WriteFakeVersionFile() | 1343 self.WriteFakeVersionFile() |
| 1389 | 1344 |
| 1390 def ResetVersion(minor, build, patch=0): | 1345 def ResetVersion(minor, build, patch=0): |
| 1391 return lambda: self.WriteFakeVersionFile(minor=minor, | 1346 return lambda: self.WriteFakeVersionFile(minor=minor, |
| 1392 build=build, | 1347 build=build, |
| 1393 patch=patch) | 1348 patch=patch) |
| 1394 | 1349 |
| 1395 self.ExpectCmd([ | 1350 self.Expect([ |
| 1396 Cmd("git status -s -uno", ""), | 1351 Cmd("git status -s -uno", ""), |
| 1397 Cmd("git checkout -f bleeding_edge", "", cb=ResetVersion(11, 4)), | 1352 Cmd("git checkout -f bleeding_edge", "", cb=ResetVersion(11, 4)), |
| 1398 Cmd("git pull", ""), | 1353 Cmd("git pull", ""), |
| 1399 Cmd("git branch", ""), | 1354 Cmd("git branch", ""), |
| 1400 Cmd("git checkout -f bleeding_edge", ""), | 1355 Cmd("git checkout -f bleeding_edge", ""), |
| 1401 Cmd("git log -1 --format=%H", "latest_hash"), | 1356 Cmd("git log -1 --format=%H", "latest_hash"), |
| 1402 Cmd("git diff --name-only latest_hash latest_hash^", ""), | 1357 Cmd("git diff --name-only latest_hash latest_hash^", ""), |
| 1358 URL("https://v8-status.appspot.com/lkgr", "12345"), |
| 1403 Cmd("git checkout -f bleeding_edge", ""), | 1359 Cmd("git checkout -f bleeding_edge", ""), |
| 1404 Cmd(("git log --format=%H --grep=" | 1360 Cmd(("git log --format=%H --grep=" |
| 1405 "\"^git-svn-id: [^@]*@12345 [A-Za-z0-9-]*$\""), | 1361 "\"^git-svn-id: [^@]*@12345 [A-Za-z0-9-]*$\""), |
| 1406 "lkgr_hash"), | 1362 "lkgr_hash"), |
| 1407 Cmd("git checkout -b auto-bump-up-version lkgr_hash", ""), | 1363 Cmd("git checkout -b auto-bump-up-version lkgr_hash", ""), |
| 1408 Cmd("git checkout -f bleeding_edge", ""), | 1364 Cmd("git checkout -f bleeding_edge", ""), |
| 1409 Cmd("git branch", ""), | 1365 Cmd("git branch", ""), |
| 1410 Cmd("git diff --name-only lkgr_hash lkgr_hash^", ""), | 1366 Cmd("git diff --name-only lkgr_hash lkgr_hash^", ""), |
| 1411 Cmd("git checkout -f master", "", cb=ResetVersion(11, 5)), | 1367 Cmd("git checkout -f master", "", cb=ResetVersion(11, 5)), |
| 1412 Cmd("git pull", ""), | 1368 Cmd("git pull", ""), |
| 1369 URL("https://v8-status.appspot.com/current?format=json", |
| 1370 "{\"message\": \"Tree is open\"}"), |
| 1413 Cmd("git checkout -b auto-bump-up-version bleeding_edge", "", | 1371 Cmd("git checkout -b auto-bump-up-version bleeding_edge", "", |
| 1414 cb=ResetVersion(11, 4)), | 1372 cb=ResetVersion(11, 4)), |
| 1415 Cmd("git commit -am \"[Auto-roll] Bump up version to 3.11.6.0\n\n" | 1373 Cmd("git commit -am \"[Auto-roll] Bump up version to 3.11.6.0\n\n" |
| 1416 "TBR=author@chromium.org\"", ""), | 1374 "TBR=author@chromium.org\"", ""), |
| 1417 Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f " | 1375 Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f " |
| 1418 "--bypass-hooks", ""), | 1376 "--bypass-hooks", ""), |
| 1419 Cmd("git cl dcommit -f --bypass-hooks", ""), | 1377 Cmd("git cl dcommit -f --bypass-hooks", ""), |
| 1420 Cmd("git checkout -f bleeding_edge", ""), | 1378 Cmd("git checkout -f bleeding_edge", ""), |
| 1421 Cmd("git branch", "auto-bump-up-version\n* bleeding_edge"), | 1379 Cmd("git branch", "auto-bump-up-version\n* bleeding_edge"), |
| 1422 Cmd("git branch -D auto-bump-up-version", ""), | 1380 Cmd("git branch -D auto-bump-up-version", ""), |
| 1423 ]) | 1381 ]) |
| 1424 | 1382 |
| 1425 self.ExpectReadURL([ | |
| 1426 URL("https://v8-status.appspot.com/lkgr", "12345"), | |
| 1427 URL("https://v8-status.appspot.com/current?format=json", | |
| 1428 "{\"message\": \"Tree is open\"}"), | |
| 1429 ]) | |
| 1430 | |
| 1431 BumpUpVersion(TEST_CONFIG, self).Run(["-a", "author@chromium.org"]) | 1383 BumpUpVersion(TEST_CONFIG, self).Run(["-a", "author@chromium.org"]) |
| 1432 | 1384 |
| 1433 def testAutoTag(self): | 1385 def testAutoTag(self): |
| 1434 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 1386 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 1435 self.WriteFakeVersionFile() | 1387 self.WriteFakeVersionFile() |
| 1436 | 1388 |
| 1437 def ResetVersion(minor, build, patch=0): | 1389 def ResetVersion(minor, build, patch=0): |
| 1438 return lambda: self.WriteFakeVersionFile(minor=minor, | 1390 return lambda: self.WriteFakeVersionFile(minor=minor, |
| 1439 build=build, | 1391 build=build, |
| 1440 patch=patch) | 1392 patch=patch) |
| 1441 | 1393 |
| 1442 self.ExpectCmd([ | 1394 self.Expect([ |
| 1443 Cmd("git status -s -uno", ""), | 1395 Cmd("git status -s -uno", ""), |
| 1444 Cmd("git status -s -b -uno", "## some_branch\n"), | 1396 Cmd("git status -s -b -uno", "## some_branch\n"), |
| 1445 Cmd("git svn fetch", ""), | 1397 Cmd("git svn fetch", ""), |
| 1446 Cmd("git branch", " branch1\n* branch2\n"), | 1398 Cmd("git branch", " branch1\n* branch2\n"), |
| 1447 Cmd("git checkout -f master", ""), | 1399 Cmd("git checkout -f master", ""), |
| 1448 Cmd("git svn rebase", ""), | 1400 Cmd("git svn rebase", ""), |
| 1449 Cmd("git checkout -b %s" % TEST_CONFIG[BRANCHNAME], "", | 1401 Cmd("git checkout -b %s" % TEST_CONFIG[BRANCHNAME], "", |
| 1450 cb=ResetVersion(4, 5)), | 1402 cb=ResetVersion(4, 5)), |
| 1451 Cmd("git branch -r", | 1403 Cmd("git branch -r", |
| 1452 "svn/tags/3.4.2\nsvn/tags/3.2.1.0\nsvn/branches/3.4"), | 1404 "svn/tags/3.4.2\nsvn/tags/3.2.1.0\nsvn/branches/3.4"), |
| 1453 Cmd(("git log --format=%H --grep=" | 1405 Cmd(("git log --format=%H --grep=" |
| 1454 "\"\\[Auto\\-roll\\] Bump up version to\""), | 1406 "\"\\[Auto\\-roll\\] Bump up version to\""), |
| 1455 "hash125\nhash118\nhash111\nhash101"), | 1407 "hash125\nhash118\nhash111\nhash101"), |
| 1456 Cmd("git checkout -f hash125 -- %s" % TEST_CONFIG[VERSION_FILE], "", | 1408 Cmd("git checkout -f hash125 -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 1457 cb=ResetVersion(4, 4)), | 1409 cb=ResetVersion(4, 4)), |
| 1458 Cmd("git checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "", | 1410 Cmd("git checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 1459 cb=ResetVersion(4, 5)), | 1411 cb=ResetVersion(4, 5)), |
| 1460 Cmd("git checkout -f hash118 -- %s" % TEST_CONFIG[VERSION_FILE], "", | 1412 Cmd("git checkout -f hash118 -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 1461 cb=ResetVersion(4, 3)), | 1413 cb=ResetVersion(4, 3)), |
| 1462 Cmd("git checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "", | 1414 Cmd("git checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 1463 cb=ResetVersion(4, 5)), | 1415 cb=ResetVersion(4, 5)), |
| 1464 Cmd("git checkout -f hash111 -- %s" % TEST_CONFIG[VERSION_FILE], "", | 1416 Cmd("git checkout -f hash111 -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 1465 cb=ResetVersion(4, 2)), | 1417 cb=ResetVersion(4, 2)), |
| 1466 Cmd("git checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "", | 1418 Cmd("git checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 1467 cb=ResetVersion(4, 5)), | 1419 cb=ResetVersion(4, 5)), |
| 1420 URL("https://v8-status.appspot.com/revisions?format=json", |
| 1421 "[{\"revision\": \"126\", \"status\": true}," |
| 1422 "{\"revision\": \"123\", \"status\": true}," |
| 1423 "{\"revision\": \"112\", \"status\": true}]"), |
| 1468 Cmd("git svn find-rev hash118", "118"), | 1424 Cmd("git svn find-rev hash118", "118"), |
| 1469 Cmd("git svn find-rev hash125", "125"), | 1425 Cmd("git svn find-rev hash125", "125"), |
| 1470 Cmd("git svn find-rev r123", "hash123"), | 1426 Cmd("git svn find-rev r123", "hash123"), |
| 1471 Cmd("git log -1 --format=%at hash123", "1"), | 1427 Cmd("git log -1 --format=%at hash123", "1"), |
| 1472 Cmd("git reset --hard hash123", ""), | 1428 Cmd("git reset --hard hash123", ""), |
| 1473 Cmd("git svn tag 3.4.3 -m \"Tagging version 3.4.3\"", ""), | 1429 Cmd("git svn tag 3.4.3 -m \"Tagging version 3.4.3\"", ""), |
| 1474 Cmd("git checkout -f some_branch", ""), | 1430 Cmd("git checkout -f some_branch", ""), |
| 1475 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), | 1431 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), |
| 1476 ]) | 1432 ]) |
| 1477 | 1433 |
| 1478 self.ExpectReadURL([ | |
| 1479 URL("https://v8-status.appspot.com/revisions?format=json", | |
| 1480 "[{\"revision\": \"126\", \"status\": true}," | |
| 1481 "{\"revision\": \"123\", \"status\": true}," | |
| 1482 "{\"revision\": \"112\", \"status\": true}]"), | |
| 1483 ]) | |
| 1484 | |
| 1485 AutoTag(TEST_CONFIG, self).Run(["-a", "author@chromium.org"]) | 1434 AutoTag(TEST_CONFIG, self).Run(["-a", "author@chromium.org"]) |
| 1486 | 1435 |
| 1487 # Test that we bail out if the last change was a version change. | 1436 # Test that we bail out if the last change was a version change. |
| 1488 def testBumpUpVersionBailout1(self): | 1437 def testBumpUpVersionBailout1(self): |
| 1489 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 1438 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 1490 self._state["latest"] = "latest_hash" | 1439 self._state["latest"] = "latest_hash" |
| 1491 | 1440 |
| 1492 self.ExpectCmd([ | 1441 self.Expect([ |
| 1493 Cmd("git diff --name-only latest_hash latest_hash^", | 1442 Cmd("git diff --name-only latest_hash latest_hash^", |
| 1494 TEST_CONFIG[VERSION_FILE]), | 1443 TEST_CONFIG[VERSION_FILE]), |
| 1495 ]) | 1444 ]) |
| 1496 | 1445 |
| 1497 self.assertEquals(1, | 1446 self.assertEquals(1, |
| 1498 self.RunStep(BumpUpVersion, LastChangeBailout, ["--dry_run"])) | 1447 self.RunStep(BumpUpVersion, LastChangeBailout, ["--dry_run"])) |
| 1499 | 1448 |
| 1500 # Test that we bail out if the lkgr was a version change. | 1449 # Test that we bail out if the lkgr was a version change. |
| 1501 def testBumpUpVersionBailout2(self): | 1450 def testBumpUpVersionBailout2(self): |
| 1502 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 1451 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 1503 self._state["lkgr"] = "lkgr_hash" | 1452 self._state["lkgr"] = "lkgr_hash" |
| 1504 | 1453 |
| 1505 self.ExpectCmd([ | 1454 self.Expect([ |
| 1506 Cmd("git diff --name-only lkgr_hash lkgr_hash^", | 1455 Cmd("git diff --name-only lkgr_hash lkgr_hash^", |
| 1507 TEST_CONFIG[VERSION_FILE]), | 1456 TEST_CONFIG[VERSION_FILE]), |
| 1508 ]) | 1457 ]) |
| 1509 | 1458 |
| 1510 self.assertEquals(1, | 1459 self.assertEquals(1, |
| 1511 self.RunStep(BumpUpVersion, LKGRVersionUpToDateBailout, ["--dry_run"])) | 1460 self.RunStep(BumpUpVersion, LKGRVersionUpToDateBailout, ["--dry_run"])) |
| 1512 | 1461 |
| 1513 # Test that we bail out if the last version is already newer than the lkgr's | 1462 # Test that we bail out if the last version is already newer than the lkgr's |
| 1514 # version. | 1463 # version. |
| 1515 def testBumpUpVersionBailout3(self): | 1464 def testBumpUpVersionBailout3(self): |
| 1516 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 1465 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 1517 self._state["lkgr"] = "lkgr_hash" | 1466 self._state["lkgr"] = "lkgr_hash" |
| 1518 self._state["lkgr_version"] = "3.22.4.0" | 1467 self._state["lkgr_version"] = "3.22.4.0" |
| 1519 self._state["latest_version"] = "3.22.5.0" | 1468 self._state["latest_version"] = "3.22.5.0" |
| 1520 | 1469 |
| 1521 self.ExpectCmd([ | 1470 self.Expect([ |
| 1522 Cmd("git diff --name-only lkgr_hash lkgr_hash^", ""), | 1471 Cmd("git diff --name-only lkgr_hash lkgr_hash^", ""), |
| 1523 ]) | 1472 ]) |
| 1524 | 1473 |
| 1525 self.assertEquals(1, | 1474 self.assertEquals(1, |
| 1526 self.RunStep(BumpUpVersion, LKGRVersionUpToDateBailout, ["--dry_run"])) | 1475 self.RunStep(BumpUpVersion, LKGRVersionUpToDateBailout, ["--dry_run"])) |
| 1527 | 1476 |
| 1528 | 1477 |
| 1529 class SystemTest(unittest.TestCase): | 1478 class SystemTest(unittest.TestCase): |
| 1530 def testReload(self): | 1479 def testReload(self): |
| 1531 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, | 1480 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, |
| 1532 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) | 1481 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) |
| 1533 body = step.Reload( | 1482 body = step.Reload( |
| 1534 """------------------------------------------------------------------------ | 1483 """------------------------------------------------------------------------ |
| 1535 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines | 1484 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines |
| 1536 | 1485 |
| 1537 Prepare push to trunk. Now working on version 3.23.11. | 1486 Prepare push to trunk. Now working on version 3.23.11. |
| 1538 | 1487 |
| 1539 R=danno@chromium.org | 1488 R=danno@chromium.org |
| 1540 | 1489 |
| 1541 Review URL: https://codereview.chromium.org/83173002 | 1490 Review URL: https://codereview.chromium.org/83173002 |
| 1542 | 1491 |
| 1543 ------------------------------------------------------------------------""") | 1492 ------------------------------------------------------------------------""") |
| 1544 self.assertEquals( | 1493 self.assertEquals( |
| 1545 """Prepare push to trunk. Now working on version 3.23.11. | 1494 """Prepare push to trunk. Now working on version 3.23.11. |
| 1546 | 1495 |
| 1547 R=danno@chromium.org | 1496 R=danno@chromium.org |
| 1548 | 1497 |
| 1549 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 1498 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
| OLD | NEW |