Title: [213097] trunk/Tools
Revision
213097
Author
[email protected]
Date
2017-02-27 15:07:25 -0800 (Mon, 27 Feb 2017)

Log Message

Add machine-readable results for bindings tests
https://bugs.webkit.org/show_bug.cgi?id=168626

Patch by Srinivasan Vijayaraghavan <[email protected]> on 2017-02-27
Reviewed by Alexey Proskuryakov.

* Scripts/run-bindings-tests:
(main): Add optional --json-output command-line parameter.
* Scripts/webkitpy/bindings/main.py:
(BindingsTests.__init__): Add variables to store machine-readable results.
(BindingsTests.detect_changes): Store results in machine-readable form if applicable.
(BindingsTests.main): Write data to JSON file if applicable.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (213096 => 213097)


--- trunk/Tools/ChangeLog	2017-02-27 22:54:26 UTC (rev 213096)
+++ trunk/Tools/ChangeLog	2017-02-27 23:07:25 UTC (rev 213097)
@@ -1,3 +1,17 @@
+2017-02-27  Srinivasan Vijayaraghavan  <[email protected]>
+
+        Add machine-readable results for bindings tests
+        https://bugs.webkit.org/show_bug.cgi?id=168626
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Scripts/run-bindings-tests:
+        (main): Add optional --json-output command-line parameter.
+        * Scripts/webkitpy/bindings/main.py:
+        (BindingsTests.__init__): Add variables to store machine-readable results.
+        (BindingsTests.detect_changes): Store results in machine-readable form if applicable.
+        (BindingsTests.main): Write data to JSON file if applicable.
+
 2017-02-27  Wenson Hsieh  <[email protected]>
 
         Unreviewed, roll out r213065.

Modified: trunk/Tools/Scripts/run-bindings-tests (213096 => 213097)


--- trunk/Tools/Scripts/run-bindings-tests	2017-02-27 22:54:26 UTC (rev 213096)
+++ trunk/Tools/Scripts/run-bindings-tests	2017-02-27 23:07:25 UTC (rev 213097)
@@ -29,6 +29,7 @@
 # patch. This makes it easier to track and review changes in generated code.
 
 import optparse
+import os
 import sys
 from webkitpy.common.system import executive
 
@@ -43,12 +44,17 @@
         help='Disable verobse output')
     option_parser.add_option('--reset-results', action='', default=False,
         help='Overwrites the reference files with the generated results')
+    option_parser.add_option('--json-output', action='', type='string', dest='json_file_name',
+        help='Create a file at specified path, listing test results in JSON format.')
     options, args = option_parser.parse_args()    
 
     from webkitpy.bindings.main import BindingsTests
 
-    return BindingsTests(options.reset_results, [ 'JS' ], executive.Executive(), not options.no_verbose, args).main()
+    if options.json_file_name:
+        options.json_file_name = os.path.abspath(options.json_file_name)
 
+    return BindingsTests(options.reset_results, [ 'JS' ], executive.Executive(), not options.no_verbose, args, options.json_file_name).main()
 
+
 if __name__ == '__main__':
     sys.exit(main(sys.argv))

Modified: trunk/Tools/Scripts/webkitpy/bindings/main.py (213096 => 213097)


--- trunk/Tools/Scripts/webkitpy/bindings/main.py	2017-02-27 22:54:26 UTC (rev 213096)
+++ trunk/Tools/Scripts/webkitpy/bindings/main.py	2017-02-27 23:07:25 UTC (rev 213097)
@@ -23,6 +23,7 @@
 #
 
 import fnmatch
+import json
 import os
 import os.path
 import shutil
@@ -35,13 +36,18 @@
 
 class BindingsTests:
 
-    def __init__(self, reset_results, generators, executive, verbose, patterns):
+    def __init__(self, reset_results, generators, executive, verbose, patterns, json_file_name):
         self.reset_results = reset_results
         self.generators = generators
         self.executive = executive
         self.verbose = verbose
         self.patterns = patterns
+        self.json_file_name = json_file_name
 
+        if self.json_file_name:
+            self.failures = []
+            self.errors = []
+
     def generate_from_idl(self, generator, idl_file, output_directory, supplemental_dependency_file):
         cmd = ['perl', '-w',
                '-IWebCore/bindings/scripts',
@@ -109,11 +115,15 @@
             except ScriptError, e:
                 output = e.output
                 exit_code = e.exit_code
+                if self.json_file_name:
+                    self.errors.append("(%s) %s" % (generator, output_file))
 
             if exit_code or output:
                 print 'FAIL: (%s) %s' % (generator, output_file)
                 print output
                 changes_found = True
+                if self.json_file_name:
+                    self.failures.append("(%s) %s" % (generator, output_file))
             elif self.verbose:
                 print 'PASS: (%s) %s' % (generator, output_file)
         return changes_found
@@ -189,6 +199,16 @@
         os.remove(window_constructors_file)
         os.remove(workerglobalscope_constructors_file)
         os.remove(dedicatedworkerglobalscope_constructors_file)
+
+        if self.json_file_name:
+            json_data = {
+                'failures': self.failures,
+                'errors': self.errors,
+            }
+
+            with open(self.json_file_name, 'w') as json_file:
+                json.dump(json_data, json_file)
+
         print ''
         if all_tests_passed:
             print 'All tests PASS!'
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to