Bug 74566

Summary: webkitpy: finish refactoring port classes to make a host mandatory
Product: WebKit Reporter: Dirk Pranke <dpranke>
Component: New BugsAssignee: Dirk Pranke <dpranke>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, eric, ojan, tony
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 74551, 74556, 74562    
Bug Blocks: 74138, 74878    
Attachments:
Description Flags
Patch
none
delete unneeded MockSystemHost import
none
update w/ review feedback none

Dirk Pranke
Reported 2011-12-14 17:19:39 PST
webkitpy: finish refactoring port classes to make a host mandatory
Attachments
Patch (41.59 KB, patch)
2011-12-14 17:22 PST, Dirk Pranke
no flags
delete unneeded MockSystemHost import (42.77 KB, patch)
2011-12-15 19:52 PST, Dirk Pranke
no flags
update w/ review feedback (43.84 KB, patch)
2011-12-19 12:21 PST, Dirk Pranke
no flags
Dirk Pranke
Comment 1 2011-12-14 17:22:03 PST
Dirk Pranke
Comment 2 2011-12-14 17:23:49 PST
this is the last (4 of 4) of the patches ... this can't easily be broken up any smaller because of the heavy dependency of the integrationtests and rebaselining tests on how mock filesystems are created and populated.
Eric Seidel (no email)
Comment 3 2011-12-14 18:31:12 PST
Comment on attachment 119344 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=119344&action=review LGTM. > Tools/Scripts/webkitpy/layout_tests/port/base.py:55 > +from webkitpy.common.system.systemhost_mock import MockSystemHost I don't think we want to import testing code into production code. I suspect this import isn't even needed. :)
Dirk Pranke
Comment 4 2011-12-14 20:00:21 PST
Comment on attachment 119344 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=119344&action=review >> Tools/Scripts/webkitpy/layout_tests/port/base.py:55 >> +from webkitpy.common.system.systemhost_mock import MockSystemHost > > I don't think we want to import testing code into production code. I suspect this import isn't even needed. :) I think you're right and this can be deleted now.
Dirk Pranke
Comment 5 2011-12-15 19:52:28 PST
Created attachment 119547 [details] delete unneeded MockSystemHost import
Eric Seidel (no email)
Comment 6 2011-12-15 20:46:37 PST
Comment on attachment 119547 [details] delete unneeded MockSystemHost import View in context: https://bugs.webkit.org/attachment.cgi?id=119547&action=review LGTM. > Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py:54 > + if 'executive' in kwargs: > + host.executive = kwargs['executive'] I thought you were going with the executive=None route? Port doesn't care about the executive parameter anymore. > Tools/Scripts/webkitpy/layout_tests/port/test.py:-306 > -def unit_test_filesystem(files=None): > - files = files or {} > - fs = MockFileSystem(files, dirs=set(['/mock-checkout'])) # Make sure at least the checkout_root exists as a directory. > - add_unit_tests_to_mock_filesystem(fs) > - return fs Yay! > Tools/Scripts/webkitpy/layout_tests/port/test.py:315 > + self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt' Probably should be using fs.join, but really doesn't matter. :) > Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:404 > + host = MockHost() > + self.assertTrue(passing_run(host=host)) > + self.assertEquals(host.filesystem.read_text_file('/tmp/layout-test-results/passes/error-stderr.txt'), I think passing_run() wants to be a method on some helper object which can be created with a Host. But obviously that's a later change. Free funtions aren't very pythonic IMO. > Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:411 > + tests_run = get_tests_run(['--test-list=%s' % filename], tests_included=True, flatten_batches=True, host=host) likewise get_tests_run would be on the same object as passing_run. It would just be run() and then you'd assert on some sort of passed, tests_run, members, etc. :) Again, not for this patch (and maybe not ever!), just musing. > Tools/Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests_unittest.py:212 > - filesystem.maybe_make_directory(mock_scm.checkout_root) > + filesystem.maybe_make_directory(host.scm().checkout_root) I'm pretty sure that the default filesystem already includes checkout_root. :)
Dirk Pranke
Comment 7 2011-12-16 09:55:46 PST
(In reply to comment #6) > > Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py:54 > > + if 'executive' in kwargs: > > + host.executive = kwargs['executive'] > > I thought you were going with the executive=None route? Port doesn't care about the executive parameter anymore. > I fix this in the patch in bug 74562 (which will land before this), but I hadn't rebased this patch against the latest version of that patch; it looks like these lines are bad. Will fix. > > Tools/Scripts/webkitpy/layout_tests/port/test.py:315 > > + self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt' > > Probably should be using fs.join, but really doesn't matter. :) > Perhaps; we pervasively assume string concatenations and os.sep == '/' in this file (which is safe when we have MockHosts); fixing it everywhere would probably be more trouble than it's worth. > > Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:404 > > + host = MockHost() > > + self.assertTrue(passing_run(host=host)) > > + self.assertEquals(host.filesystem.read_text_file('/tmp/layout-test-results/passes/error-stderr.txt'), > > I think passing_run() wants to be a method on some helper object which can be created with a Host. But obviously that's a later change. Free funtions aren't very pythonic IMO. I think you and I disagree on the badness of free functions; I have nothing against them as long as they're pure (Port.factory.get() being my favorite example of you and I disagreeing). That said, you're right in this case a helper object for this set of functions might be cleaner. > > Tools/Scripts/webkitpy/to_be_moved/rebaseline_chromium_webkit_tests_unittest.py:212 > > - filesystem.maybe_make_directory(mock_scm.checkout_root) > > + filesystem.maybe_make_directory(host.scm().checkout_root) > > I'm pretty sure that the default filesystem already includes checkout_root. :) You might be right; I'll double check. Thanks for the review!
Dirk Pranke
Comment 8 2011-12-19 12:21:24 PST
Created attachment 119900 [details] update w/ review feedback
Dirk Pranke
Comment 9 2011-12-19 12:22:27 PST
Note You need to log in before you can comment on or make changes to this bug.