Changeset 203386 in webkit
- Timestamp:
- Jul 18, 2016, 5:24:50 PM (9 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r203350 r203386 1 2016-07-18 Aakash Jain <aakash_jain@apple.com> 2 3 EWS console logs doesn't go to log file 4 https://bugs.webkit.org/show_bug.cgi?id=159539 5 <rdar://problem/24464570> 6 7 Reviewed by David Kilzer. 8 9 * Scripts/webkitpy/common/system/logutils.py: 10 (configure_logger_to_log_to_file): Added method to configure the logger to log to file. 11 (FileSystemHandler): Added class which uses logging.FileHandler as base class and supports writing 12 to filesystem. It also supports passing MockFilesystem. 13 (FileSystemHandler.__init__): Initialize the class and calls base class __init__. 14 (FileSystemHandler._open): Overrides the base class _open method to use filesystem object. 15 * Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py: 16 (AbstractEarlyWarningSystemTest.test_failing_tests_message): Added MockHost() parameter. 17 (_test_ews): Same. 18 * Scripts/webkitpy/tool/commands/queues.py: 19 (AbstractQueue.begin_work_queue): Configure the logger to log to file. 20 (AbstractQueue._log_directory): Using filesystem object instead of os. 21 (AbstractQueue.queue_log_path): Same. 22 (AbstractQueue.__init__): Passed host parameter. 23 (PatchProcessingQueue.__init__): Same. 24 (CommitQueue.__init__): Same. 25 (AbstractReviewQueue.__init__): Same. 26 (StyleQueue.__init__): Same. 27 * Scripts/webkitpy/tool/commands/queues_unittest.py: 28 (TestCommitQueue): Passed MockHost() as host. 29 (TestCommitQueue.__init__): Same. 30 (TestQueue.__init__): Same. 31 (TestReviewQueue.__init__): Same. 32 (TestFeederQueue.__init__): Same. 33 (AbstractPatchQueueTest.test_next_patch): Same. 34 (PatchProcessingQueueTest.test_upload_results_archive_for_patch): Same. 35 (test_commit_queue_failure): Same. 36 (MockCommitQueueTask.results_from_patch_test_run): Same. 37 (test_rollout_lands): Same. 38 (test_non_valid_patch): Same. 39 (test_auto_retry): Same. 40 (test_style_queue_with_watch_list_exception): Same. 41 1 42 2016-07-02 Filip Pizlo <fpizlo@apple.com> 2 43 -
trunk/Tools/Scripts/webkitpy/common/system/logutils.py
r132840 r203386 31 31 32 32 import webkitpy 33 34 from logging import FileHandler 33 35 34 36 … … 210 212 211 213 return handlers 214 215 216 def configure_logger_to_log_to_file(logger, log_path, filesystem): 217 log_directory = filesystem.dirname(log_path) 218 if log_directory and not filesystem.exists(log_directory): 219 filesystem.maybe_make_directory(log_directory) 220 221 handler = FileSystemHandler(log_path, filesystem) 222 formatter = logging.Formatter('%(asctime)s - %(message)s') 223 handler.setFormatter(formatter) 224 225 logger.addHandler(handler) 226 227 228 class FileSystemHandler(FileHandler): 229 def __init__(self, filename, filesystem): 230 self.filename = filename 231 self.filesystem = filesystem 232 FileHandler.__init__(self, filename) 233 234 def _open(self): 235 return self.filesystem.open_text_file_for_writing(self.filename) -
trunk/Tools/Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py
r191345 r203386 29 29 from webkitpy.thirdparty.mock import Mock 30 30 from webkitpy.common.host import Host 31 from webkitpy.common.host_mock import MockHost 31 32 from webkitpy.common.net.layouttestresults import LayoutTestResults 32 33 from webkitpy.common.system.outputcapture import OutputCapture … … 50 51 ews = TestEWS() 51 52 ews.bind_to_tool(MockTool()) 53 ews.host = MockHost() 52 54 ews._options = MockOptions(port=None, confirm=False) 53 55 OutputCapture().assert_outputs(self, ews.begin_work_queue, expected_logs=self._default_begin_work_queue_logs(ews.name)) … … 90 92 def _test_ews(self, ews): 91 93 ews.bind_to_tool(MockTool()) 94 ews.host = MockHost() 92 95 options = Mock() 93 96 options.port = None -
trunk/Tools/Scripts/webkitpy/tool/commands/queues.py
r202319 r203386 42 42 from webkitpy.common.config.committervalidator import CommitterValidator 43 43 from webkitpy.common.config.ports import DeprecatedPort 44 from webkitpy.common.host import Host 44 45 from webkitpy.common.net.bugzilla import Attachment 45 46 from webkitpy.common.net.statusserver import StatusServer 47 from webkitpy.common.system import logutils 46 48 from webkitpy.common.system.executive import ScriptError 47 49 from webkitpy.tool.bot.botinfo import BotInfo … … 67 69 _error_status = "Error" 68 70 69 def __init__(self, options=None ): # Default values should never be collections (like []) as default values are shared between invocations71 def __init__(self, options=None, host=Host()): # Default values should never be collections (like []) as default values are shared between invocations 70 72 options_list = (options or []) + [ 71 73 make_option("--no-confirm", action="store_false", dest="confirm", default=True, help="Do not ask the user for confirmation before running the queue. Dangerous!"), … … 77 79 if not hasattr(self, 'architecture'): 78 80 self.architecture = None 81 self.host = host 79 82 80 83 def _cc_watchers(self, bug_id): … … 110 113 111 114 def _log_directory(self): 112 return os.path.join("..", "%s-logs" % self.name)115 return self.host.filesystem.join("..", "%s-logs" % self.name) 113 116 114 117 # QueueEngineDelegate methods 115 118 116 119 def queue_log_path(self): 117 return os.path.join(self._log_directory(), "%s.log" % self.name)120 return self.host.filesystem.join(self._log_directory(), "%s.log" % self.name) 118 121 119 122 def work_item_log_path(self, work_item): … … 121 124 122 125 def begin_work_queue(self): 126 logutils.configure_logger_to_log_to_file(_log, self.queue_log_path(), self.host.filesystem) 123 127 _log.info("CAUTION: %s will discard all local changes in \"%s\"" % (self.name, self._tool.scm().checkout_root)) 124 128 if self._options.confirm: … … 260 264 port_name = None 261 265 262 def __init__(self, options=None ):266 def __init__(self, options=None, host=Host()): 263 267 self._port = None # We can't instantiate port here because tool isn't avaialble. 264 AbstractPatchQueue.__init__(self, options) 268 self.host = host 269 AbstractPatchQueue.__init__(self, options, host=host) 265 270 266 271 # FIXME: This is a hack to map between the old port names and the new port names. … … 314 319 315 320 class CommitQueue(PatchProcessingQueue, StepSequenceErrorHandler, CommitQueueTaskDelegate): 316 def __init__(self, commit_queue_task_class=CommitQueueTask): 321 def __init__(self, commit_queue_task_class=CommitQueueTask, host=Host()): 322 self.host = host 317 323 self._commit_queue_task_class = commit_queue_task_class 318 PatchProcessingQueue.__init__(self )324 PatchProcessingQueue.__init__(self, host=host) 319 325 320 326 name = "commit-queue" … … 431 437 class AbstractReviewQueue(PatchProcessingQueue, StepSequenceErrorHandler): 432 438 """This is the base-class for the EWS queues and the style-queue.""" 433 def __init__(self, options=None): 434 PatchProcessingQueue.__init__(self, options) 439 def __init__(self, options=None, host=Host()): 440 self.host = host 441 PatchProcessingQueue.__init__(self, options, host=host) 435 442 436 443 def review_patch(self, patch): … … 464 471 name = "style-queue" 465 472 466 def __init__(self): 467 AbstractReviewQueue.__init__(self) 473 def __init__(self, host=Host()): 474 self.host = host 475 AbstractReviewQueue.__init__(self, host=host) 468 476 469 477 def review_patch(self, patch): -
trunk/Tools/Scripts/webkitpy/tool/commands/queues_unittest.py
r202319 r203386 32 32 from webkitpy.common.checkout.scm import CheckoutNeedsUpdate 33 33 from webkitpy.common.checkout.scm.scm_mock import MockSCM 34 from webkitpy.common.host_mock import MockHost 34 35 from webkitpy.common.net.layouttestresults import LayoutTestResults 35 36 from webkitpy.common.net.bugzilla import Attachment … … 48 49 class TestCommitQueue(CommitQueue): 49 50 def __init__(self, tool=None): 50 CommitQueue.__init__(self )51 CommitQueue.__init__(self, host=MockHost()) 51 52 if tool: 52 53 self.bind_to_tool(tool) … … 63 64 name = "test-queue" 64 65 66 def __init__(self): 67 AbstractPatchQueue.__init__(self, host=MockHost()) 68 65 69 66 70 class TestReviewQueue(AbstractReviewQueue): 67 71 name = "test-review-queue" 68 72 73 def __init__(self): 74 AbstractReviewQueue.__init__(self, host=MockHost()) 75 69 76 70 77 class TestFeederQueue(FeederQueue): 71 78 _sleep_duration = 0 79 80 def __init__(self): 81 FeederQueue.__init__(self, host=MockHost()) 72 82 73 83 … … 154 164 class AbstractPatchQueueTest(CommandsTest): 155 165 def test_next_patch(self): 156 queue = AbstractPatchQueue( )166 queue = AbstractPatchQueue(host=MockHost()) 157 167 tool = MockTool() 158 168 queue.bind_to_tool(tool) … … 172 182 class PatchProcessingQueueTest(CommandsTest): 173 183 def test_upload_results_archive_for_patch(self): 174 queue = PatchProcessingQueue( )184 queue = PatchProcessingQueue(host=MockHost()) 175 185 queue.name = "mock-queue" 176 186 tool = MockTool() … … 261 271 "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n", 262 272 } 263 self.assert_queue_outputs(CommitQueue( ), tool=tool, expected_logs=expected_logs)273 self.assert_queue_outputs(CommitQueue(host=MockHost()), tool=tool, expected_logs=expected_logs) 264 274 265 275 def test_commit_queue_failure(self): … … 277 287 "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n", 278 288 } 279 queue = CommitQueue( )289 queue = CommitQueue(host=MockHost()) 280 290 281 291 def mock_run_webkit_patch(command): … … 309 319 return LayoutTestResults([test_results.TestResult("mock_test_name.html", failures=[test_failures.FailureTextMismatch()])], did_exceed_test_failure_limit=False) 310 320 311 queue = CommitQueue(MockCommitQueueTask )321 queue = CommitQueue(MockCommitQueueTask, host=MockHost()) 312 322 313 323 def mock_run_webkit_patch(command): … … 348 358 "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n", 349 359 } 350 self.assert_queue_outputs(CommitQueue( ), tool=tool, expected_logs=expected_logs)360 self.assert_queue_outputs(CommitQueue(host=MockHost()), tool=tool, expected_logs=expected_logs) 351 361 352 362 def test_rollout_lands(self): … … 373 383 "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10005' with comment 'Rejecting attachment 10005 from commit-queue.\n\nMock error message'\n", 374 384 } 375 self.assert_queue_outputs(CommitQueue( ), tool=tool, work_item=rollout_patch, expected_logs=expected_logs)385 self.assert_queue_outputs(CommitQueue(host=MockHost()), tool=tool, work_item=rollout_patch, expected_logs=expected_logs) 376 386 377 387 def test_non_valid_patch(self): … … 384 394 """, 385 395 } 386 self.assert_queue_outputs(CommitQueue( ), tool=tool, work_item=patch, expected_logs=expected_logs)396 self.assert_queue_outputs(CommitQueue(host=MockHost()), tool=tool, work_item=patch, expected_logs=expected_logs) 387 397 388 398 def test_auto_retry(self): 389 queue = CommitQueue( )399 queue = CommitQueue(host=MockHost()) 390 400 options = Mock() 391 401 options.parent_command = "commit-queue" … … 499 509 } 500 510 tool = MockTool(executive_throws_when_run=set(['check-style'])) 501 self.assert_queue_outputs(StyleQueue( ), expected_logs=expected_logs, tool=tool)511 self.assert_queue_outputs(StyleQueue(host=MockHost()), expected_logs=expected_logs, tool=tool) 502 512 503 513 def test_style_queue_with_watch_list_exception(self): … … 524 534 } 525 535 tool = MockTool(executive_throws_when_run=set(['apply-watchlist-local'])) 526 self.assert_queue_outputs(StyleQueue( ), expected_logs=expected_logs, tool=tool)536 self.assert_queue_outputs(StyleQueue(host=MockHost()), expected_logs=expected_logs, tool=tool)
Note:
See TracChangeset
for help on using the changeset viewer.