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

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

Issue 98173003: Mock out date call in push-to-trunk script for testability. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 def ReadLine(self): 282 def ReadLine(self):
283 return self._rl_mock.Call() 283 return self._rl_mock.Call()
284 284
285 def ReadURL(self, url): 285 def ReadURL(self, url):
286 return self._url_mock.Call(url) 286 return self._url_mock.Call(url)
287 287
288 def Sleep(self, seconds): 288 def Sleep(self, seconds):
289 pass 289 pass
290 290
291 def GetDate(self):
292 return "1999-07-31"
293
291 def ExpectGit(self, *args): 294 def ExpectGit(self, *args):
292 """Convenience wrapper.""" 295 """Convenience wrapper."""
293 self._git_mock.Expect(*args) 296 self._git_mock.Expect(*args)
294 297
295 def ExpectReadline(self, *args): 298 def ExpectReadline(self, *args):
296 """Convenience wrapper.""" 299 """Convenience wrapper."""
297 self._rl_mock.Expect(*args) 300 self._rl_mock.Expect(*args)
298 301
299 def ExpectReadURL(self, *args): 302 def ExpectReadURL(self, *args):
300 """Convenience wrapper.""" 303 """Convenience wrapper."""
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 self.ExpectReadURL([ 440 self.ExpectReadURL([
438 ["https://codereview.chromium.org/9876543210/description", 441 ["https://codereview.chromium.org/9876543210/description",
439 "Title\n\nBUG=456\nLOG=N\n\n"], 442 "Title\n\nBUG=456\nLOG=N\n\n"],
440 ]) 443 ])
441 444
442 self.MakeStep().Persist("last_push", "1234") 445 self.MakeStep().Persist("last_push", "1234")
443 self.MakeStep(PrepareChangeLog).Run() 446 self.MakeStep(PrepareChangeLog).Run()
444 447
445 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 448 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
446 449
447 # TODO(machenbach): Mock out call to date() in order to make a fixed 450 expected_cl = """1999-07-31: Version 3.22.5
448 # comparison here instead of a regexp match.
449 expected_cl = """\\d+\\-\\d+\\-\\d+: Version 3\\.22\\.5
450 451
451 Title text 1. 452 Title text 1.
452 453
453 Title text 3 \\(Chromium issue 321\\). 454 Title text 3 (Chromium issue 321).
454 455
455 Performance and stability improvements on all platforms\\. 456 Performance and stability improvements on all platforms.
456 # 457 #
457 # The change log above is auto-generated\\. Please review if all relevant 458 # The change log above is auto-generated. Please review if all relevant
458 # commit messages from the list below are included\\. 459 # commit messages from the list below are included.
459 # All lines starting with # will be stripped\\. 460 # All lines starting with # will be stripped.
460 # 461 #
461 # Title text 1. 462 # Title text 1.
462 # \\(author1@chromium\\.org\\) 463 # (author1@chromium.org)
463 # 464 #
464 # Title text 2 \\(Chromium issue 123\\). 465 # Title text 2 (Chromium issue 123).
465 # \\(author2@chromium\\.org\\) 466 # (author2@chromium.org)
466 # 467 #
467 # Title text 3 \\(Chromium issue 321\\). 468 # Title text 3 (Chromium issue 321).
468 # \\(author3@chromium\\.org\\) 469 # (author3@chromium.org)
469 # 470 #
470 # Title text 4 \\(Chromium issue 456\\). 471 # Title text 4 (Chromium issue 456).
471 # \\(author4@chromium\\.org\\) 472 # (author4@chromium.org)
472 # 473 #
473 #""" 474 #"""
474 475
475 self.assertTrue(re.match(expected_cl, actual_cl)) 476 self.assertEquals(expected_cl, actual_cl)
476 self.assertEquals("3", self.MakeStep().Restore("major")) 477 self.assertEquals("3", self.MakeStep().Restore("major"))
477 self.assertEquals("22", self.MakeStep().Restore("minor")) 478 self.assertEquals("22", self.MakeStep().Restore("minor"))
478 self.assertEquals("5", self.MakeStep().Restore("build")) 479 self.assertEquals("5", self.MakeStep().Restore("build"))
479 self.assertEquals("0", self.MakeStep().Restore("patch")) 480 self.assertEquals("0", self.MakeStep().Restore("patch"))
480 481
481 def testEditChangeLog(self): 482 def testEditChangeLog(self):
482 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 483 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
483 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 484 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
484 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) 485 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE])
485 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 486 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE])
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 733
733 Review URL: https://codereview.chromium.org/83173002 734 Review URL: https://codereview.chromium.org/83173002
734 735
735 ------------------------------------------------------------------------""") 736 ------------------------------------------------------------------------""")
736 self.assertEquals( 737 self.assertEquals(
737 """Prepare push to trunk. Now working on version 3.23.11. 738 """Prepare push to trunk. Now working on version 3.23.11.
738 739
739 R=danno@chromium.org 740 R=danno@chromium.org
740 741
741 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) 742 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