Title: [101150] trunk/Tools
Revision
101150
Author
[email protected]
Date
2011-11-24 22:44:19 -0800 (Thu, 24 Nov 2011)

Log Message

Replace subprocess.call() with subprocess.Popen()
https://bugs.webkit.org/show_bug.cgi?id=73105

Reviewed by Adam Barth.

Currently, the stdout and stderr of the child processes of run-bindings-tests
are mixed (or even gone away) with the stdout and stderr of run-bindings-tests itself.
This is the problem of subprocess.call(), which does not synchronize the stdout and stderr
between a parent process and a child process. This patch replaces subprocess.call() with
subprocess.Popen() and synchronizes the stdout and stderr between them.
This patch also makes output messages of run-bindings-tests more readable.

With this patch, the output messages of run-bindings-tests look like as follows:

    PASS: (CPP) WebDOMTestObj.h
    PASS: (CPP) WebDOMTestObj.cpp
    FAIL: (CPP) WebDOMTestInterface.h
    --- Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h      2011-11-25 13:34:09.313516268 +0900
    +++ /tmp/tmpDAV87G/WebDOMTestInterface.h        2011-11-25 13:44:42.712946812 +0900
    @@ -23,7 +23,7 @@
     #ifndef WebDOMTestInterface_h
     #define WebDOMTestInterface_h

    -#if ENABLE(Condition1) || ENABLE(Condition2)
    +#if ENABLE(Condition1) || ENABLE(Condition3)

     #include <WebDOMObject.h>
     #include <WebDOMString.h>
     @@ -53,5 +53,5 @@
     WebDOMTestInterface toWebKit(WebCore::TestInterface*);

     #endif
    -#endif // ENABLE(Condition1) || ENABLE(Condition2)
    +#endif // ENABLE(Condition1) || ENABLE(Condition3)
    PASS: (CPP) WebDOMFloat64Array.cpp
    PASS: (CPP) WebDOMFloat64Array.h

    Some tests FAIL! (To update the reference files, execute "run-bindings-tests --reset-results")

* Scripts/run-bindings-tests:
(generate_from_idl):
(detect_changes):
(run_tests):
(main):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (101149 => 101150)


--- trunk/Tools/ChangeLog	2011-11-25 06:36:26 UTC (rev 101149)
+++ trunk/Tools/ChangeLog	2011-11-25 06:44:19 UTC (rev 101150)
@@ -1,5 +1,52 @@
 2011-11-24  Kentaro Hara  <[email protected]>
 
+        Replace subprocess.call() with subprocess.Popen()
+        https://bugs.webkit.org/show_bug.cgi?id=73105
+
+        Reviewed by Adam Barth.
+
+        Currently, the stdout and stderr of the child processes of run-bindings-tests
+        are mixed (or even gone away) with the stdout and stderr of run-bindings-tests itself.
+        This is the problem of subprocess.call(), which does not synchronize the stdout and stderr
+        between a parent process and a child process. This patch replaces subprocess.call() with
+        subprocess.Popen() and synchronizes the stdout and stderr between them.
+        This patch also makes output messages of run-bindings-tests more readable.
+
+        With this patch, the output messages of run-bindings-tests look like as follows:
+
+            PASS: (CPP) WebDOMTestObj.h
+            PASS: (CPP) WebDOMTestObj.cpp
+            FAIL: (CPP) WebDOMTestInterface.h
+            --- Source/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h      2011-11-25 13:34:09.313516268 +0900
+            +++ /tmp/tmpDAV87G/WebDOMTestInterface.h        2011-11-25 13:44:42.712946812 +0900
+            @@ -23,7 +23,7 @@
+             #ifndef WebDOMTestInterface_h
+             #define WebDOMTestInterface_h
+
+            -#if ENABLE(Condition1) || ENABLE(Condition2)
+            +#if ENABLE(Condition1) || ENABLE(Condition3)
+
+             #include <WebDOMObject.h>
+             #include <WebDOMString.h>
+             @@ -53,5 +53,5 @@
+             WebDOMTestInterface toWebKit(WebCore::TestInterface*);
+
+             #endif
+            -#endif // ENABLE(Condition1) || ENABLE(Condition2)
+            +#endif // ENABLE(Condition1) || ENABLE(Condition3)
+            PASS: (CPP) WebDOMFloat64Array.cpp
+            PASS: (CPP) WebDOMFloat64Array.h
+
+            Some tests FAIL! (To update the reference files, execute "run-bindings-tests --reset-results")
+
+        * Scripts/run-bindings-tests:
+        (generate_from_idl):
+        (detect_changes):
+        (run_tests):
+        (main):
+
+2011-11-24  Kentaro Hara  <[email protected]>
+
         Fix the current working directory of run-bindings-tests
         https://bugs.webkit.org/show_bug.cgi?id=73106
 

