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

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

Issue 203773013: Retrieve current version from trunk branch in push-to-trunk. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/push-to-trunk/push_to_trunk.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 the V8 project authors. All rights reserved. 2 # Copyright 2013 the V8 project authors. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 % (self._name, self._index, len(self._recipe))) 287 % (self._name, self._index, len(self._recipe)))
288 288
289 289
290 class ScriptTest(unittest.TestCase): 290 class ScriptTest(unittest.TestCase):
291 def MakeEmptyTempFile(self): 291 def MakeEmptyTempFile(self):
292 handle, name = tempfile.mkstemp() 292 handle, name = tempfile.mkstemp()
293 os.close(handle) 293 os.close(handle)
294 self._tmp_files.append(name) 294 self._tmp_files.append(name)
295 return name 295 return name
296 296
297 def WriteFakeVersionFile(self): 297 def WriteFakeVersionFile(self, build=4):
298 with open(TEST_CONFIG[VERSION_FILE], "w") as f: 298 with open(TEST_CONFIG[VERSION_FILE], "w") as f:
299 f.write(" // Some line...\n") 299 f.write(" // Some line...\n")
300 f.write("\n") 300 f.write("\n")
301 f.write("#define MAJOR_VERSION 3\n") 301 f.write("#define MAJOR_VERSION 3\n")
302 f.write("#define MINOR_VERSION 22\n") 302 f.write("#define MINOR_VERSION 22\n")
303 f.write("#define BUILD_NUMBER 5\n") 303 f.write("#define BUILD_NUMBER %s\n" % build)
304 f.write("#define PATCH_LEVEL 0\n") 304 f.write("#define PATCH_LEVEL 0\n")
305 f.write(" // Some line...\n") 305 f.write(" // Some line...\n")
306 f.write("#define IS_CANDIDATE_VERSION 0\n") 306 f.write("#define IS_CANDIDATE_VERSION 0\n")
307 307
308 def MakeStep(self): 308 def MakeStep(self):
309 """Convenience wrapper.""" 309 """Convenience wrapper."""
310 options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([]) 310 options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([])
311 return MakeStep(step_class=Step, state=self._state, 311 return MakeStep(step_class=Step, state=self._state,
312 config=TEST_CONFIG, side_effect_handler=self, 312 config=TEST_CONFIG, side_effect_handler=self,
313 options=options) 313 options=options)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 self.assertRaises(Exception, self.MakeStep().PrepareBranch) 433 self.assertRaises(Exception, self.MakeStep().PrepareBranch)
434 self.assertEquals("some_branch", self._state["current_branch"]) 434 self.assertEquals("some_branch", self._state["current_branch"])
435 435
436 def testInitialEnvironmentChecks(self): 436 def testInitialEnvironmentChecks(self):
437 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 437 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
438 os.environ["EDITOR"] = "vi" 438 os.environ["EDITOR"] = "vi"
439 self.MakeStep().InitialEnvironmentChecks() 439 self.MakeStep().InitialEnvironmentChecks()
440 440
441 def testReadAndPersistVersion(self): 441 def testReadAndPersistVersion(self):
442 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() 442 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile()
443 self.WriteFakeVersionFile() 443 self.WriteFakeVersionFile(build=5)
444 step = self.MakeStep() 444 step = self.MakeStep()
445 step.ReadAndPersistVersion() 445 step.ReadAndPersistVersion()
446 self.assertEquals("3", step["major"]) 446 self.assertEquals("3", step["major"])
447 self.assertEquals("22", step["minor"]) 447 self.assertEquals("22", step["minor"])
448 self.assertEquals("5", step["build"]) 448 self.assertEquals("5", step["build"])
449 self.assertEquals("0", step["patch"]) 449 self.assertEquals("0", step["patch"])
450 450
451 def testRegex(self): 451 def testRegex(self):
452 self.assertEqual("(issue 321)", 452 self.assertEqual("(issue 321)",
453 re.sub(r"BUG=v8:(.*)$", r"(issue \1)", "BUG=v8:321")) 453 re.sub(r"BUG=v8:(.*)$", r"(issue \1)", "BUG=v8:321"))
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 Git("log -1 --format=%an rev4", "author4@chromium.org"), 492 Git("log -1 --format=%an rev4", "author4@chromium.org"),
493 ]) 493 ])
494 494
495 # The cl for rev4 on rietveld has an updated LOG flag. 495 # The cl for rev4 on rietveld has an updated LOG flag.
496 self.ExpectReadURL([ 496 self.ExpectReadURL([
497 URL("https://codereview.chromium.org/9876543210/description", 497 URL("https://codereview.chromium.org/9876543210/description",
498 "Title\n\nBUG=456\nLOG=N\n\n"), 498 "Title\n\nBUG=456\nLOG=N\n\n"),
499 ]) 499 ])
500 500
501 self._state["last_push_bleeding_edge"] = "1234" 501 self._state["last_push_bleeding_edge"] = "1234"
502 self._state["version"] = "3.22.5"
502 self.RunStep(PushToTrunk, PrepareChangeLog) 503 self.RunStep(PushToTrunk, PrepareChangeLog)
503 504
504 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 505 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
505 506
506 expected_cl = """1999-07-31: Version 3.22.5 507 expected_cl = """1999-07-31: Version 3.22.5
507 508
508 Title text 1. 509 Title text 1.
509 510
510 Title text 3 (Chromium issue 321). 511 Title text 3 (Chromium issue 321).
511 512
(...skipping 11 matching lines...) Expand all
523 # 524 #
524 # Title text 3 (Chromium issue 321). 525 # Title text 3 (Chromium issue 321).
525 # (author3@chromium.org) 526 # (author3@chromium.org)
526 # 527 #
527 # Title text 4 (Chromium issue 456). 528 # Title text 4 (Chromium issue 456).
528 # (author4@chromium.org) 529 # (author4@chromium.org)
529 # 530 #
530 #""" 531 #"""
531 532
532 self.assertEquals(expected_cl, actual_cl) 533 self.assertEquals(expected_cl, actual_cl)
533 self.assertEquals("3", self._state["major"])
534 self.assertEquals("22", self._state["minor"])
535 self.assertEquals("5", self._state["build"])
536 self.assertEquals("0", self._state["patch"])
537 534
538 def testEditChangeLog(self): 535 def testEditChangeLog(self):
539 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 536 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
540 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 537 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE])
541 os.environ["EDITOR"] = "vi" 538 os.environ["EDITOR"] = "vi"
542 539
543 self.ExpectReadline([ 540 self.ExpectReadline([
544 RL(""), # Open editor. 541 RL(""), # Open editor.
545 ]) 542 ])
546 543
547 self.RunStep(PushToTrunk, EditChangeLog) 544 self.RunStep(PushToTrunk, EditChangeLog)
548 545
549 self.assertEquals("New\n Lines", 546 self.assertEquals("New\n Lines",
550 FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])) 547 FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]))
551 548
552 def testIncrementVersion(self): 549 def testIncrementVersion(self):
553 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() 550 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile()
554 self.WriteFakeVersionFile() 551 self.WriteFakeVersionFile()
555 self._state["build"] = "5" 552 self._state["last_push_trunk"] = "hash1"
553
554 self.ExpectGit([
555 Git("checkout -f hash1 -- %s" % TEST_CONFIG[VERSION_FILE], "")
556 ])
556 557
557 self.ExpectReadline([ 558 self.ExpectReadline([
558 RL("Y"), # Increment build number. 559 RL("Y"), # Increment build number.
559 ]) 560 ])
560 561
561 self.RunStep(PushToTrunk, IncrementVersion) 562 self.RunStep(PushToTrunk, IncrementVersion)
562 563
563 self.assertEquals("3", self._state["new_major"]) 564 self.assertEquals("3", self._state["new_major"])
564 self.assertEquals("22", self._state["new_minor"]) 565 self.assertEquals("22", self._state["new_minor"])
565 self.assertEquals("6", self._state["new_build"]) 566 self.assertEquals("5", self._state["new_build"])
566 self.assertEquals("0", self._state["new_patch"]) 567 self.assertEquals("0", self._state["new_patch"])
567 568
568 def _TestSquashCommits(self, change_log, expected_msg): 569 def _TestSquashCommits(self, change_log, expected_msg):
569 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 570 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
570 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: 571 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f:
571 f.write(change_log) 572 f.write(change_log)
572 573
573 self.ExpectGit([ 574 self.ExpectGit([
574 Git("diff svn/trunk hash1", "patch content"), 575 Git("diff svn/trunk hash1", "patch content"),
575 Git("svn find-rev hash1", "123455\n"), 576 Git("svn find-rev hash1", "123455\n"),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 Performance and stability improvements on all platforms.""" 613 Performance and stability improvements on all platforms."""
613 self._TestSquashCommits(change_log, commit_msg) 614 self._TestSquashCommits(change_log, commit_msg)
614 615
615 def testSquashCommitsQuotationMarks(self): 616 def testSquashCommitsQuotationMarks(self):
616 change_log = """Line with "quotation marks".\n""" 617 change_log = """Line with "quotation marks".\n"""
617 commit_msg = """Line with "quotation marks".""" 618 commit_msg = """Line with "quotation marks"."""
618 self._TestSquashCommits(change_log, commit_msg) 619 self._TestSquashCommits(change_log, commit_msg)
619 620
620 def _PushToTrunk(self, force=False, manual=False): 621 def _PushToTrunk(self, force=False, manual=False):
621 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 622 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
623
624 # The version file on bleeding edge has build level 5, while the version
625 # file from trunk has build level 4.
622 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() 626 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile()
623 self.WriteFakeVersionFile() 627 self.WriteFakeVersionFile(build=5)
628
624 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 629 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
625 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 630 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
626 if not os.path.exists(TEST_CONFIG[CHROMIUM]): 631 if not os.path.exists(TEST_CONFIG[CHROMIUM]):
627 os.makedirs(TEST_CONFIG[CHROMIUM]) 632 os.makedirs(TEST_CONFIG[CHROMIUM])
628 bleeding_edge_change_log = "2014-03-17: Sentinel\n" 633 bleeding_edge_change_log = "2014-03-17: Sentinel\n"
629 TextToFile(bleeding_edge_change_log, TEST_CONFIG[CHANGELOG_FILE]) 634 TextToFile(bleeding_edge_change_log, TEST_CONFIG[CHANGELOG_FILE])
630 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", 635 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line",
631 TEST_CONFIG[DEPS_FILE]) 636 TEST_CONFIG[DEPS_FILE])
632 os.environ["EDITOR"] = "vi" 637 os.environ["EDITOR"] = "vi"
633 638
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 Git("branch", " branch1\n* branch2\n"), 696 Git("branch", " branch1\n* branch2\n"),
692 Git("branch", " branch1\n* branch2\n"), 697 Git("branch", " branch1\n* branch2\n"),
693 Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""), 698 Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""),
694 Git(("log -1 --format=%H --grep=" 699 Git(("log -1 --format=%H --grep="
695 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " 700 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
696 "svn/trunk"), "hash2\n"), 701 "svn/trunk"), "hash2\n"),
697 Git("log -1 hash2", "Log message\n"), 702 Git("log -1 hash2", "Log message\n"),
698 Git("log -1 --format=%s hash2", 703 Git("log -1 --format=%s hash2",
699 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"), 704 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"),
700 Git("svn find-rev r1234", "hash3\n"), 705 Git("svn find-rev r1234", "hash3\n"),
706 Git("checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "",
707 cb=self.WriteFakeVersionFile),
701 Git("log --format=%H hash3..HEAD", "rev1\n"), 708 Git("log --format=%H hash3..HEAD", "rev1\n"),
702 Git("log -1 --format=%s rev1", "Log text 1.\n"), 709 Git("log -1 --format=%s rev1", "Log text 1.\n"),
703 Git("log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"), 710 Git("log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
704 Git("log -1 --format=%an rev1", "author1@chromium.org\n"), 711 Git("log -1 --format=%an rev1", "author1@chromium.org\n"),
705 Git(("commit -am \"Prepare push to trunk. " 712 Git(("commit -am \"Prepare push to trunk. "
706 "Now working on version 3.22.6.%s\"" % review_suffix), 713 "Now working on version 3.22.6.%s\"" % review_suffix),
707 " 2 files changed\n", 714 " 2 files changed\n",
708 cb=CheckPreparePush), 715 cb=CheckPreparePush),
709 Git(("cl upload --send-mail --email \"author@chromium.org\" " 716 Git(("cl upload --send-mail --email \"author@chromium.org\" "
710 "-r \"reviewer@chromium.org\"%s" % force_flag), 717 "-r \"reviewer@chromium.org\"%s" % force_flag),
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 ]) 886 ])
880 887
881 def RunAutoRoll(): 888 def RunAutoRoll():
882 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS) 889 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS)
883 self.assertRaises(Exception, RunAutoRoll) 890 self.assertRaises(Exception, RunAutoRoll)
884 891
885 def testMergeToBranch(self): 892 def testMergeToBranch(self):
886 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() 893 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile()
887 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 894 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
888 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() 895 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile()
889 self.WriteFakeVersionFile() 896 self.WriteFakeVersionFile(build=5)
890 os.environ["EDITOR"] = "vi" 897 os.environ["EDITOR"] = "vi"
891 extra_patch = self.MakeEmptyTempFile() 898 extra_patch = self.MakeEmptyTempFile()
892 899
893 def VerifyPatch(patch): 900 def VerifyPatch(patch):
894 return lambda: self.assertEquals(patch, 901 return lambda: self.assertEquals(patch,
895 FileToText(TEST_CONFIG[TEMPORARY_PATCH_FILE])) 902 FileToText(TEST_CONFIG[TEMPORARY_PATCH_FILE]))
896 903
897 msg = """Merged r12345, r23456, r34567, r45678, r56789 into trunk branch. 904 msg = """Merged r12345, r23456, r34567, r45678, r56789 into trunk branch.
898 905
899 Title4 906 Title4
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 1032
1026 Review URL: https://codereview.chromium.org/83173002 1033 Review URL: https://codereview.chromium.org/83173002
1027 1034
1028 ------------------------------------------------------------------------""") 1035 ------------------------------------------------------------------------""")
1029 self.assertEquals( 1036 self.assertEquals(
1030 """Prepare push to trunk. Now working on version 3.23.11. 1037 """Prepare push to trunk. Now working on version 3.23.11.
1031 1038
1032 R=danno@chromium.org 1039 R=danno@chromium.org
1033 1040
1034 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) 1041 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body)
OLDNEW
« no previous file with comments | « tools/push-to-trunk/push_to_trunk.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698