| 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 16 matching lines...) Expand all Loading... |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import os | 29 import os |
| 30 import tempfile | 30 import tempfile |
| 31 import unittest | 31 import unittest |
| 32 | 32 |
| 33 import common_includes | 33 import common_includes |
| 34 from common_includes import * | 34 from common_includes import * |
| 35 import push_to_trunk | 35 import push_to_trunk |
| 36 from push_to_trunk import * | 36 from push_to_trunk import * |
| 37 import auto_roll |
| 37 | 38 |
| 38 | 39 |
| 39 TEST_CONFIG = { | 40 TEST_CONFIG = { |
| 40 BRANCHNAME: "test-prepare-push", | 41 BRANCHNAME: "test-prepare-push", |
| 41 TRUNKBRANCH: "test-trunk-push", | 42 TRUNKBRANCH: "test-trunk-push", |
| 42 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", | 43 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", |
| 43 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", | 44 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", |
| 44 DOT_GIT_LOCATION: None, | 45 DOT_GIT_LOCATION: None, |
| 45 VERSION_FILE: None, | 46 VERSION_FILE: None, |
| 46 CHANGELOG_FILE: None, | 47 CHANGELOG_FILE: None, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 "BUG=1234567890\n")) | 172 "BUG=1234567890\n")) |
| 172 # -----------------00--------10--------20--------30-------- | 173 # -----------------00--------10--------20--------30-------- |
| 173 self.assertEquals(" (Chromium issues 234, 1234567890" | 174 self.assertEquals(" (Chromium issues 234, 1234567890" |
| 174 ", 12345678901234567,\n" | 175 ", 12345678901234567,\n" |
| 175 " 1234567890123456789)\n", | 176 " 1234567890123456789)\n", |
| 176 MakeChangeLogBugReference("BUG=234\n" | 177 MakeChangeLogBugReference("BUG=234\n" |
| 177 "BUG=12345678901234567\n" | 178 "BUG=12345678901234567\n" |
| 178 "BUG=1234567890123456789\n" | 179 "BUG=1234567890123456789\n" |
| 179 "BUG=1234567890\n")) | 180 "BUG=1234567890\n")) |
| 180 | 181 |
| 182 |
| 183 class SimpleMock(object): |
| 184 def __init__(self, name): |
| 185 self._name = name |
| 186 self._recipe = [] |
| 187 self._index = -1 |
| 188 |
| 189 def Expect(self, recipe): |
| 190 self._recipe = recipe |
| 191 |
| 192 def Call(self, *args): |
| 193 self._index += 1 |
| 194 try: |
| 195 expected_call = self._recipe[self._index] |
| 196 except IndexError: |
| 197 raise Exception("Calling %s %s" % (name, " ".join(args))) |
| 198 |
| 199 # Pack expectations without arguments into a list. |
| 200 if not isinstance(expected_call, list): |
| 201 expected_call = [expected_call] |
| 202 |
| 203 # The number of arguments in the expectation must match the actual |
| 204 # arguments. |
| 205 if len(args) > len(expected_call): |
| 206 raise Exception("When calling %s with arguments, the expectations " |
| 207 "must consist of at least as many arguments.") |
| 208 |
| 209 # Compare expected and actual arguments. |
| 210 for (expected_arg, actual_arg) in zip(expected_call, args): |
| 211 if expected_arg != actual_arg: |
| 212 raise Exception("Expected: %s - Actual: %s" |
| 213 % (expected_arg, actual_arg)) |
| 214 |
| 215 # The expectation list contains a mandatory return value and an optional |
| 216 # callback for checking the context at the time of the call. |
| 217 if len(expected_call) == len(args) + 2: |
| 218 expected_call[len(args) + 1]() |
| 219 return expected_call[len(args)] |
| 220 |
| 221 def AssertFinished(self): |
| 222 if self._index < len(self._recipe) -1: |
| 223 raise Exception("Called %s too seldom: %d vs. %d" |
| 224 % (self._name, self._index, len(self._recipe))) |
| 225 |
| 226 |
| 181 class ScriptTest(unittest.TestCase): | 227 class ScriptTest(unittest.TestCase): |
| 182 def MakeEmptyTempFile(self): | 228 def MakeEmptyTempFile(self): |
| 183 handle, name = tempfile.mkstemp() | 229 handle, name = tempfile.mkstemp() |
| 184 os.close(handle) | 230 os.close(handle) |
| 185 self._tmp_files.append(name) | 231 self._tmp_files.append(name) |
| 186 return name | 232 return name |
| 187 | 233 |
| 188 def MakeTempVersionFile(self): | 234 def MakeTempVersionFile(self): |
| 189 name = self.MakeEmptyTempFile() | 235 name = self.MakeEmptyTempFile() |
| 190 with open(name, "w") as f: | 236 with open(name, "w") as f: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 201 def MakeStep(self, step_class=Step, state=None): | 247 def MakeStep(self, step_class=Step, state=None): |
| 202 state = state or {} | 248 state = state or {} |
| 203 step = step_class() | 249 step = step_class() |
| 204 step.SetConfig(TEST_CONFIG) | 250 step.SetConfig(TEST_CONFIG) |
| 205 step.SetState(state) | 251 step.SetState(state) |
| 206 step.SetNumber(0) | 252 step.SetNumber(0) |
| 207 step.SetSideEffectHandler(self) | 253 step.SetSideEffectHandler(self) |
| 208 return step | 254 return step |
| 209 | 255 |
| 210 def GitMock(self, cmd, args="", pipe=True): | 256 def GitMock(self, cmd, args="", pipe=True): |
| 211 self._git_index += 1 | 257 return self._git_mock.Call(args) |
| 212 try: | |
| 213 git_invocation = self._git_recipe[self._git_index] | |
| 214 except IndexError: | |
| 215 raise Exception("Calling git %s" % args) | |
| 216 if git_invocation[0] != args: | |
| 217 raise Exception("Expected: %s - Actual: %s" % (git_invocation[0], args)) | |
| 218 if len(git_invocation) == 3: | |
| 219 # Run optional function checking the context during this git command. | |
| 220 git_invocation[2]() | |
| 221 return git_invocation[1] | |
| 222 | 258 |
| 223 def LogMock(self, cmd, args=""): | 259 def LogMock(self, cmd, args=""): |
| 224 print "Log: %s %s" % (cmd, args) | 260 print "Log: %s %s" % (cmd, args) |
| 225 | 261 |
| 226 MOCKS = { | 262 MOCKS = { |
| 227 "git": GitMock, | 263 "git": GitMock, |
| 228 "vi": LogMock, | 264 "vi": LogMock, |
| 229 } | 265 } |
| 230 | 266 |
| 231 def Command(self, cmd, args="", prefix="", pipe=True): | 267 def Command(self, cmd, args="", prefix="", pipe=True): |
| 232 return ScriptTest.MOCKS[cmd](self, cmd, args) | 268 return ScriptTest.MOCKS[cmd](self, cmd, args) |
| 233 | 269 |
| 234 def ReadLine(self): | 270 def ReadLine(self): |
| 235 self._rl_index += 1 | 271 return self._rl_mock.Call() |
| 236 try: | 272 |
| 237 return self._rl_recipe[self._rl_index] | 273 def ReadURL(self, url): |
| 238 except IndexError: | 274 return self._url_mock.Call(url) |
| 239 raise Exception("Calling readline too often") | 275 |
| 276 def ExpectGit(self, *args): |
| 277 """Convenience wrapper.""" |
| 278 self._git_mock.Expect(*args) |
| 279 |
| 280 def ExpectReadline(self, *args): |
| 281 """Convenience wrapper.""" |
| 282 self._rl_mock.Expect(*args) |
| 283 |
| 284 def ExpectReadURL(self, *args): |
| 285 """Convenience wrapper.""" |
| 286 self._url_mock.Expect(*args) |
| 240 | 287 |
| 241 def setUp(self): | 288 def setUp(self): |
| 242 self._git_recipe = [] | 289 self._git_mock = SimpleMock("git") |
| 243 self._git_index = -1 | 290 self._rl_mock = SimpleMock("readline") |
| 244 self._rl_recipe = [] | 291 self._url_mock = SimpleMock("readurl") |
| 245 self._rl_index = -1 | |
| 246 self._tmp_files = [] | 292 self._tmp_files = [] |
| 247 | 293 |
| 248 def tearDown(self): | 294 def tearDown(self): |
| 249 Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME]) | 295 Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME]) |
| 250 | 296 |
| 251 # Clean up temps. Doesn't work automatically. | 297 # Clean up temps. Doesn't work automatically. |
| 252 for name in self._tmp_files: | 298 for name in self._tmp_files: |
| 253 if os.path.exists(name): | 299 if os.path.exists(name): |
| 254 os.remove(name) | 300 os.remove(name) |
| 255 | 301 |
| 256 if self._git_index < len(self._git_recipe) -1: | 302 self._git_mock.AssertFinished() |
| 257 raise Exception("Called git too seldom: %d vs. %d" % | 303 self._rl_mock.AssertFinished() |
| 258 (self._git_index, len(self._git_recipe))) | 304 self._url_mock.AssertFinished() |
| 259 if self._rl_index < len(self._rl_recipe) -1: | |
| 260 raise Exception("Too little input: %d vs. %d" % | |
| 261 (self._rl_index, len(self._rl_recipe))) | |
| 262 | 305 |
| 263 def testPersistRestore(self): | 306 def testPersistRestore(self): |
| 264 self.MakeStep().Persist("test1", "") | 307 self.MakeStep().Persist("test1", "") |
| 265 self.assertEquals("", self.MakeStep().Restore("test1")) | 308 self.assertEquals("", self.MakeStep().Restore("test1")) |
| 266 self.MakeStep().Persist("test2", "AB123") | 309 self.MakeStep().Persist("test2", "AB123") |
| 267 self.assertEquals("AB123", self.MakeStep().Restore("test2")) | 310 self.assertEquals("AB123", self.MakeStep().Restore("test2")) |
| 268 | 311 |
| 269 def testGitOrig(self): | 312 def testGitOrig(self): |
| 270 self.assertTrue(Command("git", "--version").startswith("git version")) | 313 self.assertTrue(Command("git", "--version").startswith("git version")) |
| 271 | 314 |
| 272 def testGitMock(self): | 315 def testGitMock(self): |
| 273 self._git_recipe = [["--version", "git version 1.2.3"], ["dummy", ""]] | 316 self.ExpectGit([["--version", "git version 1.2.3"], ["dummy", ""]]) |
| 274 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) | 317 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) |
| 275 self.assertEquals("", self.MakeStep().Git("dummy")) | 318 self.assertEquals("", self.MakeStep().Git("dummy")) |
| 276 | 319 |
| 277 def testCommonPrepareDefault(self): | 320 def testCommonPrepareDefault(self): |
| 278 self._git_recipe = [ | 321 self.ExpectGit([ |
| 279 ["status -s -uno", ""], | 322 ["status -s -uno", ""], |
| 280 ["status -s -b -uno", "## some_branch"], | 323 ["status -s -b -uno", "## some_branch"], |
| 281 ["svn fetch", ""], | 324 ["svn fetch", ""], |
| 282 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], | 325 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], |
| 283 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 326 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 284 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 327 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 285 ["branch", ""], | 328 ["branch", ""], |
| 286 ] | 329 ]) |
| 287 self._rl_recipe = ["Y"] | 330 self.ExpectReadline(["Y"]) |
| 288 self.MakeStep().CommonPrepare() | 331 self.MakeStep().CommonPrepare() |
| 289 self.MakeStep().PrepareBranch() | 332 self.MakeStep().PrepareBranch() |
| 290 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) | 333 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) |
| 291 | 334 |
| 292 def testCommonPrepareNoConfirm(self): | 335 def testCommonPrepareNoConfirm(self): |
| 293 self._git_recipe = [ | 336 self.ExpectGit([ |
| 294 ["status -s -uno", ""], | 337 ["status -s -uno", ""], |
| 295 ["status -s -b -uno", "## some_branch"], | 338 ["status -s -b -uno", "## some_branch"], |
| 296 ["svn fetch", ""], | 339 ["svn fetch", ""], |
| 297 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], | 340 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], |
| 298 ] | 341 ]) |
| 299 self._rl_recipe = ["n"] | 342 self.ExpectReadline(["n"]) |
| 300 self.MakeStep().CommonPrepare() | 343 self.MakeStep().CommonPrepare() |
| 301 self.assertRaises(Exception, self.MakeStep().PrepareBranch) | 344 self.assertRaises(Exception, self.MakeStep().PrepareBranch) |
| 302 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) | 345 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) |
| 303 | 346 |
| 304 def testCommonPrepareDeleteBranchFailure(self): | 347 def testCommonPrepareDeleteBranchFailure(self): |
| 305 self._git_recipe = [ | 348 self.ExpectGit([ |
| 306 ["status -s -uno", ""], | 349 ["status -s -uno", ""], |
| 307 ["status -s -b -uno", "## some_branch"], | 350 ["status -s -b -uno", "## some_branch"], |
| 308 ["svn fetch", ""], | 351 ["svn fetch", ""], |
| 309 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], | 352 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], |
| 310 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None], | 353 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None], |
| 311 ] | 354 ]) |
| 312 self._rl_recipe = ["Y"] | 355 self.ExpectReadline(["Y"]) |
| 313 self.MakeStep().CommonPrepare() | 356 self.MakeStep().CommonPrepare() |
| 314 self.assertRaises(Exception, self.MakeStep().PrepareBranch) | 357 self.assertRaises(Exception, self.MakeStep().PrepareBranch) |
| 315 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) | 358 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) |
| 316 | 359 |
| 317 def testInitialEnvironmentChecks(self): | 360 def testInitialEnvironmentChecks(self): |
| 318 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 361 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 319 os.environ["EDITOR"] = "vi" | 362 os.environ["EDITOR"] = "vi" |
| 320 self.MakeStep().InitialEnvironmentChecks() | 363 self.MakeStep().InitialEnvironmentChecks() |
| 321 | 364 |
| 322 def testReadAndPersistVersion(self): | 365 def testReadAndPersistVersion(self): |
| (...skipping 27 matching lines...) Expand all Loading... |
| 350 | 393 |
| 351 self.assertEqual("//\n#define BUILD_NUMBER 3\n", | 394 self.assertEqual("//\n#define BUILD_NUMBER 3\n", |
| 352 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", | 395 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", |
| 353 r"\g<space>3", | 396 r"\g<space>3", |
| 354 "//\n#define BUILD_NUMBER 321\n")) | 397 "//\n#define BUILD_NUMBER 321\n")) |
| 355 | 398 |
| 356 def testPrepareChangeLog(self): | 399 def testPrepareChangeLog(self): |
| 357 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 400 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 358 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 401 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 359 | 402 |
| 360 self._git_recipe = [ | 403 self.ExpectGit([ |
| 361 ["log 1234..HEAD --format=%H", "rev1\nrev2\nrev3"], | 404 ["log 1234..HEAD --format=%H", "rev1\nrev2\nrev3"], |
| 362 ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Title text 1"], | 405 ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Title text 1"], |
| 363 ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\nLOG=y\n"], | 406 ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\nLOG=y\n"], |
| 364 ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", | 407 ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", |
| 365 " author1@chromium.org"], | 408 " author1@chromium.org"], |
| 366 ["log -1 rev2 --format=\"%w(80,8,8)%s\"", " Title text 2"], | 409 ["log -1 rev2 --format=\"%w(80,8,8)%s\"", " Title text 2"], |
| 367 ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=123\nLOG= \n"], | 410 ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=123\nLOG= \n"], |
| 368 ["log -1 rev2 --format=\"%w(80,8,8)(%an)\"", | 411 ["log -1 rev2 --format=\"%w(80,8,8)(%an)\"", |
| 369 " author2@chromium.org"], | 412 " author2@chromium.org"], |
| 370 ["log -1 rev3 --format=\"%w(80,8,8)%s\"", " Title text 3"], | 413 ["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"], | 414 ["log -1 rev3 --format=\"%B\"", "Title\n\nBUG=321\nLOG=true\n"], |
| 372 ["log -1 rev3 --format=\"%w(80,8,8)(%an)\"", | 415 ["log -1 rev3 --format=\"%w(80,8,8)(%an)\"", |
| 373 " author3@chromium.org"], | 416 " author3@chromium.org"], |
| 374 ] | 417 ]) |
| 375 | 418 |
| 376 self.MakeStep().Persist("last_push", "1234") | 419 self.MakeStep().Persist("last_push", "1234") |
| 377 self.MakeStep(PrepareChangeLog).Run() | 420 self.MakeStep(PrepareChangeLog).Run() |
| 378 | 421 |
| 379 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 422 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| 380 | 423 |
| 381 # TODO(machenbach): Mock out call to date() in order to make a fixed | 424 # TODO(machenbach): Mock out call to date() in order to make a fixed |
| 382 # comparison here instead of a regexp match. | 425 # comparison here instead of a regexp match. |
| 383 expected_cl = """\\d+\\-\\d+\\-\\d+: Version 3\\.22\\.5 | 426 expected_cl = """\\d+\\-\\d+\\-\\d+: Version 3\\.22\\.5 |
| 384 | 427 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 412 self.assertEquals("5", self.MakeStep().Restore("build")) | 455 self.assertEquals("5", self.MakeStep().Restore("build")) |
| 413 self.assertEquals("0", self.MakeStep().Restore("patch")) | 456 self.assertEquals("0", self.MakeStep().Restore("patch")) |
| 414 | 457 |
| 415 def testEditChangeLog(self): | 458 def testEditChangeLog(self): |
| 416 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 459 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 417 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | 460 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
| 418 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) | 461 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) |
| 419 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 462 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| 420 os.environ["EDITOR"] = "vi" | 463 os.environ["EDITOR"] = "vi" |
| 421 | 464 |
| 422 self._rl_recipe = [ | 465 self.ExpectReadline([ |
| 423 "", # Open editor. | 466 "", # Open editor. |
| 424 ] | 467 ]) |
| 425 | 468 |
| 426 self.MakeStep(EditChangeLog).Run() | 469 self.MakeStep(EditChangeLog).Run() |
| 427 | 470 |
| 428 self.assertEquals(" New\n Lines\n\n\n Original CL", | 471 self.assertEquals(" New\n Lines\n\n\n Original CL", |
| 429 FileToText(TEST_CONFIG[CHANGELOG_FILE])) | 472 FileToText(TEST_CONFIG[CHANGELOG_FILE])) |
| 430 | 473 |
| 431 def testIncrementVersion(self): | 474 def testIncrementVersion(self): |
| 432 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 475 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 433 self.MakeStep().Persist("build", "5") | 476 self.MakeStep().Persist("build", "5") |
| 434 | 477 |
| 435 self._rl_recipe = [ | 478 self.ExpectReadline([ |
| 436 "Y", # Increment build number. | 479 "Y", # Increment build number. |
| 437 ] | 480 ]) |
| 438 | 481 |
| 439 self.MakeStep(IncrementVersion).Run() | 482 self.MakeStep(IncrementVersion).Run() |
| 440 | 483 |
| 441 self.assertEquals("3", self.MakeStep().Restore("new_major")) | 484 self.assertEquals("3", self.MakeStep().Restore("new_major")) |
| 442 self.assertEquals("22", self.MakeStep().Restore("new_minor")) | 485 self.assertEquals("22", self.MakeStep().Restore("new_minor")) |
| 443 self.assertEquals("6", self.MakeStep().Restore("new_build")) | 486 self.assertEquals("6", self.MakeStep().Restore("new_build")) |
| 444 self.assertEquals("0", self.MakeStep().Restore("new_patch")) | 487 self.assertEquals("0", self.MakeStep().Restore("new_patch")) |
| 445 | 488 |
| 446 def testLastChangeLogEntries(self): | 489 def testLastChangeLogEntries(self): |
| 447 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | 490 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
| (...skipping 15 matching lines...) Expand all Loading... |
| 463 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 506 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 464 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: | 507 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: |
| 465 f.write("1999-11-11: Version 3.22.5\n") | 508 f.write("1999-11-11: Version 3.22.5\n") |
| 466 f.write("\n") | 509 f.write("\n") |
| 467 f.write(" Log text 1.\n") | 510 f.write(" Log text 1.\n") |
| 468 f.write(" Chromium issue 12345\n") | 511 f.write(" Chromium issue 12345\n") |
| 469 f.write("\n") | 512 f.write("\n") |
| 470 f.write(" Performance and stability improvements on all " | 513 f.write(" Performance and stability improvements on all " |
| 471 "platforms.\n") | 514 "platforms.\n") |
| 472 | 515 |
| 473 self._git_recipe = [ | 516 self.ExpectGit([ |
| 474 ["diff svn/trunk hash1", "patch content"], | 517 ["diff svn/trunk hash1", "patch content"], |
| 475 ] | 518 ]) |
| 476 | 519 |
| 477 self.MakeStep().Persist("prepare_commit_hash", "hash1") | 520 self.MakeStep().Persist("prepare_commit_hash", "hash1") |
| 478 self.MakeStep().Persist("date", "1999-11-11") | 521 self.MakeStep().Persist("date", "1999-11-11") |
| 479 | 522 |
| 480 self.MakeStep(SquashCommits).Run() | 523 self.MakeStep(SquashCommits).Run() |
| 481 | 524 |
| 482 msg = FileToText(TEST_CONFIG[COMMITMSG_FILE]) | 525 msg = FileToText(TEST_CONFIG[COMMITMSG_FILE]) |
| 483 self.assertTrue(re.search(r"Version 3\.22\.5", msg)) | 526 self.assertTrue(re.search(r"Version 3\.22\.5", msg)) |
| 484 self.assertTrue(re.search(r"Performance and stability", msg)) | 527 self.assertTrue(re.search(r"Performance and stability", msg)) |
| 485 self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg)) | 528 self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg)) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 self.assertTrue(re.search(r"Version 3.22.5", commit)) | 564 self.assertTrue(re.search(r"Version 3.22.5", commit)) |
| 522 self.assertTrue(re.search(r"Log text 1. \(issue 321\)", commit)) | 565 self.assertTrue(re.search(r"Log text 1. \(issue 321\)", commit)) |
| 523 version = FileToText(TEST_CONFIG[VERSION_FILE]) | 566 version = FileToText(TEST_CONFIG[VERSION_FILE]) |
| 524 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) | 567 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) |
| 525 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) | 568 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) |
| 526 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) | 569 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) |
| 527 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) | 570 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) |
| 528 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) | 571 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) |
| 529 | 572 |
| 530 force_flag = " -f" if force else "" | 573 force_flag = " -f" if force else "" |
| 531 self._git_recipe = [ | 574 self.ExpectGit([ |
| 532 ["status -s -uno", ""], | 575 ["status -s -uno", ""], |
| 533 ["status -s -b -uno", "## some_branch\n"], | 576 ["status -s -b -uno", "## some_branch\n"], |
| 534 ["svn fetch", ""], | 577 ["svn fetch", ""], |
| 535 ["branch", " branch1\n* branch2\n"], | 578 ["branch", " branch1\n* branch2\n"], |
| 536 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 579 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 537 ["branch", " branch1\n* branch2\n"], | 580 ["branch", " branch1\n* branch2\n"], |
| 538 ["branch", " branch1\n* branch2\n"], | 581 ["branch", " branch1\n* branch2\n"], |
| 539 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], | 582 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], |
| 540 ["log -1 --format=%H ChangeLog", "1234\n"], | 583 ["log -1 --format=%H ChangeLog", "1234\n"], |
| 541 ["log -1 1234", "Last push ouput\n"], | 584 ["log -1 1234", "Last push ouput\n"], |
| (...skipping 26 matching lines...) Expand all Loading... |
| 568 ["pull", ""], | 611 ["pull", ""], |
| 569 ["checkout -b v8-roll-123456", ""], | 612 ["checkout -b v8-roll-123456", ""], |
| 570 [("commit -am \"Update V8 to version 3.22.5.\n\n" | 613 [("commit -am \"Update V8 to version 3.22.5.\n\n" |
| 571 "TBR=reviewer@chromium.org\""), | 614 "TBR=reviewer@chromium.org\""), |
| 572 ""], | 615 ""], |
| 573 ["cl upload --send-mail%s" % force_flag, ""], | 616 ["cl upload --send-mail%s" % force_flag, ""], |
| 574 ["checkout -f some_branch", ""], | 617 ["checkout -f some_branch", ""], |
| 575 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 618 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 576 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], | 619 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], |
| 577 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], | 620 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], |
| 578 ] | 621 ]) |
| 579 self._rl_recipe = [ | 622 self.ExpectReadline([ |
| 580 "Y", # Confirm last push. | 623 "Y", # Confirm last push. |
| 581 "", # Open editor. | 624 "", # Open editor. |
| 582 "Y", # Increment build number. | 625 "Y", # Increment build number. |
| 583 "reviewer@chromium.org", # V8 reviewer. | 626 "reviewer@chromium.org", # V8 reviewer. |
| 584 "LGTX", # Enter LGTM for V8 CL (wrong). | 627 "LGTX", # Enter LGTM for V8 CL (wrong). |
| 585 "LGTM", # Enter LGTM for V8 CL. | 628 "LGTM", # Enter LGTM for V8 CL. |
| 586 "Y", # Sanity check. | 629 "Y", # Sanity check. |
| 587 "reviewer@chromium.org", # Chromium reviewer. | 630 "reviewer@chromium.org", # Chromium reviewer. |
| 588 ] | 631 ]) |
| 589 if force: | 632 if force: |
| 590 # TODO(machenbach): The lgtm for the prepare push is just temporary. | 633 # TODO(machenbach): The lgtm for the prepare push is just temporary. |
| 591 # There should be no user input in "force" mode. | 634 # There should be no user input in "force" mode. |
| 592 self._rl_recipe = [ | 635 self.ExpectReadline([ |
| 593 "LGTM", # Enter LGTM for V8 CL. | 636 "LGTM", # Enter LGTM for V8 CL. |
| 594 ] | 637 ]) |
| 595 | 638 |
| 596 class Options( object ): | 639 class Options( object ): |
| 597 pass | 640 pass |
| 598 | 641 |
| 599 options = Options() | 642 options = Options() |
| 600 options.s = 0 | 643 options.s = 0 |
| 601 options.l = None | 644 options.l = None |
| 602 options.f = force | 645 options.f = force |
| 603 options.r = "reviewer@chromium.org" if force else None | 646 options.r = "reviewer@chromium.org" if force else None |
| 604 options.c = TEST_CONFIG[CHROMIUM] | 647 options.c = TEST_CONFIG[CHROMIUM] |
| (...skipping 10 matching lines...) Expand all Loading... |
| 615 | 658 |
| 616 # Note: The version file is on build number 5 again in the end of this test | 659 # Note: The version file is on build number 5 again in the end of this test |
| 617 # since the git command that merges to the bleeding edge branch is mocked | 660 # since the git command that merges to the bleeding edge branch is mocked |
| 618 # out. | 661 # out. |
| 619 | 662 |
| 620 def testPushToTrunk(self): | 663 def testPushToTrunk(self): |
| 621 self._PushToTrunk() | 664 self._PushToTrunk() |
| 622 | 665 |
| 623 def testPushToTrunkForced(self): | 666 def testPushToTrunkForced(self): |
| 624 self._PushToTrunk(force=True) | 667 self._PushToTrunk(force=True) |
| 668 |
| 669 def testAutoRoll(self): |
| 670 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 671 |
| 672 # TODO(machenbach): Get rid of the editor check in automatic mode. |
| 673 os.environ["EDITOR"] = "vi" |
| 674 |
| 675 self.ExpectReadURL([ |
| 676 ["https://v8-status.appspot.com/lkgr", "100"], |
| 677 ]) |
| 678 |
| 679 self.ExpectGit([ |
| 680 ["status -s -uno", ""], |
| 681 ["status -s -b -uno", "## some_branch\n"], |
| 682 ["svn fetch", ""], |
| 683 ["svn log -1 --oneline", "r101 | Text"], |
| 684 ]) |
| 685 |
| 686 # TODO(machenbach): Make a convenience wrapper for this. |
| 687 class Options( object ): |
| 688 pass |
| 689 |
| 690 options = Options() |
| 691 options.s = 0 |
| 692 |
| 693 auto_roll.RunAutoRoll(TEST_CONFIG, options, self) |
| 694 |
| 695 self.assertEquals("100", self.MakeStep().Restore("lkgr")) |
| 696 self.assertEquals("101", self.MakeStep().Restore("latest")) |
| OLD | NEW |