Chromium Code Reviews| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 CHANGELOG_FILE: None, | 46 CHANGELOG_FILE: None, |
| 47 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", | 47 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", |
| 48 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", | 48 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", |
| 49 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", | 49 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", |
| 50 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", | 50 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", |
| 51 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", | 51 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 class ToplevelTest(unittest.TestCase): | 55 class ToplevelTest(unittest.TestCase): |
| 56 def testMakeComment(self): | |
| 57 self.assertEquals("# Line 1\n# Line 2\n#", | |
| 58 MakeComment(" Line 1\n Line 2\n")) | |
| 59 self.assertEquals("#Line 1\n#Line 2", | |
| 60 MakeComment("Line 1\n Line 2")) | |
| 61 | |
| 62 def testStripComments(self): | |
| 63 self.assertEquals(" Line 1\n Line 3\n", | |
| 64 StripComments(" Line 1\n# Line 2\n Line 3\n#\n")) | |
| 65 self.assertEquals("\nLine 2 ### Test\n #", | |
| 66 StripComments("###\n# \n\n# Line 1\nLine 2 ### Test\n #") ) | |
|
Jakob Kummerow
2013/11/21 09:17:05
nit: 80col
| |
| 67 | |
| 56 def testMakeChangeLogBodySimple(self): | 68 def testMakeChangeLogBodySimple(self): |
| 57 commits = lambda: [ | 69 commits = [ |
| 58 [" Title text 1", | 70 [" Title text 1", |
| 59 "Title text 1\n\nBUG=\n", | 71 "Title text 1\n\nBUG=\n", |
| 60 " author1@chromium.org"], | 72 " author1@chromium.org"], |
| 61 [" Title text 2", | 73 [" Title text 2", |
| 62 "Title text 2\n\nBUG=1234\n", | 74 "Title text 2\n\nBUG=1234\n", |
| 63 " author2@chromium.org"], | 75 " author2@chromium.org"], |
| 64 ] | 76 ] |
| 65 self.assertEquals(" Title text 1\n" | 77 self.assertEquals(" Title text 1\n" |
| 66 " author1@chromium.org\n\n" | 78 " author1@chromium.org\n\n" |
| 67 " Title text 2\n" | 79 " Title text 2\n" |
| 68 " (Chromium issue 1234)\n" | 80 " (Chromium issue 1234)\n" |
| 69 " author2@chromium.org\n\n", | 81 " author2@chromium.org\n\n", |
| 70 MakeChangeLogBody(commits)) | 82 MakeChangeLogBody(commits)) |
| 71 | 83 |
| 72 def testMakeChangeLogBodyEmpty(self): | 84 def testMakeChangeLogBodyEmpty(self): |
| 73 commits = lambda: [] | 85 self.assertEquals("", MakeChangeLogBody([])) |
| 74 self.assertEquals("", MakeChangeLogBody(commits)) | 86 |
| 87 def testMakeChangeLogBodyAutoFormat(self): | |
| 88 commits = [ | |
| 89 [" Title text 1", | |
| 90 "Title text 1\nLOG=y\nBUG=\n", | |
| 91 " author1@chromium.org"], | |
| 92 [" Title text 2", | |
| 93 "Title text 2\n\nBUG=1234\n", | |
| 94 " author2@chromium.org"], | |
| 95 [" Title text 3", | |
| 96 "Title text 3\n\nBUG=1234\nLOG = Yes\n", | |
| 97 " author3@chromium.org"], | |
| 98 [" Title text 3", | |
| 99 "Title text 4\n\nBUG=1234\nLOG=\n", | |
| 100 " author4@chromium.org"], | |
| 101 ] | |
| 102 self.assertEquals(" Title text 1\n\n" | |
| 103 " Title text 3\n" | |
| 104 " (Chromium issue 1234)\n\n", | |
| 105 MakeChangeLogBody(commits, True)) | |
| 75 | 106 |
| 76 def testMakeChangeLogBugReferenceEmpty(self): | 107 def testMakeChangeLogBugReferenceEmpty(self): |
| 77 self.assertEquals("", MakeChangeLogBugReference("")) | 108 self.assertEquals("", MakeChangeLogBugReference("")) |
| 78 self.assertEquals("", MakeChangeLogBugReference("LOG=")) | 109 self.assertEquals("", MakeChangeLogBugReference("LOG=")) |
| 79 self.assertEquals("", MakeChangeLogBugReference(" BUG =")) | 110 self.assertEquals("", MakeChangeLogBugReference(" BUG =")) |
| 80 self.assertEquals("", MakeChangeLogBugReference("BUG=none\t")) | 111 self.assertEquals("", MakeChangeLogBugReference("BUG=none\t")) |
| 81 | 112 |
| 82 def testMakeChangeLogBugReferenceSimple(self): | 113 def testMakeChangeLogBugReferenceSimple(self): |
| 83 self.assertEquals(" (issue 987654)\n", | 114 self.assertEquals(" (issue 987654)\n", |
| 84 MakeChangeLogBugReference("BUG = v8:987654")) | 115 MakeChangeLogBugReference("BUG = v8:987654")) |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 self.assertEqual("//\n#define BUILD_NUMBER 3\n", | 351 self.assertEqual("//\n#define BUILD_NUMBER 3\n", |
| 321 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", | 352 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", |
| 322 r"\g<space>3", | 353 r"\g<space>3", |
| 323 "//\n#define BUILD_NUMBER 321\n")) | 354 "//\n#define BUILD_NUMBER 321\n")) |
| 324 | 355 |
| 325 def testPrepareChangeLog(self): | 356 def testPrepareChangeLog(self): |
| 326 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 357 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 327 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 358 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 328 | 359 |
| 329 self._git_recipe = [ | 360 self._git_recipe = [ |
| 330 ["log 1234..HEAD --format=%H", "rev1\nrev2"], | 361 ["log 1234..HEAD --format=%H", "rev1\nrev2\nrev3"], |
| 331 ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Title text 1"], | 362 ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Title text 1"], |
| 332 ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\n"], | 363 ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\nLOG=y\n"], |
| 333 ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", | 364 ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", |
| 334 " author1@chromium.org"], | 365 " author1@chromium.org"], |
| 335 ["log -1 rev2 --format=\"%w(80,8,8)%s\"", " Title text 2"], | 366 ["log -1 rev2 --format=\"%w(80,8,8)%s\"", " Title text 2"], |
| 336 ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=321\n"], | 367 ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=123\nLOG= \n"], |
| 337 ["log -1 rev2 --format=\"%w(80,8,8)(%an)\"", | 368 ["log -1 rev2 --format=\"%w(80,8,8)(%an)\"", |
| 338 " author2@chromium.org"], | 369 " author2@chromium.org"], |
| 370 ["log -1 rev3 --format=\"%w(80,8,8)%s\"", " Title text 3"], | |
| 371 ["log -1 rev3 --format=\"%B\"", "Title\n\nBUG=321\nLOG=true\n"], | |
| 372 ["log -1 rev3 --format=\"%w(80,8,8)(%an)\"", | |
| 373 " author3@chromium.org"], | |
| 339 ] | 374 ] |
| 340 | 375 |
| 341 self.MakeStep().Persist("last_push", "1234") | 376 self.MakeStep().Persist("last_push", "1234") |
| 342 self.MakeStep(PrepareChangeLog).Run() | 377 self.MakeStep(PrepareChangeLog).Run() |
| 343 | 378 |
| 344 cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 379 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| 345 self.assertTrue(re.search(r"\d+\-\d+\-\d+: Version 3\.22\.5", cl)) | 380 |
| 346 self.assertTrue(re.search(r" Title text 1", cl)) | 381 # TODO(machenbach): Mock out call to date() in order to make a fixed |
| 347 self.assertTrue(re.search(r" Title text 2", cl)) | 382 # comparison here instead of a regexp match. |
| 348 self.assertTrue(re.search(r" author1@chromium.org", cl)) | 383 expected_cl = """\\d+\\-\\d+\\-\\d+: Version 3\\.22\\.5 |
| 349 self.assertTrue(re.search(r" author2@chromium.org", cl)) | 384 |
| 350 self.assertTrue(re.search(r" \(Chromium issue 321\)", cl)) | 385 Title text 1 |
| 351 self.assertFalse(re.search(r"BUG=", cl)) | 386 |
| 387 Title text 3 | |
| 388 \\(Chromium issue 321\\) | |
| 389 | |
| 390 Performance and stability improvements on all platforms\\. | |
| 391 # | |
| 392 # The change log above is auto-generated\\. Please review if all relevant | |
| 393 # commit messages from the list below are included\\. | |
| 394 # All lines starting with # will be stripped\\. | |
| 395 # | |
| 396 # Title text 1 | |
| 397 # author1@chromium\\.org | |
| 398 # | |
| 399 # Title text 2 | |
| 400 # \\(Chromium issue 123\\) | |
| 401 # author2@chromium\\.org | |
| 402 # | |
| 403 # Title text 3 | |
| 404 # \\(Chromium issue 321\\) | |
| 405 # author3@chromium\\.org | |
| 406 # | |
| 407 #""" | |
| 408 | |
| 409 self.assertTrue(re.match(expected_cl, actual_cl)) | |
| 352 self.assertEquals("3", self.MakeStep().Restore("major")) | 410 self.assertEquals("3", self.MakeStep().Restore("major")) |
| 353 self.assertEquals("22", self.MakeStep().Restore("minor")) | 411 self.assertEquals("22", self.MakeStep().Restore("minor")) |
| 354 self.assertEquals("5", self.MakeStep().Restore("build")) | 412 self.assertEquals("5", self.MakeStep().Restore("build")) |
| 355 self.assertEquals("0", self.MakeStep().Restore("patch")) | 413 self.assertEquals("0", self.MakeStep().Restore("patch")) |
| 356 | 414 |
| 357 def testEditChangeLog(self): | 415 def testEditChangeLog(self): |
| 358 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 416 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 359 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | 417 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
| 360 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) | 418 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) |
| 361 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 419 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE]) | 498 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE]) |
| 441 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", | 499 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", |
| 442 TEST_CONFIG[DEPS_FILE]) | 500 TEST_CONFIG[DEPS_FILE]) |
| 443 os.environ["EDITOR"] = "vi" | 501 os.environ["EDITOR"] = "vi" |
| 444 | 502 |
| 445 def CheckPreparePush(): | 503 def CheckPreparePush(): |
| 446 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) | 504 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) |
| 447 self.assertTrue(re.search(r"Version 3.22.5", cl)) | 505 self.assertTrue(re.search(r"Version 3.22.5", cl)) |
| 448 self.assertTrue(re.search(r" Log text 1", cl)) | 506 self.assertTrue(re.search(r" Log text 1", cl)) |
| 449 self.assertTrue(re.search(r" \(issue 321\)", cl)) | 507 self.assertTrue(re.search(r" \(issue 321\)", cl)) |
| 508 self.assertFalse(re.search(r" author1@chromium\.org", cl)) | |
| 509 | |
| 510 # Make sure all comments got stripped. | |
| 511 self.assertFalse(re.search(r"^#", cl, flags=re.M)) | |
| 512 | |
| 450 version = FileToText(TEST_CONFIG[VERSION_FILE]) | 513 version = FileToText(TEST_CONFIG[VERSION_FILE]) |
| 451 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version)) | 514 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version)) |
| 452 | 515 |
| 516 def CheckUpload(): | |
| 517 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) | |
| 518 | |
| 453 def CheckSVNCommit(): | 519 def CheckSVNCommit(): |
| 454 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) | 520 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) |
| 455 self.assertTrue(re.search(r"Version 3.22.5", commit)) | 521 self.assertTrue(re.search(r"Version 3.22.5", commit)) |
| 456 self.assertTrue(re.search(r"Log text 1. \(issue 321\)", commit)) | 522 self.assertTrue(re.search(r"Log text 1. \(issue 321\)", commit)) |
| 457 version = FileToText(TEST_CONFIG[VERSION_FILE]) | 523 version = FileToText(TEST_CONFIG[VERSION_FILE]) |
| 458 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) | 524 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) |
| 459 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) | 525 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) |
| 460 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) | 526 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) |
| 461 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) | 527 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) |
| 462 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) | 528 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) |
| 463 | 529 |
| 464 force_flag = " -f" if force else "" | 530 force_flag = " -f" if force else "" |
| 465 self._git_recipe = [ | 531 self._git_recipe = [ |
| 466 ["status -s -uno", ""], | 532 ["status -s -uno", ""], |
| 467 ["status -s -b -uno", "## some_branch\n"], | 533 ["status -s -b -uno", "## some_branch\n"], |
| 468 ["svn fetch", ""], | 534 ["svn fetch", ""], |
| 469 ["branch", " branch1\n* branch2\n"], | 535 ["branch", " branch1\n* branch2\n"], |
| 470 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 536 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 471 ["branch", " branch1\n* branch2\n"], | 537 ["branch", " branch1\n* branch2\n"], |
| 472 ["branch", " branch1\n* branch2\n"], | 538 ["branch", " branch1\n* branch2\n"], |
| 473 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], | 539 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], |
| 474 ["log -1 --format=%H ChangeLog", "1234\n"], | 540 ["log -1 --format=%H ChangeLog", "1234\n"], |
| 475 ["log -1 1234", "Last push ouput\n"], | 541 ["log -1 1234", "Last push ouput\n"], |
| 476 ["log 1234..HEAD --format=%H", "rev1\n"], | 542 ["log 1234..HEAD --format=%H", "rev1\n"], |
| 477 ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Log text 1.\n"], | 543 ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Log text 1.\n"], |
| 478 ["log -1 rev1 --format=\"%B\"", "Text\nBUG=v8:321\nText\n"], | 544 ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"], |
| 479 ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", | 545 ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", |
| 480 " author1@chromium.org\n"], | 546 " author1@chromium.org\n"], |
| 481 [("commit -a -m \"Prepare push to trunk. " | 547 [("commit -a -m \"Prepare push to trunk. " |
| 482 "Now working on version 3.22.6.\""), | 548 "Now working on version 3.22.6.\""), |
| 483 " 2 files changed\n", | 549 " 2 files changed\n", |
| 484 CheckPreparePush], | 550 CheckPreparePush], |
| 485 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag, | 551 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag, |
| 486 "done\n"], | 552 "done\n"], |
| 487 ["cl dcommit -f", "Closing issue\n"], | 553 ["cl dcommit -f", "Closing issue\n"], |
| 488 ["svn fetch", "fetch result\n"], | 554 ["svn fetch", "fetch result\n"], |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 | 615 |
| 550 # Note: The version file is on build number 5 again in the end of this test | 616 # Note: The version file is on build number 5 again in the end of this test |
| 551 # since the git command that merges to the bleeding edge branch is mocked | 617 # since the git command that merges to the bleeding edge branch is mocked |
| 552 # out. | 618 # out. |
| 553 | 619 |
| 554 def testPushToTrunk(self): | 620 def testPushToTrunk(self): |
| 555 self._PushToTrunk() | 621 self._PushToTrunk() |
| 556 | 622 |
| 557 def testPushToTrunkForced(self): | 623 def testPushToTrunkForced(self): |
| 558 self._PushToTrunk(force=True) | 624 self._PushToTrunk(force=True) |
| OLD | NEW |