Modified: trunk/Tools/Scripts/run-bindings-tests (101149 => 101150)


--- trunk/Tools/Scripts/run-bindings-tests	2011-11-25 06:36:26 UTC (rev 101149)
+++ trunk/Tools/Scripts/run-bindings-tests	2011-11-25 06:44:19 UTC (rev 101150)
@@ -48,22 +48,32 @@
            '--generator', generator,
            '--outputDir', output_directory,
            idl_file]
-    return subprocess.call(cmd) == 0
 
+    process = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
+    exit_code = process.wait()
+    output = process.communicate()[0]
+    if output:
+        print output
+    return exit_code
 
-def detect_changes(work_directory, reference_directory):
+
+def detect_changes(generator, work_directory, reference_directory):
     changes_found = False
     for output_file in os.listdir(work_directory):
-        print 'Detecting changes in %s...' % output_file
         cmd = ['diff',
                '-u',
                os.path.join(reference_directory, output_file),
                os.path.join(work_directory, output_file)]
-        if subprocess.call(cmd) != 0:
-            print 'Detected changes in %s (see above)' % output_file
+
+        process = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
+        process.wait()
+        output = process.communicate()[0]
+        if output:
+            print 'FAIL: (%s) %s' % (generator, output_file)
+            print output
             changes_found = True
         else:
-            print 'No changes found.'
+            print 'PASS: (%s) %s' % (generator, output_file)
 
     return changes_found
 
@@ -76,30 +86,30 @@
         (name, extension) = os.path.splitext(input_file)
         if extension != '.idl':
             continue
-        print 'Testing the %s generator on %s' % (generator, input_file)
-        # Generate output into the work directory (either the given one or a 
+        # Generate output into the work directory (either the given one or a
         # temp one if not reset_results is performed)
         if not reset_results:
             work_directory = tempfile.mkdtemp()
-        if not generate_from_idl(generator, os.path.join(input_directory,
-                                                         input_file),
-                                 work_directory):
+
+        if generate_from_idl(generator,
+                             os.path.join(input_directory, input_file),
+                             work_directory):
             passed = False
+
         if reset_results:
-            print "Overwrote reference files"
+            print "Reset results: (%s) %s" % (generator, input_file)
             continue
+
         # Detect changes
-        if detect_changes(work_directory, reference_directory):
+        if detect_changes(generator, work_directory, reference_directory):
             passed = False
         shutil.rmtree(work_directory)
 
-    if not passed:
-        print '%s generator failed.' % generator
     return passed
 
 
 def main(argv):
-    """Runs WebCore bindings code generators on test IDL files and compares 
+    """Runs WebCore bindings code generators on test IDL files and compares
     the results with reference files.
 
     Options:
@@ -127,11 +137,12 @@
         if not run_tests(generator, input_directory, reference_directory, reset_results):
             all_tests_passed = False
 
+    print ''
     if all_tests_passed:
-        print 'All tests passed!'
+        print 'All tests PASS!'
         return 0
     else:
-        print '(To update the reference files, execute "run-bindings-tests --reset-results")'
+        print 'Some tests FAIL! (To update the reference files, execute "run-bindings-tests --reset-results")'
         return -1
 
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to