Bug 102007 - webkitpy: consolidate webkit-base-finding code
Summary: webkitpy: consolidate webkit-base-finding code
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dirk Pranke
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-12 16:20 PST by Dirk Pranke
Modified: 2012-11-14 17:29 PST (History)
6 users (show)

See Also:


Attachments
Patch (29.60 KB, patch)
2012-11-12 16:28 PST, Dirk Pranke
no flags Details | Formatted Diff | Diff
add missed tests (32.85 KB, patch)
2012-11-12 17:29 PST, Dirk Pranke
no flags Details | Formatted Diff | Diff
Patch (35.68 KB, patch)
2012-11-13 14:19 PST, Dirk Pranke
no flags Details | Formatted Diff | Diff
rework into a separate new WebKitFinder module (35.37 KB, patch)
2012-11-14 17:14 PST, Dirk Pranke
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Pranke 2012-11-12 16:20:57 PST
webkitpy: consolidate webkit-base-finding code
Comment 1 Dirk Pranke 2012-11-12 16:28:42 PST
Created attachment 173756 [details]
Patch
Comment 2 Dirk Pranke 2012-11-12 16:31:28 PST
Comment on attachment 173756 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173756&action=review

> Tools/Scripts/webkitpy/common/system/systemhost.py:51
> +    def webkit_base_dir(self):

I'm not actually sure that SystemHost is the best place for this. We know we don't want it in layout_tests.port, and it doesn't seem like common/config/Checkout is the right place (since that is too version-control-centric).

Arguably workspace.Workspace() might be the right place, but I'm not actually sure why that class exists and it seems to introduce an unnecessary additional concept. Maybe Workspace() should be merged into SystemHost()?
Comment 3 Eric Seidel (no email) 2012-11-12 16:37:07 PST
Checkout seems like the right place for finding your chromium vs. no checkout, etc.  It could also be exteneded to support tarballs, or whatever other diretory structures folks want.

