[Refactoring] In webkitpy/bindings/main.py, replace subprocess.Popen() with Executive
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Dec 2011 08:05:11 +0000 (08:05 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Dec 2011 08:05:11 +0000 (08:05 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@102105 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/run-bindings-tests
Tools/Scripts/webkitpy/bindings/main.py

index 2b1aa6c..07b66c2 100644 (file)
@@ -1,3 +1,23 @@
+2011-12-06  Kentaro Hara  <haraken@chromium.org>
+
+        [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  <alexander.faeroy@nokia.com>
 
         [Qt] MiniBrowser should default to touch behavior
index 236d50e..627f176 100755 (executable)
@@ -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 @@ def main(argv):
 
     from webkitpy.bindings.main import BindingsTests
 
-    BindingsTests(reset_results, generators).main()
+    BindingsTests(reset_results, generators, executive.Executive()).main()
 
 
 if __name__ == '__main__':
index de8e6da..820ad2b 100644 (file)
@@ -30,13 +30,15 @@ import subprocess
 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 @@ class BindingsTests:
                '--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 @@ class BindingsTests:
                '--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 @@ class BindingsTests:
                    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):