Fix case of 'diff xxx | head' appearing to succeed even if the diff command returned non-zero exit statux.
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Sun, 06 Apr 2008 19:22:39 +0100
changeset 2882 542f4d57464b
parent 2881 81d1080cd0ae
child 2883 0b4cb407bb9e
Fix case of 'diff xxx | head' appearing to succeed even if the diff command returned non-zero exit statux.
wscript
--- a/wscript	Fri Apr 04 19:33:39 2008 +0100
+++ b/wscript	Sun Apr 06 19:22:39 2008 +0100
@@ -677,12 +677,16 @@
             run_program(testName, command_template=get_command_template())
 
             if verbose:
-                diffCmd = "diff traces " + refTestDirName + " | head"
+                #diffCmd = "diff traces " + refTestDirName + " | head"
+                diffCmd = subprocess.Popen(args=["diff", "traces", refTestDirName], stdout=subprocess.PIPE)
+                headCmd = subprocess.Popen(args=["diff", "traces", refTestDirName], stdin=diffCmd.stdout)
+                rc1 = diffCmd.wait()
+                rc2 = headCmd.wait()
+                rc = rc1 or rc2
             else:
                 diffCmd = "diff traces " + refTestDirName + \
                     " > /dev/null 2>&1"
-
-            rc = os.system(diffCmd)
+                rc = os.system(diffCmd)
             if rc:
                 print "----------"
                 print "Traces differ in test: test-" + testName