Workspace was just a place to stick the zip and "find me a filename" logic, which seemed above FileSystem, but not really fitting for Checkout.  I'm open to other names or organizations.
Comment 4 Dirk Pranke 2012-11-12 16:44:41 PST
(In reply to comment #3)
> Checkout seems like the right place for finding your chromium vs. no checkout, etc.  It could also be exteneded to support tarballs, or whatever other diretory structures folks want.
> 

Checkout seems to require an scm object in order to function, and seems to be concerned with changelogs and other stuff specific to actually doing things with version-control. It doesn't seem like the rest of the class would work without a real scm object, so moving these routines there seems like a bad fit.

> Workspace was just a place to stick the zip and "find me a filename" logic, which seemed above FileSystem, but not really fitting for Checkout.  I'm open to other names or organizations.

Do you dislike just keeping this stuff in SystemHost (and maybe getting rid of Workspace)?
Comment 5 Eric Seidel (no email) 2012-11-12 16:47:02 PST
Maybe Checkout should have some sort of superclass (like Workspace?) which handled the idea of a general place where the code is stored, and was not dependent on SCM?
Comment 6 Eric Seidel (no email) 2012-11-12 16:47:49 PST
SystemHost shouldn't need to know anything about WebKit, should it?  It's supposed to be your basic mocking root for how you talk to the outside world?
Comment 7 Dirk Pranke 2012-11-12 16:56:45 PST
(In reply to comment #5)
> Maybe Checkout should have some sort of superclass (like Workspace?) which handled the idea of a general place where the code is stored, and was not dependent on SCM?

I'm open to something like this, though it's not clear to me that there's really anything really in common with Checkout and Workspace at all.

(In reply to comment #6)
> SystemHost shouldn't need to know anything about WebKit, should it?  It's supposed to be your basic mocking root for how you talk to the outside world?

I don't know that SystemHost has this specifically as its raison d'etre. I wonder how many things we write at all in webkitpy that want a systemhost (or anything) but don't want either a full host or at least something that implements these few new routines (the layout_tests.port stuff may be the only code that depends on systemhost rather than host, and that's true to avoid circular dependencies and because I don't want the port stuff to depend on SCM objects). 

I also worry a bit about a proliferation of fine-grained (mostly base) classes. It looks like the two routines in Workspace are only used by tool.bot.layouttestresultsreader; I'd probably just roll them into that class until someone else actually has a need for them.

WDYT?
Comment 8 Dirk Pranke 2012-11-12 17:29:46 PST
Created attachment 173770 [details]
add missed tests
Comment 9 Eric Seidel (no email) 2012-11-13 13:05:27 PST
(In reply to comment #7)
> (In reply to comment #5)
> I also worry a bit about a proliferation of fine-grained (mostly base) classes. It looks like the two routines in Workspace are only used by tool.bot.layouttestresultsreader; I'd probably just roll them into that class until someone else actually has a need for them.
> 
> WDYT?

Thats fine, or you could simply move them into that class.

One of my goals with webkitpy was to write re-usable code. :)  When useful I tried to split things out into classes.  i agree that Workspace has seen little other use (although I just used the find_unused_filename code in my --profile patch last week).

In any case, you're in this code much more than I am these days.  I don't think small classes are bad.  I do think monolithic classes are.  And files with lots of classes are similarly bad.
Comment 10 Eric Seidel (no email) 2012-11-13 13:06:53 PST
Comment on attachment 173770 [details]
add missed tests

SystemHost currently ahs nothing to do with WebKit.  it's simply a mock-point for writing python code which can be easily mocked.  I dont' think this is the right direction.  I do support consolidating this logic. But SystemHost is the wrong place IMO.
Comment 11 Dirk Pranke 2012-11-13 13:12:02 PST
(In reply to comment #10)
> (From update of attachment 173770 [details])
> SystemHost currently ahs nothing to do with WebKit.  it's simply a mock-point for writing python code which can be easily mocked.  I dont' think this is the right direction.  I do support consolidating this logic. But SystemHost is the wrong place IMO.

Okay, I've got no real problem with that.

How about I move these functions into Workspace, and then (in separate follow-on patches) move the existing functions in Workspace into LayoutTestsResultReader and make Checkout derive from Workspace?
Comment 12 Dirk Pranke 2012-11-13 13:17:44 PST
Whoops, didn't see this comment ...

(In reply to comment #9)
> (In reply to comment #7)
> > (In reply to comment #5)
> > I also worry a bit about a proliferation of fine-grained (mostly base) classes. It looks like the two routines in Workspace are only used by tool.bot.layouttestresultsreader; I'd probably just roll them into that class until someone else actually has a need for them.
> > 
> > WDYT?
> 
> Thats fine, or you could simply move them into that class.
> 
> One of my goals with webkitpy was to write re-usable code. :)  When useful I tried to split things out into classes.  i agree that Workspace has seen little other use (although I just used the find_unused_filename code in my --profile patch last week).
> 

Don't think I saw the reference to that ..


> In any case, you're in this code much more than I am these days.  I don't think small classes are bad.  I do think monolithic classes are.  And files with lots of classes are similarly bad.

I don't think small classes are bad per se, and I definitely agree that both big classes and "catch-all" classes (like Port) are bad. Of course, having to jump between multiple places and files to follow the code incurs its own cost. I tend to like to break things out into their own files only if they are actually being reused or if reducing the size of the files does make things easier to file

I agree that putting webkit_base_dir() in SystemHost is at best a grey area, and wouldn't really argue that it's just bad :).
Comment 13 Dirk Pranke 2012-11-13 14:19:34 PST
Created attachment 173987 [details]
Patch
Comment 14 Dirk Pranke 2012-11-14 17:14:22 PST
Created attachment 174296 [details]
rework into a separate new WebKitFinder module
Comment 15 Dirk Pranke 2012-11-14 17:14:38 PST
fourth times' a charm?
Comment 16 Eric Seidel (no email) 2012-11-14 17:19:15 PST
Comment on attachment 174296 [details]
rework into a separate new WebKitFinder module

LGTM.
Comment 17 Dirk Pranke 2012-11-14 17:29:15 PST
Committed r134701: <http://trac.webkit.org/changeset/134701>