[svn-commits] russell: testsuite/asterisk/trunk r166 - in /asterisk/trunk: ./ tests/ami-log...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 31 11:16:41 CDT 2010


Author: russell
Date: Wed Mar 31 11:16:39 2010
New Revision: 166

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=166
Log:
Use tee to save off test output so that it can be included in XML results.

Modified:
    asterisk/trunk/runtests.py
    asterisk/trunk/tests/ami-login/   (props changed)
    asterisk/trunk/tests/blind-transfer-accountcode/   (props changed)
    asterisk/trunk/tests/example/   (props changed)
    asterisk/trunk/tests/iax-call-basic/   (props changed)
    asterisk/trunk/tests/rfc2833_dtmf_detect/   (props changed)

Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=166&r1=165&r2=166
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Wed Mar 31 11:16:39 2010
@@ -72,7 +72,6 @@
 class TestConfig:
     def __init__(self, test_name, ast_version):
         self.can_run = True
-        self.stdout = ""
         self.time = 0.0
         self.test_name = test_name
         self.ast_version = ast_version
@@ -83,15 +82,17 @@
     def run(self):
         self.passed = False
         start_time = time.time()
-        cmd = ["tests/%s/run-test" % self.test_name]
-        cmd.extend(["-v", str(self.ast_version)])
+        cmd = [
+            "tests/%s/run-test" % self.test_name,
+            "-v", str(self.ast_version)
+        ]
         if os.path.exists(cmd[0]):
-            # XXX TODO Figure out a way to have the output of the test process
-            # sent to stdout while the test runs, but also be able to save off
-            # the output for inclusion in the test results later on.
             print "Running %s ..." % cmd
-            p = subprocess.Popen(cmd, shell=True)
+            p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+            p2 = subprocess.Popen(["tee", "tests/%s/test-output.txt" %
+                                   self.test_name], stdin=p.stdout)
             p.wait()
+            p2.wait()
             self.passed = p.returncode == 0
         self.time = time.time() - start_time
 
@@ -243,7 +244,14 @@
             if t.passed is True:
                 f.write('/>\n')
                 continue
-            f.write('>\n\t\t<failure><![CDATA[\n%s\n\t\t]]></failure>\n\t</testcase>\n' % t.stdout)
+            f.write(">\n\t\t<failure><![CDATA[\n")
+            try:
+                test_output = open("tests/%s/test-output.txt" % t.test_name, "r")
+                f.write("%s" % test_output.read())
+                test_output.close()
+            except IOError:
+                print "Failed to open test output for %s" % t.test_name
+            f.write("\n\t\t]]></failure>\n\t</testcase>\n")
         f.write('</testsuite>\n')
         f.close()
 

Propchange: asterisk/trunk/tests/ami-login/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Mar 31 11:16:39 2010
@@ -1,1 +1,2 @@
 tmp
+test-output.txt

Propchange: asterisk/trunk/tests/blind-transfer-accountcode/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar 31 11:16:39 2010
@@ -1,0 +1,2 @@
+tmp
+test-output.txt

Propchange: asterisk/trunk/tests/example/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar 31 11:16:39 2010
@@ -1,0 +1,1 @@
+test-output.txt

Propchange: asterisk/trunk/tests/iax-call-basic/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Mar 31 11:16:39 2010
@@ -1,1 +1,2 @@
 tmp
+test-output.txt

Propchange: asterisk/trunk/tests/rfc2833_dtmf_detect/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar 31 11:16:39 2010
@@ -1,0 +1,2 @@
+tmp
+test-output.txt




More information about the svn-commits mailing list