Title: [210676] trunk/Tools
Revision
210676
Author
[email protected]
Date
2017-01-12 12:39:40 -0800 (Thu, 12 Jan 2017)

Log Message

Add the ability to filter the set of bindings tests you want to run
https://bugs.webkit.org/show_bug.cgi?id=166977

Reviewed by Tim Horton.

Allows doing things like:
    run-bindings-tests TestObj* TestCEReactions*
        
to run only those tests that match the patterns.

* Scripts/run-bindings-tests:
(main):
Switch to using optparse and pass the remaining args as the filters.

* Scripts/webkitpy/bindings/main.py:
(BindingsTests.__init__):
Store the pattens.

(BindingsTests.test_matches_patterns):
Add helper predicate to determine if a test should be run. When no
patterns are present, all tests should run.

(BindingsTests.run_tests):
Filter tests using the passed in patterns.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (210675 => 210676)


--- trunk/Tools/ChangeLog	2017-01-12 20:38:31 UTC (rev 210675)
+++ trunk/Tools/ChangeLog	2017-01-12 20:39:40 UTC (rev 210676)
@@ -1,3 +1,30 @@
+2017-01-12  Sam Weinig  <[email protected]>
+
+        Add the ability to filter the set of bindings tests you want to run
+        https://bugs.webkit.org/show_bug.cgi?id=166977
+
+        Reviewed by Tim Horton.
+
+        Allows doing things like:
+            run-bindings-tests TestObj* TestCEReactions*
+        
+        to run only those tests that match the patterns.
+
+        * Scripts/run-bindings-tests:
+        (main):
+        Switch to using optparse and pass the remaining args as the filters.
+
+        * Scripts/webkitpy/bindings/main.py:
+        (BindingsTests.__init__):
+        Store the pattens.
+
+        (BindingsTests.test_matches_patterns):
+        Add helper predicate to determine if a test should be run. When no
+        patterns are present, all tests should run.
+
+        (BindingsTests.run_tests):
+        Filter tests using the passed in patterns.
+
 2017-01-12  Per Arne Vollan  <[email protected]>
 
         Followup fix after r210503.

Modified: trunk/Tools/Scripts/run-bindings-tests (210675 => 210676)


--- trunk/Tools/Scripts/run-bindings-tests	2017-01-12 20:38:31 UTC (rev 210675)
+++ trunk/Tools/Scripts/run-bindings-tests	2017-01-12 20:39:40 UTC (rev 210676)
@@ -28,6 +28,7 @@
 # CodeGeneratorXXXX.pm, and submit the changes in XXXXTestObj.h/cpp in the same
 # patch. This makes it easier to track and review changes in generated code.
 
+import optparse
 import sys
 from webkitpy.common.system import executive
 
@@ -34,19 +35,19 @@
 def main(argv):
     """Runs WebCore bindings code generators on test IDL files and compares
     the results with reference files.
-
-    Options:
-       --reset-results: Overwrites the reference files with the generated results.
-
     """
-    reset_results = "--reset-results" in argv
-    verbose = not "--no-verbose" in argv
 
-    generators = [ 'JS' ]
+    option_parser = optparse.OptionParser(usage='run-bindings-test [options] [patterns-to-test...]',
+        description="Runs WebCore bindings code generators on test IDL files and compares the results with reference files")
+    option_parser.add_option('--no-verbose', action='', default=False,
+        help='Disable verobse output')
+    option_parser.add_option('--reset-results', action='', default=False,
+        help='Overwrites the reference files with the generated results')
+    options, args = option_parser.parse_args()    
 
     from webkitpy.bindings.main import BindingsTests
 
-    return BindingsTests(reset_results, generators, executive.Executive(), verbose).main()
+    return BindingsTests(options.reset_results, [ 'JS' ], executive.Executive(), not options.no_verbose, args).main()
 
 
 if __name__ == '__main__':

Modified: trunk/Tools/Scripts/webkitpy/bindings/main.py (210675 => 210676)


--- trunk/Tools/Scripts/webkitpy/bindings/main.py	2017-01-12 20:38:31 UTC (rev 210675)
+++ trunk/Tools/Scripts/webkitpy/bindings/main.py	2017-01-12 20:39:40 UTC (rev 210676)
@@ -22,6 +22,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
+import fnmatch
 import os
 import os.path
 import shutil
@@ -34,11 +35,12 @@
 
 class BindingsTests:
 
-    def __init__(self, reset_results, generators, executive, verbose):
+    def __init__(self, reset_results, generators, executive, verbose, patterns):
         self.reset_results = reset_results
         self.generators = generators
         self.executive = executive
         self.verbose = verbose
+        self.patterns = patterns
 
     def generate_from_idl(self, generator, idl_file, output_directory, supplemental_dependency_file):
         cmd = ['perl', '-w',
@@ -116,6 +118,14 @@
                 print 'PASS: (%s) %s' % (generator, output_file)
         return changes_found
 
+    def test_matches_patterns(self, test):
+        if not self.patterns:
+            return True
+        for pattern in self.patterns:
+            if fnmatch.fnmatch(test, pattern):
+                return True
+        return False
+
     def run_tests(self, generator, input_directory, reference_directory, supplemental_dependency_file):
         work_directory = reference_directory
 
@@ -124,6 +134,10 @@
             (name, extension) = os.path.splitext(input_file)
             if extension != '.idl':
                 continue
+
+            if not self.test_matches_patterns(input_file):
+                continue
+
             # Generate output into the work directory (either the given one or a
             # temp one if not reset_results is performed)
             if not self.reset_results:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to