Title: [102105] trunk/Tools
Revision
102105
Author
[email protected]
Date
2011-12-06 00:05:11 -0800 (Tue, 06 Dec 2011)

Log Message

[Refactoring] In webkitpy/bindings/main.py, replace subprocess.Popen() with Executive
https://bugs.webkit.org/show_bug.cgi?id=73637

Reviewed by Adam Barth.

This patch replaces subprocess.Popen() with Executive, similar to other
Python scripts in webkitpy/. I manually confirmed that run-bindings-tests
works well for cases where no exception is raised, no exception is raised
but diff is found, and ScriptError is raised.

* Scripts/run-bindings-tests:
(main):
* Scripts/webkitpy/bindings/main.py: Replaces subprocess.Popen() with Executive.
(BindingsTests.__init__):
(BindingsTests.generate_from_idl):
(BindingsTests.generate_supplemental_dependency):
(BindingsTests.detect_changes):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (102104 => 102105)


--- trunk/Tools/ChangeLog	2011-12-06 08:00:53 UTC (rev 102104)
+++ trunk/Tools/ChangeLog	2011-12-06 08:05:11 UTC (rev 102105)
@@ -1,3 +1,23 @@
+2011-12-06  Kentaro Hara  <[email protected]>
+
+        [Refactoring] In webkitpy/bindings/main.py, replace subprocess.Popen() with Executive
+        https://bugs.webkit.org/show_bug.cgi?id=73637
+
+        Reviewed by Adam Barth.
+
+        This patch replaces subprocess.Popen() with Executive, similar to other
+        Python scripts in webkitpy/. I manually confirmed that run-bindings-tests
+        works well for cases where no exception is raised, no exception is raised
+        but diff is found, and ScriptError is raised.
+
+        * Scripts/run-bindings-tests:
+        (main):
+        * Scripts/webkitpy/bindings/main.py: Replaces subprocess.Popen() with Executive.
+        (BindingsTests.__init__):
+        (BindingsTests.generate_from_idl):
+        (BindingsTests.generate_supplemental_dependency):
+        (BindingsTests.detect_changes):
+
 2011-12-05  Alexander Færøy  <[email protected]>
 
         [Qt] MiniBrowser should default to touch behavior

Modified: trunk/Tools/Scripts/run-bindings-tests (102104 => 102105)


--- trunk/Tools/Scripts/run-bindings-tests	2011-12-06 08:00:53 UTC (rev 102104)
+++ trunk/Tools/Scripts/run-bindings-tests	2011-12-06 08:05:11 UTC (rev 102105)
@@ -29,6 +29,7 @@
 # patch. This makes it easier to track and review changes in generated code.
 
 import sys
+from webkitpy.common.system import executive
 
 def main(argv):
     """Runs WebCore bindings code generators on test IDL files and compares
@@ -50,7 +51,7 @@
 
     from webkitpy.bindings.main import BindingsTests
 
-    BindingsTests(reset_results, generators).main()
+    BindingsTests(reset_results, generators, executive.Executive()).main()
 
 
 if __name__ == '__main__':

Modified: trunk/Tools/Scripts/webkitpy/bindings/main.py (102104 => 102105)


--- trunk/Tools/Scripts/webkitpy/bindings/main.py	2011-12-06 08:00:53 UTC (rev 102104)
+++ trunk/Tools/Scripts/webkitpy/bindings/main.py	2011-12-06 08:05:11 UTC (rev 102105)
@@ -30,13 +30,15 @@
 import sys
 import tempfile
 from webkitpy.common.checkout.scm.detection import detect_scm_system
+from webkitpy.common.system.executive import ScriptError
 
 
 class BindingsTests:
 
-    def __init__(self, reset_results, generators):
+    def __init__(self, reset_results, generators, executive):
         self.reset_results = reset_results
         self.generators = generators
+        self.executive = executive
 
     def generate_from_idl(self, generator, idl_file, output_directory, supplemental_dependency_file):
         cmd = ['perl', '-w',
@@ -50,11 +52,14 @@
                '--supplementalDependencyFile', supplemental_dependency_file,
                idl_file]
 
-        process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-        exit_code = process.wait()
-        output = process.communicate()[0]
-        if output:
-            print output
+        exit_code = 0
+        try:
+            output = self.executive.run_command(cmd)
+            if output:
+                print output
+        except ScriptError, e:
+            print e.message_with_output()
+            exit_code = e.exit_code
         return exit_code
 
     def generate_supplemental_dependency(self, input_directory, supplemental_dependency_file):
@@ -72,12 +77,15 @@
                '--idlFilesList', idl_files_list[1],
                '--defines', '',
                '--supplementalDependencyFile', supplemental_dependency_file]
-        process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-        exit_code = process.wait()
-        output = process.communicate()[0]
-        if output:
-            print output
 
+        exit_code = 0
+        try:
+            output = self.executive.run_command(cmd)
+            if output:
+                print output
+        except ScriptError, e:
+            print e.message_with_output()
+            exit_code = e.exit_code
         os.remove(idl_files_list[1])
         return exit_code
 
@@ -90,16 +98,19 @@
                    os.path.join(reference_directory, output_file),
                    os.path.join(work_directory, output_file)]
 
-            process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-            process.wait()
-            output = process.communicate()[0]
-            if output:
+            exit_code = 0
+            try:
+                output = self.executive.run_command(cmd)
+            except ScriptError, e:
+                output = e.message_with_output()
+                exit_code = e.exit_code
+
+            if exit_code or output:
                 print 'FAIL: (%s) %s' % (generator, output_file)
                 print output
                 changes_found = True
             else:
                 print 'PASS: (%s) %s' % (generator, output_file)
-
         return changes_found
 
     def run_tests(self, generator, input_directory, reference_directory, supplemental_dependency_file):
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to