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

Side by Side Diff: tests/trychange_unittest.py

Issue 543012: Add the capability to filter out files on try job with regexp. (Closed)
Patch Set: Created 10 years, 11 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
« no previous file with comments | « tests/scm_unittest.py ('k') | trychange.py » ('j') | trychange.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for trychange.py.""" 6 """Unit tests for trychange.py."""
7 7
8 import optparse 8 import optparse
9 9
10 # Local imports 10 # Local imports
(...skipping 15 matching lines...) Expand all
26 self.mox.StubOutWithMock(trychange.scm.SVN, 'GenerateDiff') 26 self.mox.StubOutWithMock(trychange.scm.SVN, 'GenerateDiff')
27 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetCheckoutRoot') 27 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetCheckoutRoot')
28 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetEmail') 28 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetEmail')
29 self.fake_root = self.Dir() 29 self.fake_root = self.Dir()
30 self.expected_files = ['foo.txt', 'bar.txt'] 30 self.expected_files = ['foo.txt', 'bar.txt']
31 self.options = optparse.Values() 31 self.options = optparse.Values()
32 self.options.files = self.expected_files 32 self.options.files = self.expected_files
33 self.options.diff = None 33 self.options.diff = None
34 self.options.name = None 34 self.options.name = None
35 self.options.email = None 35 self.options.email = None
36 self.options.exclude = []
36 37
37 38
38 class TryChangeUnittest(TryChangeTestsBase): 39 class TryChangeUnittest(TryChangeTestsBase):
39 """General trychange.py tests.""" 40 """General trychange.py tests."""
40 def testMembersChanged(self): 41 def testMembersChanged(self):
41 members = [ 42 members = [
42 'EscapeDot', 'GIT', 'GuessVCS', 'GetMungedDiff', 43 'EscapeDot', 'GIT', 'GuessVCS', 'GetMungedDiff',
43 'HELP_STRING', 'InvalidScript', 'NoTryServerAccess', 'PrintSuccess', 44 'HELP_STRING', 'InvalidScript', 'NoTryServerAccess', 'PrintSuccess',
44 'SCM', 'SVN', 'TryChange', 'USAGE', 45 'SCM', 'SVN', 'TryChange', 'USAGE',
45 'breakpad', 'datetime', 'errno', 'gclient_utils', 'getpass', 'logging', 46 'breakpad', 'datetime', 'errno', 'gclient_utils', 'getpass', 'logging',
46 'optparse', 'os', 'posixpath', 'scm', 'shutil', 'sys', 'tempfile', 47 'optparse', 'os', 'posixpath', 're', 'scm', 'shutil', 'sys', 'tempfile',
47 'urllib', 48 'urllib',
48 ] 49 ]
49 # If this test fails, you should add the relevant test. 50 # If this test fails, you should add the relevant test.
50 self.compareMembers(trychange, members) 51 self.compareMembers(trychange, members)
51 52
52 53
53 class SVNUnittest(TryChangeTestsBase): 54 class SVNUnittest(TryChangeTestsBase):
54 """trychange.SVN tests.""" 55 """trychange.SVN tests."""
55 def testMembersChanged(self): 56 def testMembersChanged(self):
56 members = [ 57 members = [
(...skipping 26 matching lines...) Expand all
83 'GetCodeReviewSetting', 'ReadRootFile', 84 'GetCodeReviewSetting', 'ReadRootFile',
84 'GenerateDiff', 'GetFileNames', 85 'GenerateDiff', 'GetFileNames',
85 ] 86 ]
86 # If this test fails, you should add the relevant test. 87 # If this test fails, you should add the relevant test.
87 self.compareMembers(trychange.GIT, members) 88 self.compareMembers(trychange.GIT, members)
88 89
89 def testBasic(self): 90 def testBasic(self):
90 trychange.scm.GIT.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root) 91 trychange.scm.GIT.GetCheckoutRoot(self.fake_root).AndReturn(self.fake_root)
91 trychange.scm.GIT.GenerateDiff(self.fake_root, 92 trychange.scm.GIT.GenerateDiff(self.fake_root,
92 full_move=True, 93 full_move=True,
94 files=['foo.txt', 'bar.txt'],
93 branch=None).AndReturn('A diff') 95 branch=None).AndReturn('A diff')
94 trychange.scm.GIT.GetPatchName(self.fake_root).AndReturn('bleh-1233') 96 trychange.scm.GIT.GetPatchName(self.fake_root).AndReturn('bleh-1233')
95 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com') 97 trychange.scm.GIT.GetEmail(self.fake_root).AndReturn('georges@example.com')
96 self.mox.ReplayAll() 98 self.mox.ReplayAll()
97 git = trychange.GIT(self.options, self.fake_root) 99 git = trychange.GIT(self.options, self.fake_root)
98 self.assertEqual(git.GetFileNames(), self.expected_files) 100 self.assertEqual(git.GetFileNames(), self.expected_files)
99 self.assertEqual(git.checkout_root, self.fake_root) 101 self.assertEqual(git.checkout_root, self.fake_root)
100 self.assertEqual(git.GenerateDiff(), 'A diff') 102 self.assertEqual(git.GenerateDiff(), 'A diff')
101 103
102 104
103 if __name__ == '__main__': 105 if __name__ == '__main__':
104 import unittest 106 import unittest
105 unittest.main() 107 unittest.main()
OLDNEW
« no previous file with comments | « tests/scm_unittest.py ('k') | trychange.py » ('j') | trychange.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698