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

Side by Side Diff: Tools/Scripts/webkitpy/common/checkout/checkout_unittest.py

Issue 15981013: fix paths in webkitpy tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | « no previous file | Tools/Scripts/webkitpy/w3c/test_converter.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2010 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 # 2 #
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 disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 18 matching lines...) Expand all
29 import codecs 29 import codecs
30 import os 30 import os
31 import shutil 31 import shutil
32 import tempfile 32 import tempfile
33 import unittest2 as unittest 33 import unittest2 as unittest
34 34
35 from .checkout import Checkout 35 from .checkout import Checkout
36 from .changelog import ChangeLogEntry 36 from .changelog import ChangeLogEntry
37 from .scm import CommitMessage, SCMDetector 37 from .scm import CommitMessage, SCMDetector
38 from .scm.scm_mock import MockSCM 38 from .scm.scm_mock import MockSCM
39 from webkitpy.common.webkit_finder import WebKitFinder
39 from webkitpy.common.system.executive import Executive, ScriptError 40 from webkitpy.common.system.executive import Executive, ScriptError
40 from webkitpy.common.system.filesystem import FileSystem # FIXME: This should n ot be needed. 41 from webkitpy.common.system.filesystem import FileSystem # FIXME: This should n ot be needed.
41 from webkitpy.common.system.filesystem_mock import MockFileSystem 42 from webkitpy.common.system.filesystem_mock import MockFileSystem
42 from webkitpy.common.system.executive_mock import MockExecutive 43 from webkitpy.common.system.executive_mock import MockExecutive
43 from webkitpy.common.system.outputcapture import OutputCapture 44 from webkitpy.common.system.outputcapture import OutputCapture
44 from webkitpy.thirdparty.mock import Mock 45 from webkitpy.thirdparty.mock import Mock
45 46
46 47
47 _changelog1entry1 = u"""2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org> 48 _changelog1entry1 = u"""2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org>
48 49
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 * Path/To/Complicated/File: Added. 96 * Path/To/Complicated/File: Added.
96 """ 97 """
97 98
98 def setUp(self): 99 def setUp(self):
99 # FIXME: This should not need to touch the filesystem, however 100 # FIXME: This should not need to touch the filesystem, however
100 # ChangeLog is difficult to mock at current. 101 # ChangeLog is difficult to mock at current.
101 self.filesystem = FileSystem() 102 self.filesystem = FileSystem()
102 self.temp_dir = str(self.filesystem.mkdtemp(suffix="changelogs")) 103 self.temp_dir = str(self.filesystem.mkdtemp(suffix="changelogs"))
103 self.old_cwd = self.filesystem.getcwd() 104 self.old_cwd = self.filesystem.getcwd()
104 self.filesystem.chdir(self.temp_dir) 105 self.filesystem.chdir(self.temp_dir)
106 self.webkit_base = WebKitFinder(self.filesystem).webkit_base()
105 107
106 # Trick commit-log-editor into thinking we're in a Subversion working co py so it won't 108 # Trick commit-log-editor into thinking we're in a Subversion working co py so it won't
107 # complain about not being able to figure out what SCM is in use. 109 # complain about not being able to figure out what SCM is in use.
108 # FIXME: VCSTools.pm is no longer so easily fooled. It logs because "sv n info" doesn't 110 # FIXME: VCSTools.pm is no longer so easily fooled. It logs because "sv n info" doesn't
109 # treat a bare .svn directory being part of an svn checkout. 111 # treat a bare .svn directory being part of an svn checkout.
110 self.filesystem.maybe_make_directory(".svn") 112 self.filesystem.maybe_make_directory(".svn")
111 113
112 self.changelogs = map(self.filesystem.abspath, (self.filesystem.join("To ols", "ChangeLog"), self.filesystem.join("LayoutTests", "ChangeLog"))) 114 self.changelogs = map(self.filesystem.abspath, (self.filesystem.join("To ols", "ChangeLog"), self.filesystem.join("LayoutTests", "ChangeLog")))
113 for path, contents in zip(self.changelogs, (_changelog1, _changelog2)): 115 for path, contents in zip(self.changelogs, (_changelog1, _changelog2)):
114 self.filesystem.maybe_make_directory(self.filesystem.dirname(path)) 116 self.filesystem.maybe_make_directory(self.filesystem.dirname(path))
115 self.filesystem.write_text_file(path, contents) 117 self.filesystem.write_text_file(path, contents)
116 118
117 def tearDown(self): 119 def tearDown(self):
118 self.filesystem.rmtree(self.temp_dir) 120 self.filesystem.rmtree(self.temp_dir)
119 self.filesystem.chdir(self.old_cwd) 121 self.filesystem.chdir(self.old_cwd)
120 122
121 def test_commit_message_for_this_commit(self): 123 def test_commit_message_for_this_commit(self):
122 executive = Executive() 124 executive = Executive()
123 125
124 def mock_run(*args, **kwargs): 126 def mock_run(*args, **kwargs):
125 # Note that we use a real Executive here, not a MockExecutive, so we can test that we're 127 # Note that we use a real Executive here, not a MockExecutive, so we can test that we're
126 # invoking commit-log-editor correctly. 128 # invoking commit-log-editor correctly.
127 env = os.environ.copy() 129 env = os.environ.copy()
128 env['CHANGE_LOG_EMAIL_ADDRESS'] = 'vestbo@webkit.org' 130 env['CHANGE_LOG_EMAIL_ADDRESS'] = 'vestbo@webkit.org'
129 kwargs['env'] = env 131 kwargs['env'] = env
130 return executive.run_command(*args, **kwargs) 132 return executive.run_command(*args, **kwargs)
131 133
132 detector = SCMDetector(self.filesystem, executive) 134 detector = SCMDetector(self.filesystem, executive)
133 real_scm = detector.detect_scm_system(self.old_cwd) 135 real_scm = detector.detect_scm_system(self.webkit_base)
134 136
135 mock_scm = MockSCM() 137 mock_scm = MockSCM()
136 mock_scm.run = mock_run 138 mock_scm.run = mock_run
137 mock_scm.script_path = real_scm.script_path 139 mock_scm.script_path = real_scm.script_path
138 140
139 checkout = Checkout(mock_scm) 141 checkout = Checkout(mock_scm)
140 checkout.modified_changelogs = lambda git_commit, changed_files=None: se lf.changelogs 142 checkout.modified_changelogs = lambda git_commit, changed_files=None: se lf.changelogs
141 commit_message = checkout.commit_message_for_this_commit(git_commit=None , return_stderr=True) 143 commit_message = checkout.commit_message_for_this_commit(git_commit=None , return_stderr=True)
142 # Throw away the first line - a warning about unknown VCS root. 144 # Throw away the first line - a warning about unknown VCS root.
143 commit_message.message_lines = commit_message.message_lines[1:] 145 commit_message.message_lines = commit_message.message_lines[1:]
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 237
236 def test_apply_patch(self): 238 def test_apply_patch(self):
237 checkout = self._make_checkout() 239 checkout = self._make_checkout()
238 checkout._executive = MockExecutive(should_log=True) 240 checkout._executive = MockExecutive(should_log=True)
239 checkout._scm.script_path = lambda script: script 241 checkout._scm.script_path = lambda script: script
240 mock_patch = Mock() 242 mock_patch = Mock()
241 mock_patch.contents = lambda: "foo" 243 mock_patch.contents = lambda: "foo"
242 mock_patch.reviewer = lambda: None 244 mock_patch.reviewer = lambda: None
243 expected_logs = "MOCK run_command: ['svn-apply', '--force'], cwd=/mock-c heckout, input=foo\n" 245 expected_logs = "MOCK run_command: ['svn-apply', '--force'], cwd=/mock-c heckout, input=foo\n"
244 OutputCapture().assert_outputs(self, checkout.apply_patch, [mock_patch], expected_logs=expected_logs) 246 OutputCapture().assert_outputs(self, checkout.apply_patch, [mock_patch], expected_logs=expected_logs)
OLDNEW
« no previous file with comments | « no previous file | Tools/Scripts/webkitpy/w3c/test_converter.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698