| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 # -----------------00--------10--------20--------30-------- | 203 # -----------------00--------10--------20--------30-------- |
| 204 self.assertEquals("(Chromium issues 234, 1234567890" | 204 self.assertEquals("(Chromium issues 234, 1234567890" |
| 205 ", 12345678901234567, " | 205 ", 12345678901234567, " |
| 206 "1234567890123456789)", | 206 "1234567890123456789)", |
| 207 MakeChangeLogBugReference("BUG=234\n" | 207 MakeChangeLogBugReference("BUG=234\n" |
| 208 "BUG=12345678901234567\n" | 208 "BUG=12345678901234567\n" |
| 209 "BUG=1234567890123456789\n" | 209 "BUG=1234567890123456789\n" |
| 210 "BUG=1234567890\n")) | 210 "BUG=1234567890\n")) |
| 211 | 211 |
| 212 | 212 |
| 213 def Git(*args, **kwargs): |
| 214 """Convenience function returning a git test expectation.""" |
| 215 return { |
| 216 "name": "git", |
| 217 "args": args[:-1], |
| 218 "ret": args[-1], |
| 219 "cb": kwargs.get("cb"), |
| 220 } |
| 221 |
| 222 |
| 223 def RL(text, cb=None): |
| 224 """Convenience function returning a readline test expectation.""" |
| 225 return {"name": "readline", "args": [], "ret": text, "cb": cb} |
| 226 |
| 227 |
| 228 def URL(*args, **kwargs): |
| 229 """Convenience function returning a readurl test expectation.""" |
| 230 return { |
| 231 "name": "readurl", |
| 232 "args": args[:-1], |
| 233 "ret": args[-1], |
| 234 "cb": kwargs.get("cb"), |
| 235 } |
| 236 |
| 237 |
| 213 class SimpleMock(object): | 238 class SimpleMock(object): |
| 214 def __init__(self, name): | 239 def __init__(self, name): |
| 215 self._name = name | 240 self._name = name |
| 216 self._recipe = [] | 241 self._recipe = [] |
| 217 self._index = -1 | 242 self._index = -1 |
| 218 | 243 |
| 219 def Expect(self, recipe): | 244 def Expect(self, recipe): |
| 220 self._recipe = recipe | 245 self._recipe = recipe |
| 221 | 246 |
| 222 def Call(self, *args): # pragma: no cover | 247 def Call(self, name, *args): # pragma: no cover |
| 223 self._index += 1 | 248 self._index += 1 |
| 224 try: | 249 try: |
| 225 expected_call = self._recipe[self._index] | 250 expected_call = self._recipe[self._index] |
| 226 except IndexError: | 251 except IndexError: |
| 227 raise NoRetryException("Calling %s %s" % (self._name, " ".join(args))) | 252 raise NoRetryException("Calling %s %s" % (name, " ".join(args))) |
| 228 | 253 |
| 229 # Pack expectations without arguments into a list. | 254 if not isinstance(expected_call, dict): |
| 230 if not isinstance(expected_call, list): | 255 raise NoRetryException("Found wrong expectation type for %s %s" |
| 231 expected_call = [expected_call] | 256 % (name, " ".join(args))) |
| 257 |
| 232 | 258 |
| 233 # The number of arguments in the expectation must match the actual | 259 # The number of arguments in the expectation must match the actual |
| 234 # arguments. | 260 # arguments. |
| 235 if len(args) > len(expected_call): | 261 if len(args) > len(expected_call['args']): |
| 236 raise NoRetryException("When calling %s with arguments, the " | 262 raise NoRetryException("When calling %s with arguments, the " |
| 237 "expectations must consist of at least as many arguments.") | 263 "expectations must consist of at least as many arguments.") |
| 238 | 264 |
| 239 # Compare expected and actual arguments. | 265 # Compare expected and actual arguments. |
| 240 for (expected_arg, actual_arg) in zip(expected_call, args): | 266 for (expected_arg, actual_arg) in zip(expected_call['args'], args): |
| 241 if expected_arg != actual_arg: | 267 if expected_arg != actual_arg: |
| 242 raise NoRetryException("Expected: %s - Actual: %s" | 268 raise NoRetryException("Expected: %s - Actual: %s" |
| 243 % (expected_arg, actual_arg)) | 269 % (expected_arg, actual_arg)) |
| 244 | 270 |
| 245 # The expectation list contains a mandatory return value and an optional | 271 # The expected call contains an optional callback for checking the context |
| 246 # callback for checking the context at the time of the call. | 272 # at the time of the call. |
| 247 if len(expected_call) == len(args) + 2: | 273 if expected_call['cb']: |
| 248 try: | 274 try: |
| 249 expected_call[len(args) + 1]() | 275 expected_call['cb']() |
| 250 except: | 276 except: |
| 251 tb = traceback.format_exc() | 277 tb = traceback.format_exc() |
| 252 raise NoRetryException("Caught exception from callback: %s" % tb) | 278 raise NoRetryException("Caught exception from callback: %s" % tb) |
| 253 return_value = expected_call[len(args)] | |
| 254 | 279 |
| 255 # If the return value is an exception, raise it instead of returning. | 280 # If the return value is an exception, raise it instead of returning. |
| 256 if isinstance(return_value, Exception): | 281 if isinstance(expected_call['ret'], Exception): |
| 257 raise return_value | 282 raise expected_call['ret'] |
| 258 return return_value | 283 return expected_call['ret'] |
| 259 | 284 |
| 260 def AssertFinished(self): # pragma: no cover | 285 def AssertFinished(self): # pragma: no cover |
| 261 if self._index < len(self._recipe) -1: | 286 if self._index < len(self._recipe) -1: |
| 262 raise NoRetryException("Called %s too seldom: %d vs. %d" | 287 raise NoRetryException("Called %s too seldom: %d vs. %d" |
| 263 % (self._name, self._index, len(self._recipe))) | 288 % (self._name, self._index, len(self._recipe))) |
| 264 | 289 |
| 265 | 290 |
| 266 class ScriptTest(unittest.TestCase): | 291 class ScriptTest(unittest.TestCase): |
| 267 def MakeEmptyTempFile(self): | 292 def MakeEmptyTempFile(self): |
| 268 handle, name = tempfile.mkstemp() | 293 handle, name = tempfile.mkstemp() |
| (...skipping 21 matching lines...) Expand all Loading... |
| 290 config=TEST_CONFIG, side_effect_handler=self, | 315 config=TEST_CONFIG, side_effect_handler=self, |
| 291 options=options) | 316 options=options) |
| 292 | 317 |
| 293 def RunStep(self, script=PushToTrunk, step_class=Step, args=None): | 318 def RunStep(self, script=PushToTrunk, step_class=Step, args=None): |
| 294 """Convenience wrapper.""" | 319 """Convenience wrapper.""" |
| 295 args = args or ["-m"] | 320 args = args or ["-m"] |
| 296 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args) | 321 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args) |
| 297 | 322 |
| 298 def GitMock(self, cmd, args="", pipe=True): | 323 def GitMock(self, cmd, args="", pipe=True): |
| 299 print "%s %s" % (cmd, args) | 324 print "%s %s" % (cmd, args) |
| 300 return self._git_mock.Call(args) | 325 return self._git_mock.Call("git", args) |
| 301 | 326 |
| 302 def LogMock(self, cmd, args=""): | 327 def LogMock(self, cmd, args=""): |
| 303 print "Log: %s %s" % (cmd, args) | 328 print "Log: %s %s" % (cmd, args) |
| 304 | 329 |
| 305 MOCKS = { | 330 MOCKS = { |
| 306 "git": GitMock, | 331 "git": GitMock, |
| 307 # TODO(machenbach): Little hack to reuse the git mock for the one svn call | 332 # TODO(machenbach): Little hack to reuse the git mock for the one svn call |
| 308 # in merge-to-branch. The command should be made explicit in the test | 333 # in merge-to-branch. The command should be made explicit in the test |
| 309 # expectations. | 334 # expectations. |
| 310 "svn": GitMock, | 335 "svn": GitMock, |
| 311 "vi": LogMock, | 336 "vi": LogMock, |
| 312 } | 337 } |
| 313 | 338 |
| 314 def Call(self, fun, *args, **kwargs): | 339 def Call(self, fun, *args, **kwargs): |
| 315 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs)) | 340 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs)) |
| 316 | 341 |
| 317 def Command(self, cmd, args="", prefix="", pipe=True): | 342 def Command(self, cmd, args="", prefix="", pipe=True): |
| 318 return ScriptTest.MOCKS[cmd](self, cmd, args) | 343 return ScriptTest.MOCKS[cmd](self, cmd, args) |
| 319 | 344 |
| 320 def ReadLine(self): | 345 def ReadLine(self): |
| 321 return self._rl_mock.Call() | 346 return self._rl_mock.Call("readline") |
| 322 | 347 |
| 323 def ReadURL(self, url, params): | 348 def ReadURL(self, url, params): |
| 324 if params is not None: | 349 if params is not None: |
| 325 return self._url_mock.Call(url, params) | 350 return self._url_mock.Call("readurl", url, params) |
| 326 else: | 351 else: |
| 327 return self._url_mock.Call(url) | 352 return self._url_mock.Call("readurl", url) |
| 328 | 353 |
| 329 def Sleep(self, seconds): | 354 def Sleep(self, seconds): |
| 330 pass | 355 pass |
| 331 | 356 |
| 332 def GetDate(self): | 357 def GetDate(self): |
| 333 return "1999-07-31" | 358 return "1999-07-31" |
| 334 | 359 |
| 335 def ExpectGit(self, *args): | 360 def ExpectGit(self, *args): |
| 336 """Convenience wrapper.""" | 361 """Convenience wrapper.""" |
| 337 self._git_mock.Expect(*args) | 362 self._git_mock.Expect(*args) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 360 os.remove(name) | 385 os.remove(name) |
| 361 | 386 |
| 362 self._git_mock.AssertFinished() | 387 self._git_mock.AssertFinished() |
| 363 self._rl_mock.AssertFinished() | 388 self._rl_mock.AssertFinished() |
| 364 self._url_mock.AssertFinished() | 389 self._url_mock.AssertFinished() |
| 365 | 390 |
| 366 def testGitOrig(self): | 391 def testGitOrig(self): |
| 367 self.assertTrue(Command("git", "--version").startswith("git version")) | 392 self.assertTrue(Command("git", "--version").startswith("git version")) |
| 368 | 393 |
| 369 def testGitMock(self): | 394 def testGitMock(self): |
| 370 self.ExpectGit([["--version", "git version 1.2.3"], ["dummy", ""]]) | 395 self.ExpectGit([Git("--version", "git version 1.2.3"), Git("dummy", "")]) |
| 371 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) | 396 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) |
| 372 self.assertEquals("", self.MakeStep().Git("dummy")) | 397 self.assertEquals("", self.MakeStep().Git("dummy")) |
| 373 | 398 |
| 374 def testCommonPrepareDefault(self): | 399 def testCommonPrepareDefault(self): |
| 375 self.ExpectGit([ | 400 self.ExpectGit([ |
| 376 ["status -s -uno", ""], | 401 Git("status -s -uno", ""), |
| 377 ["status -s -b -uno", "## some_branch"], | 402 Git("status -s -b -uno", "## some_branch"), |
| 378 ["svn fetch", ""], | 403 Git("svn fetch", ""), |
| 379 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], | 404 Git("branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]), |
| 380 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 405 Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""), |
| 381 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 406 Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""), |
| 382 ["branch", ""], | 407 Git("branch", ""), |
| 383 ]) | 408 ]) |
| 384 self.ExpectReadline(["Y"]) | 409 self.ExpectReadline([RL("Y")]) |
| 385 self.MakeStep().CommonPrepare() | 410 self.MakeStep().CommonPrepare() |
| 386 self.MakeStep().PrepareBranch() | 411 self.MakeStep().PrepareBranch() |
| 387 self.assertEquals("some_branch", self._state["current_branch"]) | 412 self.assertEquals("some_branch", self._state["current_branch"]) |
| 388 | 413 |
| 389 def testCommonPrepareNoConfirm(self): | 414 def testCommonPrepareNoConfirm(self): |
| 390 self.ExpectGit([ | 415 self.ExpectGit([ |
| 391 ["status -s -uno", ""], | 416 Git("status -s -uno", ""), |
| 392 ["status -s -b -uno", "## some_branch"], | 417 Git("status -s -b -uno", "## some_branch"), |
| 393 ["svn fetch", ""], | 418 Git("svn fetch", ""), |
| 394 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], | 419 Git("branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]), |
| 395 ]) | 420 ]) |
| 396 self.ExpectReadline(["n"]) | 421 self.ExpectReadline([RL("n")]) |
| 397 self.MakeStep().CommonPrepare() | 422 self.MakeStep().CommonPrepare() |
| 398 self.assertRaises(Exception, self.MakeStep().PrepareBranch) | 423 self.assertRaises(Exception, self.MakeStep().PrepareBranch) |
| 399 self.assertEquals("some_branch", self._state["current_branch"]) | 424 self.assertEquals("some_branch", self._state["current_branch"]) |
| 400 | 425 |
| 401 def testCommonPrepareDeleteBranchFailure(self): | 426 def testCommonPrepareDeleteBranchFailure(self): |
| 402 self.ExpectGit([ | 427 self.ExpectGit([ |
| 403 ["status -s -uno", ""], | 428 Git("status -s -uno", ""), |
| 404 ["status -s -b -uno", "## some_branch"], | 429 Git("status -s -b -uno", "## some_branch"), |
| 405 ["svn fetch", ""], | 430 Git("svn fetch", ""), |
| 406 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], | 431 Git("branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]), |
| 407 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None], | 432 Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None), |
| 408 ]) | 433 ]) |
| 409 self.ExpectReadline(["Y"]) | 434 self.ExpectReadline([RL("Y")]) |
| 410 self.MakeStep().CommonPrepare() | 435 self.MakeStep().CommonPrepare() |
| 411 self.assertRaises(Exception, self.MakeStep().PrepareBranch) | 436 self.assertRaises(Exception, self.MakeStep().PrepareBranch) |
| 412 self.assertEquals("some_branch", self._state["current_branch"]) | 437 self.assertEquals("some_branch", self._state["current_branch"]) |
| 413 | 438 |
| 414 def testInitialEnvironmentChecks(self): | 439 def testInitialEnvironmentChecks(self): |
| 415 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 440 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 416 os.environ["EDITOR"] = "vi" | 441 os.environ["EDITOR"] = "vi" |
| 417 self.MakeStep().InitialEnvironmentChecks() | 442 self.MakeStep().InitialEnvironmentChecks() |
| 418 | 443 |
| 419 def testReadAndPersistVersion(self): | 444 def testReadAndPersistVersion(self): |
| (...skipping 24 matching lines...) Expand all Loading... |
| 444 self.assertEqual("//\n#define BUILD_NUMBER 3\n", | 469 self.assertEqual("//\n#define BUILD_NUMBER 3\n", |
| 445 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", | 470 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", |
| 446 r"\g<space>3", | 471 r"\g<space>3", |
| 447 "//\n#define BUILD_NUMBER 321\n")) | 472 "//\n#define BUILD_NUMBER 321\n")) |
| 448 | 473 |
| 449 def testPrepareChangeLog(self): | 474 def testPrepareChangeLog(self): |
| 450 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 475 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 451 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 476 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 452 | 477 |
| 453 self.ExpectGit([ | 478 self.ExpectGit([ |
| 454 ["log --format=%H 1234..HEAD", "rev1\nrev2\nrev3\nrev4"], | 479 Git("log --format=%H 1234..HEAD", "rev1\nrev2\nrev3\nrev4"), |
| 455 ["log -1 --format=%s rev1", "Title text 1"], | 480 Git("log -1 --format=%s rev1", "Title text 1"), |
| 456 ["log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"], | 481 Git("log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"), |
| 457 ["log -1 --format=%an rev1", "author1@chromium.org"], | 482 Git("log -1 --format=%an rev1", "author1@chromium.org"), |
| 458 ["log -1 --format=%s rev2", "Title text 2."], | 483 Git("log -1 --format=%s rev2", "Title text 2."), |
| 459 ["log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"], | 484 Git("log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"), |
| 460 ["log -1 --format=%an rev2", "author2@chromium.org"], | 485 Git("log -1 --format=%an rev2", "author2@chromium.org"), |
| 461 ["log -1 --format=%s rev3", "Title text 3"], | 486 Git("log -1 --format=%s rev3", "Title text 3"), |
| 462 ["log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"], | 487 Git("log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"), |
| 463 ["log -1 --format=%an rev3", "author3@chromium.org"], | 488 Git("log -1 --format=%an rev3", "author3@chromium.org"), |
| 464 ["log -1 --format=%s rev4", "Title text 4"], | 489 Git("log -1 --format=%s rev4", "Title text 4"), |
| 465 ["log -1 --format=%B rev4", | 490 Git("log -1 --format=%B rev4", |
| 466 ("Title\n\nBUG=456\nLOG=Y\n\n" | 491 ("Title\n\nBUG=456\nLOG=Y\n\n" |
| 467 "Review URL: https://codereview.chromium.org/9876543210\n")], | 492 "Review URL: https://codereview.chromium.org/9876543210\n")), |
| 468 ["log -1 --format=%an rev4", "author4@chromium.org"], | 493 Git("log -1 --format=%an rev4", "author4@chromium.org"), |
| 469 ]) | 494 ]) |
| 470 | 495 |
| 471 # The cl for rev4 on rietveld has an updated LOG flag. | 496 # The cl for rev4 on rietveld has an updated LOG flag. |
| 472 self.ExpectReadURL([ | 497 self.ExpectReadURL([ |
| 473 ["https://codereview.chromium.org/9876543210/description", | 498 URL("https://codereview.chromium.org/9876543210/description", |
| 474 "Title\n\nBUG=456\nLOG=N\n\n"], | 499 "Title\n\nBUG=456\nLOG=N\n\n"), |
| 475 ]) | 500 ]) |
| 476 | 501 |
| 477 self._state["last_push_bleeding_edge"] = "1234" | 502 self._state["last_push_bleeding_edge"] = "1234" |
| 478 self.RunStep(PushToTrunk, PrepareChangeLog) | 503 self.RunStep(PushToTrunk, PrepareChangeLog) |
| 479 | 504 |
| 480 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 505 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| 481 | 506 |
| 482 expected_cl = """1999-07-31: Version 3.22.5 | 507 expected_cl = """1999-07-31: Version 3.22.5 |
| 483 | 508 |
| 484 Title text 1. | 509 Title text 1. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 512 self.assertEquals("0", self._state["patch"]) | 537 self.assertEquals("0", self._state["patch"]) |
| 513 | 538 |
| 514 def testEditChangeLog(self): | 539 def testEditChangeLog(self): |
| 515 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 540 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 516 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | 541 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
| 517 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) | 542 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) |
| 518 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 543 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| 519 os.environ["EDITOR"] = "vi" | 544 os.environ["EDITOR"] = "vi" |
| 520 | 545 |
| 521 self.ExpectReadline([ | 546 self.ExpectReadline([ |
| 522 "", # Open editor. | 547 RL(""), # Open editor. |
| 523 ]) | 548 ]) |
| 524 | 549 |
| 525 self.RunStep(PushToTrunk, EditChangeLog) | 550 self.RunStep(PushToTrunk, EditChangeLog) |
| 526 | 551 |
| 527 self.assertEquals("New\n Lines\n\n\n Original CL", | 552 self.assertEquals("New\n Lines\n\n\n Original CL", |
| 528 FileToText(TEST_CONFIG[CHANGELOG_FILE])) | 553 FileToText(TEST_CONFIG[CHANGELOG_FILE])) |
| 529 | 554 |
| 530 def testIncrementVersion(self): | 555 def testIncrementVersion(self): |
| 531 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 556 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 532 self._state["build"] = "5" | 557 self._state["build"] = "5" |
| 533 | 558 |
| 534 self.ExpectReadline([ | 559 self.ExpectReadline([ |
| 535 "Y", # Increment build number. | 560 RL("Y"), # Increment build number. |
| 536 ]) | 561 ]) |
| 537 | 562 |
| 538 self.RunStep(PushToTrunk, IncrementVersion) | 563 self.RunStep(PushToTrunk, IncrementVersion) |
| 539 | 564 |
| 540 self.assertEquals("3", self._state["new_major"]) | 565 self.assertEquals("3", self._state["new_major"]) |
| 541 self.assertEquals("22", self._state["new_minor"]) | 566 self.assertEquals("22", self._state["new_minor"]) |
| 542 self.assertEquals("6", self._state["new_build"]) | 567 self.assertEquals("6", self._state["new_build"]) |
| 543 self.assertEquals("0", self._state["new_patch"]) | 568 self.assertEquals("0", self._state["new_patch"]) |
| 544 | 569 |
| 545 def testLastChangeLogEntries(self): | 570 def testLastChangeLogEntries(self): |
| (...skipping 11 matching lines...) Expand all Loading... |
| 557 | 582 |
| 558 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE]) | 583 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE]) |
| 559 self.assertEquals(cl_chunk, cl) | 584 self.assertEquals(cl_chunk, cl) |
| 560 | 585 |
| 561 def _TestSquashCommits(self, change_log, expected_msg): | 586 def _TestSquashCommits(self, change_log, expected_msg): |
| 562 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 587 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 563 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: | 588 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: |
| 564 f.write(change_log) | 589 f.write(change_log) |
| 565 | 590 |
| 566 self.ExpectGit([ | 591 self.ExpectGit([ |
| 567 ["diff svn/trunk hash1", "patch content"], | 592 Git("diff svn/trunk hash1", "patch content"), |
| 568 ["svn find-rev hash1", "123455\n"], | 593 Git("svn find-rev hash1", "123455\n"), |
| 569 ]) | 594 ]) |
| 570 | 595 |
| 571 self._state["prepare_commit_hash"] = "hash1" | 596 self._state["prepare_commit_hash"] = "hash1" |
| 572 self._state["date"] = "1999-11-11" | 597 self._state["date"] = "1999-11-11" |
| 573 | 598 |
| 574 self.RunStep(PushToTrunk, SquashCommits) | 599 self.RunStep(PushToTrunk, SquashCommits) |
| 575 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg) | 600 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg) |
| 576 | 601 |
| 577 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) | 602 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) |
| 578 self.assertTrue(re.search(r"patch content", patch)) | 603 self.assertTrue(re.search(r"patch content", patch)) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 version = FileToText(TEST_CONFIG[VERSION_FILE]) | 670 version = FileToText(TEST_CONFIG[VERSION_FILE]) |
| 646 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) | 671 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) |
| 647 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) | 672 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) |
| 648 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) | 673 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) |
| 649 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) | 674 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) |
| 650 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) | 675 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) |
| 651 | 676 |
| 652 force_flag = " -f" if not manual else "" | 677 force_flag = " -f" if not manual else "" |
| 653 review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else "" | 678 review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else "" |
| 654 self.ExpectGit([ | 679 self.ExpectGit([ |
| 655 ["status -s -uno", ""], | 680 Git("status -s -uno", ""), |
| 656 ["status -s -b -uno", "## some_branch\n"], | 681 Git("status -s -b -uno", "## some_branch\n"), |
| 657 ["svn fetch", ""], | 682 Git("svn fetch", ""), |
| 658 ["branch", " branch1\n* branch2\n"], | 683 Git("branch", " branch1\n* branch2\n"), |
| 659 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 684 Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""), |
| 660 ["branch", " branch1\n* branch2\n"], | 685 Git("branch", " branch1\n* branch2\n"), |
| 661 ["branch", " branch1\n* branch2\n"], | 686 Git("branch", " branch1\n* branch2\n"), |
| 662 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], | 687 Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""), |
| 663 [("log -1 --format=%H --grep=" | 688 Git(("log -1 --format=%H --grep=" |
| 664 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " | 689 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " |
| 665 "svn/trunk"), "hash2\n"], | 690 "svn/trunk"), "hash2\n"), |
| 666 ["log -1 hash2", "Log message\n"], | 691 Git("log -1 hash2", "Log message\n"), |
| 667 ["log -1 --format=%s hash2", | 692 Git("log -1 --format=%s hash2", |
| 668 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"], | 693 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"), |
| 669 ["svn find-rev r1234", "hash3\n"], | 694 Git("svn find-rev r1234", "hash3\n"), |
| 670 ["log --format=%H hash3..HEAD", "rev1\n"], | 695 Git("log --format=%H hash3..HEAD", "rev1\n"), |
| 671 ["log -1 --format=%s rev1", "Log text 1.\n"], | 696 Git("log -1 --format=%s rev1", "Log text 1.\n"), |
| 672 ["log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"], | 697 Git("log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"), |
| 673 ["log -1 --format=%an rev1", "author1@chromium.org\n"], | 698 Git("log -1 --format=%an rev1", "author1@chromium.org\n"), |
| 674 [("commit -am \"Prepare push to trunk. " | 699 Git(("commit -am \"Prepare push to trunk. " |
| 675 "Now working on version 3.22.6.%s\"" % review_suffix), | 700 "Now working on version 3.22.6.%s\"" % review_suffix), |
| 676 " 2 files changed\n", | 701 " 2 files changed\n", |
| 677 CheckPreparePush], | 702 cb=CheckPreparePush), |
| 678 [("cl upload --send-mail --email \"author@chromium.org\" " | 703 Git(("cl upload --send-mail --email \"author@chromium.org\" " |
| 679 "-r \"reviewer@chromium.org\"%s" % force_flag), | 704 "-r \"reviewer@chromium.org\"%s" % force_flag), |
| 680 "done\n"], | 705 "done\n"), |
| 681 ["cl presubmit", "Presubmit successfull\n"], | 706 Git("cl presubmit", "Presubmit successfull\n"), |
| 682 ["cl dcommit -f --bypass-hooks", "Closing issue\n"], | 707 Git("cl dcommit -f --bypass-hooks", "Closing issue\n"), |
| 683 ["svn fetch", "fetch result\n"], | 708 Git("svn fetch", "fetch result\n"), |
| 684 ["checkout -f svn/bleeding_edge", ""], | 709 Git("checkout -f svn/bleeding_edge", ""), |
| 685 [("log -1 --format=%H --grep=\"Prepare push to trunk. " | 710 Git(("log -1 --format=%H --grep=\"Prepare push to trunk. " |
| 686 "Now working on version 3.22.6.\""), | 711 "Now working on version 3.22.6.\""), |
| 687 "hash1\n"], | 712 "hash1\n"), |
| 688 ["diff svn/trunk hash1", "patch content\n"], | 713 Git("diff svn/trunk hash1", "patch content\n"), |
| 689 ["svn find-rev hash1", "123455\n"], | 714 Git("svn find-rev hash1", "123455\n"), |
| 690 ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""], | 715 Git("checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""), |
| 691 ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""], | 716 Git("apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""), |
| 692 ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""], | 717 Git("add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""), |
| 693 ["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit], | 718 Git("commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", |
| 694 ["svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"], | 719 cb=CheckSVNCommit), |
| 695 ["svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""], | 720 Git("svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"), |
| 696 ["status -s -uno", ""], | 721 Git("svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""), |
| 697 ["checkout -f master", ""], | 722 Git("status -s -uno", ""), |
| 698 ["pull", ""], | 723 Git("checkout -f master", ""), |
| 699 ["checkout -b v8-roll-123456", ""], | 724 Git("pull", ""), |
| 700 [("commit -am \"Update V8 to version 3.22.5 " | 725 Git("checkout -b v8-roll-123456", ""), |
| 701 "(based on bleeding_edge revision r123455).\n\n" | 726 Git(("commit -am \"Update V8 to version 3.22.5 " |
| 702 "TBR=reviewer@chromium.org\""), | 727 "(based on bleeding_edge revision r123455).\n\n" |
| 703 ""], | 728 "TBR=reviewer@chromium.org\""), |
| 704 ["cl upload --send-mail --email \"author@chromium.org\"%s" % force_flag, | 729 ""), |
| 705 ""], | 730 Git(("cl upload --send-mail --email \"author@chromium.org\"%s" |
| 706 ["checkout -f some_branch", ""], | 731 % force_flag), ""), |
| 707 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 732 Git("checkout -f some_branch", ""), |
| 708 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], | 733 Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""), |
| 709 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], | 734 Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), |
| 735 Git("branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""), |
| 710 ]) | 736 ]) |
| 711 | 737 |
| 712 # Expected keyboard input in manual mode: | 738 # Expected keyboard input in manual mode: |
| 713 if manual: | 739 if manual: |
| 714 self.ExpectReadline([ | 740 self.ExpectReadline([ |
| 715 "Y", # Confirm last push. | 741 RL("Y"), # Confirm last push. |
| 716 "", # Open editor. | 742 RL(""), # Open editor. |
| 717 "Y", # Increment build number. | 743 RL("Y"), # Increment build number. |
| 718 "reviewer@chromium.org", # V8 reviewer. | 744 RL("reviewer@chromium.org"), # V8 reviewer. |
| 719 "LGTX", # Enter LGTM for V8 CL (wrong). | 745 RL("LGTX"), # Enter LGTM for V8 CL (wrong). |
| 720 "LGTM", # Enter LGTM for V8 CL. | 746 RL("LGTM"), # Enter LGTM for V8 CL. |
| 721 "Y", # Sanity check. | 747 RL("Y"), # Sanity check. |
| 722 "reviewer@chromium.org", # Chromium reviewer. | 748 RL("reviewer@chromium.org"), # Chromium reviewer. |
| 723 ]) | 749 ]) |
| 724 | 750 |
| 725 # Expected keyboard input in semi-automatic mode: | 751 # Expected keyboard input in semi-automatic mode: |
| 726 if not manual and not force: | 752 if not manual and not force: |
| 727 self.ExpectReadline([ | 753 self.ExpectReadline([ |
| 728 "LGTM", # Enter LGTM for V8 CL. | 754 RL("LGTM"), # Enter LGTM for V8 CL. |
| 729 ]) | 755 ]) |
| 730 | 756 |
| 731 # No keyboard input in forced mode: | 757 # No keyboard input in forced mode: |
| 732 if force: | 758 if force: |
| 733 self.ExpectReadline([]) | 759 self.ExpectReadline([]) |
| 734 | 760 |
| 735 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM]] | 761 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM]] |
| 736 if force: args.append("-f") | 762 if force: args.append("-f") |
| 737 if manual: args.append("-m") | 763 if manual: args.append("-m") |
| 738 else: args += ["-r", "reviewer@chromium.org"] | 764 else: args += ["-r", "reviewer@chromium.org"] |
| (...skipping 15 matching lines...) Expand all Loading... |
| 754 self._PushToTrunk(manual=True) | 780 self._PushToTrunk(manual=True) |
| 755 | 781 |
| 756 def testPushToTrunkSemiAutomatic(self): | 782 def testPushToTrunkSemiAutomatic(self): |
| 757 self._PushToTrunk() | 783 self._PushToTrunk() |
| 758 | 784 |
| 759 def testPushToTrunkForced(self): | 785 def testPushToTrunkForced(self): |
| 760 self._PushToTrunk(force=True) | 786 self._PushToTrunk(force=True) |
| 761 | 787 |
| 762 def testCheckLastPushRecently(self): | 788 def testCheckLastPushRecently(self): |
| 763 self.ExpectGit([ | 789 self.ExpectGit([ |
| 764 ["svn log -1 --oneline", "r101 | Text"], | 790 Git("svn log -1 --oneline", "r101 | Text"), |
| 765 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], | 791 Git("svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."), |
| 766 ]) | 792 ]) |
| 767 | 793 |
| 768 self.RunStep(auto_roll.AutoRoll, FetchLatestRevision, AUTO_ROLL_ARGS) | 794 self.RunStep(auto_roll.AutoRoll, FetchLatestRevision, AUTO_ROLL_ARGS) |
| 769 self.assertRaises(Exception, lambda: self.RunStep(auto_roll.AutoRoll, | 795 self.assertRaises(Exception, lambda: self.RunStep(auto_roll.AutoRoll, |
| 770 CheckLastPush, | 796 CheckLastPush, |
| 771 AUTO_ROLL_ARGS)) | 797 AUTO_ROLL_ARGS)) |
| 772 | 798 |
| 773 def testAutoRoll(self): | 799 def testAutoRoll(self): |
| 774 password = self.MakeEmptyTempFile() | 800 password = self.MakeEmptyTempFile() |
| 775 TextToFile("PW", password) | 801 TextToFile("PW", password) |
| 776 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 802 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 777 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" | 803 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
| 778 | 804 |
| 779 self.ExpectReadURL([ | 805 self.ExpectReadURL([ |
| 780 ["https://v8-status.appspot.com/current?format=json", | 806 URL("https://v8-status.appspot.com/current?format=json", |
| 781 "{\"message\": \"Tree is throttled\"}"], | 807 "{\"message\": \"Tree is throttled\"}"), |
| 782 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], | 808 URL("https://v8-status.appspot.com/lkgr", Exception("Network problem")), |
| 783 ["https://v8-status.appspot.com/lkgr", "100"], | 809 URL("https://v8-status.appspot.com/lkgr", "100"), |
| 784 ["https://v8-status.appspot.com/status", | 810 URL("https://v8-status.appspot.com/status", |
| 785 ("username=v8-auto-roll%40chromium.org&" | 811 ("username=v8-auto-roll%40chromium.org&" |
| 786 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), | 812 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), ""), |
| 787 ""], | 813 URL("https://v8-status.appspot.com/status", |
| 788 ["https://v8-status.appspot.com/status", | 814 ("username=v8-auto-roll%40chromium.org&" |
| 789 ("username=v8-auto-roll%40chromium.org&" | 815 "message=Tree+is+throttled&password=PW"), ""), |
| 790 "message=Tree+is+throttled&password=PW"), ""], | |
| 791 ]) | 816 ]) |
| 792 | 817 |
| 793 self.ExpectGit([ | 818 self.ExpectGit([ |
| 794 ["status -s -uno", ""], | 819 Git("status -s -uno", ""), |
| 795 ["status -s -b -uno", "## some_branch\n"], | 820 Git("status -s -b -uno", "## some_branch\n"), |
| 796 ["svn fetch", ""], | 821 Git("svn fetch", ""), |
| 797 ["svn log -1 --oneline", "r100 | Text"], | 822 Git("svn log -1 --oneline", "r100 | Text"), |
| 798 [("log -1 --format=%H --grep=\"" | 823 Git(("log -1 --format=%H --grep=\"" |
| 799 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" | 824 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" |
| 800 " svn/trunk"), "push_hash\n"], | 825 " svn/trunk"), "push_hash\n"), |
| 801 ["svn find-rev push_hash", "65"], | 826 Git("svn find-rev push_hash", "65"), |
| 802 ]) | 827 ]) |
| 803 | 828 |
| 804 auto_roll.AutoRoll(TEST_CONFIG, self).Run( | 829 auto_roll.AutoRoll(TEST_CONFIG, self).Run( |
| 805 AUTO_ROLL_ARGS + ["--status-password", password, "--push"]) | 830 AUTO_ROLL_ARGS + ["--status-password", password, "--push"]) |
| 806 | 831 |
| 807 state = json.loads(FileToText("%s-state.json" | 832 state = json.loads(FileToText("%s-state.json" |
| 808 % TEST_CONFIG[PERSISTFILE_BASENAME])) | 833 % TEST_CONFIG[PERSISTFILE_BASENAME])) |
| 809 | 834 |
| 810 self.assertEquals("100", state["lkgr"]) | 835 self.assertEquals("100", state["lkgr"]) |
| 811 self.assertEquals("100", state["latest"]) | 836 self.assertEquals("100", state["latest"]) |
| 812 | 837 |
| 813 def testAutoRollStoppedBySettings(self): | 838 def testAutoRollStoppedBySettings(self): |
| 814 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 839 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 815 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() | 840 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() |
| 816 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) | 841 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) |
| 817 | 842 |
| 818 self.ExpectReadURL([]) | 843 self.ExpectReadURL([]) |
| 819 | 844 |
| 820 self.ExpectGit([ | 845 self.ExpectGit([ |
| 821 ["status -s -uno", ""], | 846 Git("status -s -uno", ""), |
| 822 ["status -s -b -uno", "## some_branch\n"], | 847 Git("status -s -b -uno", "## some_branch\n"), |
| 823 ["svn fetch", ""], | 848 Git("svn fetch", ""), |
| 824 ]) | 849 ]) |
| 825 | 850 |
| 826 def RunAutoRoll(): | 851 def RunAutoRoll(): |
| 827 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS) | 852 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS) |
| 828 self.assertRaises(Exception, RunAutoRoll) | 853 self.assertRaises(Exception, RunAutoRoll) |
| 829 | 854 |
| 830 def testAutoRollStoppedByTreeStatus(self): | 855 def testAutoRollStoppedByTreeStatus(self): |
| 831 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 856 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 832 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" | 857 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
| 833 | 858 |
| 834 self.ExpectReadURL([ | 859 self.ExpectReadURL([ |
| 835 ["https://v8-status.appspot.com/current?format=json", | 860 URL("https://v8-status.appspot.com/current?format=json", |
| 836 "{\"message\": \"Tree is throttled (no push)\"}"], | 861 "{\"message\": \"Tree is throttled (no push)\"}"), |
| 837 ]) | 862 ]) |
| 838 | 863 |
| 839 self.ExpectGit([ | 864 self.ExpectGit([ |
| 840 ["status -s -uno", ""], | 865 Git("status -s -uno", ""), |
| 841 ["status -s -b -uno", "## some_branch\n"], | 866 Git("status -s -b -uno", "## some_branch\n"), |
| 842 ["svn fetch", ""], | 867 Git("svn fetch", ""), |
| 843 ]) | 868 ]) |
| 844 | 869 |
| 845 def RunAutoRoll(): | 870 def RunAutoRoll(): |
| 846 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS) | 871 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS) |
| 847 self.assertRaises(Exception, RunAutoRoll) | 872 self.assertRaises(Exception, RunAutoRoll) |
| 848 | 873 |
| 849 def testMergeToBranch(self): | 874 def testMergeToBranch(self): |
| 850 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() | 875 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() |
| 851 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 876 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 852 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 877 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| (...skipping 23 matching lines...) Expand all Loading... |
| 876 def VerifySVNCommit(): | 901 def VerifySVNCommit(): |
| 877 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) | 902 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) |
| 878 self.assertEquals(msg, commit) | 903 self.assertEquals(msg, commit) |
| 879 version = FileToText(TEST_CONFIG[VERSION_FILE]) | 904 version = FileToText(TEST_CONFIG[VERSION_FILE]) |
| 880 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) | 905 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) |
| 881 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) | 906 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) |
| 882 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version)) | 907 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version)) |
| 883 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) | 908 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) |
| 884 | 909 |
| 885 self.ExpectGit([ | 910 self.ExpectGit([ |
| 886 ["status -s -uno", ""], | 911 Git("status -s -uno", ""), |
| 887 ["status -s -b -uno", "## some_branch\n"], | 912 Git("status -s -b -uno", "## some_branch\n"), |
| 888 ["svn fetch", ""], | 913 Git("svn fetch", ""), |
| 889 ["branch", " branch1\n* branch2\n"], | 914 Git("branch", " branch1\n* branch2\n"), |
| 890 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 915 Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""), |
| 891 ["branch", " branch1\n* branch2\n"], | 916 Git("branch", " branch1\n* branch2\n"), |
| 892 ["checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""], | 917 Git("checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""), |
| 893 ["log --format=%H --grep=\"Port r12345\" --reverse svn/bleeding_edge", | 918 Git("log --format=%H --grep=\"Port r12345\" --reverse svn/bleeding_edge", |
| 894 "hash1\nhash2"], | 919 "hash1\nhash2"), |
| 895 ["svn find-rev hash1 svn/bleeding_edge", "45678"], | 920 Git("svn find-rev hash1 svn/bleeding_edge", "45678"), |
| 896 ["log -1 --format=%s hash1", "Title1"], | 921 Git("log -1 --format=%s hash1", "Title1"), |
| 897 ["svn find-rev hash2 svn/bleeding_edge", "23456"], | 922 Git("svn find-rev hash2 svn/bleeding_edge", "23456"), |
| 898 ["log -1 --format=%s hash2", "Title2"], | 923 Git("log -1 --format=%s hash2", "Title2"), |
| 899 ["log --format=%H --grep=\"Port r23456\" --reverse svn/bleeding_edge", | 924 Git("log --format=%H --grep=\"Port r23456\" --reverse svn/bleeding_edge", |
| 900 ""], | 925 ""), |
| 901 ["log --format=%H --grep=\"Port r34567\" --reverse svn/bleeding_edge", | 926 Git("log --format=%H --grep=\"Port r34567\" --reverse svn/bleeding_edge", |
| 902 "hash3"], | 927 "hash3"), |
| 903 ["svn find-rev hash3 svn/bleeding_edge", "56789"], | 928 Git("svn find-rev hash3 svn/bleeding_edge", "56789"), |
| 904 ["log -1 --format=%s hash3", "Title3"], | 929 Git("log -1 --format=%s hash3", "Title3"), |
| 905 ["svn find-rev r12345 svn/bleeding_edge", "hash4"], | 930 Git("svn find-rev r12345 svn/bleeding_edge", "hash4"), |
| 906 # Simulate svn being down which stops the script. | 931 # Simulate svn being down which stops the script. |
| 907 ["svn find-rev r23456 svn/bleeding_edge", None], | 932 Git("svn find-rev r23456 svn/bleeding_edge", None), |
| 908 # Restart script in the failing step. | 933 # Restart script in the failing step. |
| 909 ["svn find-rev r12345 svn/bleeding_edge", "hash4"], | 934 Git("svn find-rev r12345 svn/bleeding_edge", "hash4"), |
| 910 ["svn find-rev r23456 svn/bleeding_edge", "hash2"], | 935 Git("svn find-rev r23456 svn/bleeding_edge", "hash2"), |
| 911 ["svn find-rev r34567 svn/bleeding_edge", "hash3"], | 936 Git("svn find-rev r34567 svn/bleeding_edge", "hash3"), |
| 912 ["svn find-rev r45678 svn/bleeding_edge", "hash1"], | 937 Git("svn find-rev r45678 svn/bleeding_edge", "hash1"), |
| 913 ["svn find-rev r56789 svn/bleeding_edge", "hash5"], | 938 Git("svn find-rev r56789 svn/bleeding_edge", "hash5"), |
| 914 ["log -1 --format=%s hash4", "Title4"], | 939 Git("log -1 --format=%s hash4", "Title4"), |
| 915 ["log -1 --format=%s hash2", "Title2"], | 940 Git("log -1 --format=%s hash2", "Title2"), |
| 916 ["log -1 --format=%s hash3", "Title3"], | 941 Git("log -1 --format=%s hash3", "Title3"), |
| 917 ["log -1 --format=%s hash1", "Title1"], | 942 Git("log -1 --format=%s hash1", "Title1"), |
| 918 ["log -1 --format=%s hash5", "Title5"], | 943 Git("log -1 --format=%s hash5", "Title5"), |
| 919 ["log -1 hash4", "Title4\nBUG=123\nBUG=234"], | 944 Git("log -1 hash4", "Title4\nBUG=123\nBUG=234"), |
| 920 ["log -1 hash2", "Title2\n BUG = v8:123,345"], | 945 Git("log -1 hash2", "Title2\n BUG = v8:123,345"), |
| 921 ["log -1 hash3", "Title3\nLOG=n\nBUG=567, 456"], | 946 Git("log -1 hash3", "Title3\nLOG=n\nBUG=567, 456"), |
| 922 ["log -1 hash1", "Title1"], | 947 Git("log -1 hash1", "Title1"), |
| 923 ["log -1 hash5", "Title5"], | 948 Git("log -1 hash5", "Title5"), |
| 924 ["log -1 -p hash4", "patch4"], | 949 Git("log -1 -p hash4", "patch4"), |
| 925 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], | 950 Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], |
| 926 "", VerifyPatch("patch4")], | 951 "", cb=VerifyPatch("patch4")), |
| 927 ["log -1 -p hash2", "patch2"], | 952 Git("log -1 -p hash2", "patch2"), |
| 928 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], | 953 Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], |
| 929 "", VerifyPatch("patch2")], | 954 "", cb=VerifyPatch("patch2")), |
| 930 ["log -1 -p hash3", "patch3"], | 955 Git("log -1 -p hash3", "patch3"), |
| 931 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], | 956 Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], |
| 932 "", VerifyPatch("patch3")], | 957 "", cb=VerifyPatch("patch3")), |
| 933 ["log -1 -p hash1", "patch1"], | 958 Git("log -1 -p hash1", "patch1"), |
| 934 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], | 959 Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], |
| 935 "", VerifyPatch("patch1")], | 960 "", cb=VerifyPatch("patch1")), |
| 936 ["log -1 -p hash5", "patch5\n"], | 961 Git("log -1 -p hash5", "patch5\n"), |
| 937 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], | 962 Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], |
| 938 "", VerifyPatch("patch5\n")], | 963 "", cb=VerifyPatch("patch5\n")), |
| 939 ["apply --index --reject \"%s\"" % extra_patch, ""], | 964 Git("apply --index --reject \"%s\"" % extra_patch, ""), |
| 940 ["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""], | 965 Git("commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""), |
| 941 ["cl upload --send-mail -r \"reviewer@chromium.org\"", ""], | 966 Git("cl upload --send-mail -r \"reviewer@chromium.org\"", ""), |
| 942 ["checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""], | 967 Git("checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""), |
| 943 ["cl presubmit", "Presubmit successfull\n"], | 968 Git("cl presubmit", "Presubmit successfull\n"), |
| 944 ["cl dcommit -f --bypass-hooks", "Closing issue\n", VerifySVNCommit], | 969 Git("cl dcommit -f --bypass-hooks", "Closing issue\n", cb=VerifySVNCommit)
, |
| 945 ["svn fetch", ""], | 970 Git("svn fetch", ""), |
| 946 ["log -1 --format=%%H --grep=\"%s\" svn/trunk" % msg, "hash6"], | 971 Git("log -1 --format=%%H --grep=\"%s\" svn/trunk" % msg, "hash6"), |
| 947 ["svn find-rev hash6", "1324"], | 972 Git("svn find-rev hash6", "1324"), |
| 948 [("copy -r 1324 https://v8.googlecode.com/svn/trunk " | 973 Git(("copy -r 1324 https://v8.googlecode.com/svn/trunk " |
| 949 "https://v8.googlecode.com/svn/tags/3.22.5.1 -m " | 974 "https://v8.googlecode.com/svn/tags/3.22.5.1 -m " |
| 950 "\"Tagging version 3.22.5.1\""), ""], | 975 "\"Tagging version 3.22.5.1\""), ""), |
| 951 ["checkout -f some_branch", ""], | 976 Git("checkout -f some_branch", ""), |
| 952 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 977 Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""), |
| 953 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], | 978 Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), |
| 954 ]) | 979 ]) |
| 955 | 980 |
| 956 self.ExpectReadline([ | 981 self.ExpectReadline([ |
| 957 "Y", # Automatically add corresponding ports (34567, 56789)? | 982 RL("Y"), # Automatically add corresponding ports (34567, 56789)? |
| 958 "Y", # Automatically increment patch level? | 983 RL("Y"), # Automatically increment patch level? |
| 959 "reviewer@chromium.org", # V8 reviewer. | 984 RL("reviewer@chromium.org"), # V8 reviewer. |
| 960 "LGTM", # Enter LGTM for V8 CL. | 985 RL("LGTM"), # Enter LGTM for V8 CL. |
| 961 ]) | 986 ]) |
| 962 | 987 |
| 963 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS | 988 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS |
| 964 # ports of r12345. r56789 is the MIPS port of r34567. | 989 # ports of r12345. r56789 is the MIPS port of r34567. |
| 965 args = ["-f", "-p", extra_patch, "--branch", "trunk", "12345", "23456", | 990 args = ["-f", "-p", extra_patch, "--branch", "trunk", "12345", "23456", |
| 966 "34567"] | 991 "34567"] |
| 967 | 992 |
| 968 # The first run of the script stops because of the svn being down. | 993 # The first run of the script stops because of the svn being down. |
| 969 self.assertRaises(GitFailedException, | 994 self.assertRaises(GitFailedException, |
| 970 lambda: MergeToBranch(TEST_CONFIG, self).Run(args)) | 995 lambda: MergeToBranch(TEST_CONFIG, self).Run(args)) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 988 | 1013 |
| 989 Review URL: https://codereview.chromium.org/83173002 | 1014 Review URL: https://codereview.chromium.org/83173002 |
| 990 | 1015 |
| 991 ------------------------------------------------------------------------""") | 1016 ------------------------------------------------------------------------""") |
| 992 self.assertEquals( | 1017 self.assertEquals( |
| 993 """Prepare push to trunk. Now working on version 3.23.11. | 1018 """Prepare push to trunk. Now working on version 3.23.11. |
| 994 | 1019 |
| 995 R=danno@chromium.org | 1020 R=danno@chromium.org |
| 996 | 1021 |
| 997 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 1022 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
| OLD | NEW |