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

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

Issue 693333002: Teach push script to commit with roll account. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 842
843 def testPushToTrunkManual(self): 843 def testPushToTrunkManual(self):
844 self._PushToTrunk(manual=True) 844 self._PushToTrunk(manual=True)
845 845
846 def testPushToTrunkSemiAutomatic(self): 846 def testPushToTrunkSemiAutomatic(self):
847 self._PushToTrunk() 847 self._PushToTrunk()
848 848
849 def testPushToTrunkForced(self): 849 def testPushToTrunkForced(self):
850 self._PushToTrunk(force=True) 850 self._PushToTrunk(force=True)
851 851
852 def testPushToTrunkGit(self):
853 svn_root = self.MakeEmptyTempDirectory()
854 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
855
856 # The version file on bleeding edge has build level 5, while the version
857 # file from trunk has build level 4.
858 self.WriteFakeVersionFile(build=5)
859
860 TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
861 TEST_CONFIG["CHANGELOG_FILE"] = self.MakeEmptyTempFile()
862 bleeding_edge_change_log = "2014-03-17: Sentinel\n"
863 TextToFile(bleeding_edge_change_log, TEST_CONFIG["CHANGELOG_FILE"])
864
865 def ResetChangeLog():
866 """On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog',
867 the ChangLog will be reset to its content on trunk."""
868 trunk_change_log = """1999-04-05: Version 3.22.4
869
870 Performance and stability improvements on all platforms.\n"""
871 TextToFile(trunk_change_log, TEST_CONFIG["CHANGELOG_FILE"])
872
873 def ResetToTrunk():
874 ResetChangeLog()
875 self.WriteFakeVersionFile()
876
877 def CheckSVNCommit():
878 commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
879 self.assertEquals(
880 """Version 3.22.5 (based on push_hash)
881
882 Log text 1 (issue 321).
883
884 Performance and stability improvements on all platforms.""", commit)
885 version = FileToText(
886 os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
887 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
888 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
889 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version))
890 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version))
891 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
892
893 # Check that the change log on the trunk branch got correctly modified.
894 change_log = FileToText(TEST_CONFIG["CHANGELOG_FILE"])
895 self.assertEquals(
896 """1999-07-31: Version 3.22.5
897
898 Log text 1 (issue 321).
899
900 Performance and stability improvements on all platforms.
901
902
903 1999-04-05: Version 3.22.4
904
905 Performance and stability improvements on all platforms.\n""",
906 change_log)
907
908 expectations = [
909 Cmd("git status -s -uno", ""),
910 Cmd("git status -s -b -uno", "## some_branch\n"),
911 Cmd("git fetch", ""),
912 Cmd("git branch", " branch1\n* branch2\n"),
913 Cmd("git branch", " branch1\n* branch2\n"),
914 Cmd(("git new-branch %s --upstream origin/master" %
915 TEST_CONFIG["BRANCHNAME"]),
916 ""),
917 Cmd(("git log -1 --format=%H --grep="
918 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
919 "origin/candidates"), "hash2\n"),
920 Cmd("git log -1 hash2", "Log message\n"),
921 Cmd("git log -1 --format=%s hash2",
922 "Version 3.4.5 (based on abc3)\n"),
923 Cmd("git checkout -f origin/master -- src/version.cc",
924 "", cb=self.WriteFakeVersionFile),
925 Cmd("git checkout -f hash2 -- src/version.cc", "",
926 cb=self.WriteFakeVersionFile),
927 Cmd("git log --format=%H abc3..push_hash", "rev1\n"),
928 Cmd("git log -1 --format=%s rev1", "Log text 1.\n"),
929 Cmd("git log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
930 Cmd("git log -1 --format=%an rev1", "author1@chromium.org\n"),
931 Cmd("git fetch", ""),
932 Cmd("git checkout -f origin/master", ""),
933 Cmd("git diff origin/candidates push_hash", "patch content\n"),
934 Cmd(("git new-branch %s --upstream origin/candidates" %
935 TEST_CONFIG["TRUNKBRANCH"]), "", cb=ResetToTrunk),
936 Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG["PATCH_FILE"], ""),
937 Cmd(("git checkout -f origin/candidates -- %s" %
938 TEST_CONFIG["CHANGELOG_FILE"]), "",
939 cb=ResetChangeLog),
940 Cmd("git checkout -f origin/candidates -- src/version.cc", "",
941 cb=self.WriteFakeVersionFile),
942 Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], "",
943 cb=CheckSVNCommit),
944 # TODO(machenbach): Change test to pure git after flag day.
945 # Cmd("git push origin", ""),
946 Cmd("git diff HEAD^ HEAD", "patch content"),
947 Cmd("svn update", "", cwd=svn_root),
948 Cmd("svn status", "", cwd=svn_root),
949 Cmd("patch -d trunk -p1 -i %s" %
950 TEST_CONFIG["PATCH_FILE"], "Applied patch...", cwd=svn_root),
951 Cmd("svn commit --non-interactive --username=author@chromium.org "
952 "--config-dir=[CONFIG_DIR] "
953 "-m \"Version 3.22.5 (based on push_hash)\"",
954 "", cwd=svn_root),
955 Cmd("git fetch", ""),
956 Cmd("git log -1 --format=%H --grep="
957 "\"Version 3.22.5 (based on push_hash)\""
958 " origin/candidates", "hsh_to_tag"),
959 Cmd("git tag 3.22.5 hsh_to_tag", ""),
960 Cmd("git push origin 3.22.5", ""),
961 Cmd("git checkout -f some_branch", ""),
962 Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
963 Cmd("git branch -D %s" % TEST_CONFIG["TRUNKBRANCH"], ""),
964 ]
965 self.Expect(expectations)
966
967 args = ["-a", "author@chromium.org", "--revision", "push_hash",
968 "--vc-interface", "git", "-f", "-r", "reviewer@chromium.org",
969 "--svn", svn_root, "--svn-config", "[CONFIG_DIR]"]
970 PushToTrunk(TEST_CONFIG, self).Run(args)
971
972 cl = FileToText(TEST_CONFIG["CHANGELOG_FILE"])
973 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl))
974 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl))
975 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl))
976
977 # Note: The version file is on build number 5 again in the end of this test
978 # since the git command that merges to the bleeding edge branch is mocked
979 # out.
980
852 C_V8_22624_LOG = """V8 CL. 981 C_V8_22624_LOG = """V8 CL.
853 982
854 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123 983 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123
855 984
856 """ 985 """
857 986
858 C_V8_123455_LOG = """V8 CL. 987 C_V8_123455_LOG = """V8 CL.
859 988
860 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@123455 123 989 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@123455 123
861 990
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 auto_push.AutoPush, CheckLastPush, AUTO_PUSH_ARGS)) 1067 auto_push.AutoPush, CheckLastPush, AUTO_PUSH_ARGS))
939 1068
940 def testAutoPush(self): 1069 def testAutoPush(self):
941 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git")) 1070 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
942 TEST_CONFIG["SETTINGS_LOCATION"] = "~/.doesnotexist" 1071 TEST_CONFIG["SETTINGS_LOCATION"] = "~/.doesnotexist"
943 1072
944 self.Expect([ 1073 self.Expect([
945 Cmd("git status -s -uno", ""), 1074 Cmd("git status -s -uno", ""),
946 Cmd("git status -s -b -uno", "## some_branch\n"), 1075 Cmd("git status -s -b -uno", "## some_branch\n"),
947 Cmd("git fetch", ""), 1076 Cmd("git fetch", ""),
948 Cmd("git svn fetch", ""),
949 URL("https://v8-status.appspot.com/current?format=json", 1077 URL("https://v8-status.appspot.com/current?format=json",
950 "{\"message\": \"Tree is throttled\"}"), 1078 "{\"message\": \"Tree is throttled\"}"),
951 URL("https://v8-status.appspot.com/lkgr", Exception("Network problem")), 1079 URL("https://v8-status.appspot.com/lkgr", Exception("Network problem")),
952 URL("https://v8-status.appspot.com/lkgr", "abc123"), 1080 URL("https://v8-status.appspot.com/lkgr", "abc123"),
953 Cmd(("git log -1 --format=%H --grep=\"" 1081 Cmd(("git log -1 --format=%H --grep=\""
954 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" 1082 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\""
955 " origin/candidates"), "push_hash\n"), 1083 " origin/candidates"), "push_hash\n"),
956 Cmd("git log -1 --format=%s push_hash", 1084 Cmd("git log -1 --format=%s push_hash",
957 "Version 3.4.5 (based on abc101)\n"), 1085 "Version 3.4.5 (based on abc101)\n"),
958 ]) 1086 ])
959 1087
960 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS + ["--push"]) 1088 auto_push.AutoPush(TEST_CONFIG, self).Run(
1089 AUTO_PUSH_ARGS + ["--push", "--vc-interface", "git"])
961 1090
962 state = json.loads(FileToText("%s-state.json" 1091 state = json.loads(FileToText("%s-state.json"
963 % TEST_CONFIG["PERSISTFILE_BASENAME"])) 1092 % TEST_CONFIG["PERSISTFILE_BASENAME"]))
964 1093
965 self.assertEquals("abc123", state["lkgr"]) 1094 self.assertEquals("abc123", state["lkgr"])
966 1095
967 def testAutoPushStoppedBySettings(self): 1096 def testAutoPushStoppedBySettings(self):
968 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git")) 1097 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
969 TEST_CONFIG["SETTINGS_LOCATION"] = self.MakeEmptyTempFile() 1098 TEST_CONFIG["SETTINGS_LOCATION"] = self.MakeEmptyTempFile()
970 TextToFile("{\"enable_auto_push\": false}", 1099 TextToFile("{\"enable_auto_push\": false}",
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 1838
1710 Review URL: https://codereview.chromium.org/83173002 1839 Review URL: https://codereview.chromium.org/83173002
1711 1840
1712 ------------------------------------------------------------------------""") 1841 ------------------------------------------------------------------------""")
1713 self.assertEquals( 1842 self.assertEquals(
1714 """Prepare push to trunk. Now working on version 3.23.11. 1843 """Prepare push to trunk. Now working on version 3.23.11.
1715 1844
1716 R=danno@chromium.org 1845 R=danno@chromium.org
1717 1846
1718 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) 1847 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