Bug 65413

Summary: Introduce SpecifierSorter, a thing that knows how specifiers should be ordered.
Product: WebKit Reporter: Dimitri Glazkov (Google) <dglazkov>
Component: Tools / TestsAssignee: Dimitri Glazkov (Google) <dglazkov>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 64385, 65444    
Attachments:
Description Flags
WIP:Switching computers.
none
Patch abarth: review+

Description Dimitri Glazkov (Google) 2011-07-30 11:18:25 PDT
Introduce SpecifierSorter, a thing that knows how specifiers should be ordered.
Comment 1 Dimitri Glazkov (Google) 2011-07-30 11:19:11 PDT
Created attachment 102438 [details]
WIP:Switching computers.
Comment 2 Dimitri Glazkov (Google) 2011-07-30 14:55:33 PDT
Created attachment 102440 [details]
Patch
Comment 3 Adam Barth 2011-07-31 22:03:41 PDT
Comment on attachment 102440 [details]
Patch

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

> Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py:84
> +    def add_specifier(self, category, specifier):
> +        self._specifier_to_category[specifier] = category

Should this be private?

> Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py:99
> +        category_slots = []
> +        for i in range(len(TestConfiguration.category_order())):
> +            category_slots.append([])

category_slots = [[]] * len(TestConfiguration.category_order())

or

category_slots = map(lambda x: [], TestConfiguration.category_order())
Comment 4 Dimitri Glazkov (Google) 2011-08-01 10:53:09 PDT
(In reply to comment #3)
> (From update of attachment 102440 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=102440&action=review
> 
> > Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py:84
> > +    def add_specifier(self, category, specifier):
> > +        self._specifier_to_category[specifier] = category
> 
> Should this be private?
> 
> > Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py:99
> > +        category_slots = []
> > +        for i in range(len(TestConfiguration.category_order())):
> > +            category_slots.append([])
> 
> category_slots = [[]] * len(TestConfiguration.category_order())

This will give you a somewhat unexpected effect of having one array listed N times:

>>> a = ([[]] * 10)
>>> a[0].append('zoot')
>>> a
[['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot']]

> 
> or
> 
> category_slots = map(lambda x: [], TestConfiguration.category_order())

Now, _that_ is cool.

(In reply to comment #3)
> (From update of attachment 102440 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=102440&action=review
> 
> > Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py:84
> > +    def add_specifier(self, category, specifier):
> > +        self._specifier_to_category[specifier] = category
> 
> Should this be private?
> 
> > Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py:99
> > +        category_slots = []
> > +        for i in range(len(TestConfiguration.category_order())):
> > +            category_slots.append([])
> 
> category_slots = [[]] * len(TestConfiguration.category_order())
> 
> or
> 
> category_slots = map(lambda x: [], TestConfiguration.category_order())
Comment 5 Dimitri Glazkov (Google) 2011-08-01 11:34:29 PDT
(In reply to comment #3)
> (From update of attachment 102440 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=102440&action=review
> 
> > Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py:84
> > +    def add_specifier(self, category, specifier):
> > +        self._specifier_to_category[specifier] = category
> 
> Should this be private?

No, I use it to populate the specifier in TestConfigurationConverter.
Comment 6 Adam Barth 2011-08-01 12:18:38 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > (From update of attachment 102440 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=102440&action=review
> > 
> > > Tools/Scripts/webkitpy/layout_tests/models/test_configuration.py:99
> > > +        category_slots = []
> > > +        for i in range(len(TestConfiguration.category_order())):
> > > +            category_slots.append([])
> > 
> > category_slots = [[]] * len(TestConfiguration.category_order())
> 
> This will give you a somewhat unexpected effect of having one array listed N times:
> 
> >>> a = ([[]] * 10)
> >>> a[0].append('zoot')
> >>> a
> [['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot'], ['zoot']]

Doh!
Comment 7 Dimitri Glazkov (Google) 2011-08-01 12:55:53 PDT
Committed r92136: <http://trac.webkit.org/changeset/92136>