[asterisk-scf-commits] asterisk-scf/release/testsuite.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Apr 12 18:27:57 CDT 2011


branch "master" has been updated
       via  8583ee347123d3df8bff87b7082a8ab4ef687876 (commit)
      from  1462303021e9fc15825401d263b16e82bf6a69d5 (commit)

Summary of changes:
 bamboo/bin/tests.py |   60 +++++++++++++++++++++++++++++---------------------
 1 files changed, 35 insertions(+), 25 deletions(-)


- Log -----------------------------------------------------------------
commit 8583ee347123d3df8bff87b7082a8ab4ef687876
Author: Darren Sessions <dsessions at digium.com>
Date:   Tue Apr 12 18:27:53 2011 -0500

    Added some tweaks for unit testing both the logger server and client.

diff --git a/bamboo/bin/tests.py b/bamboo/bin/tests.py
index 66104df..a599118 100644
--- a/bamboo/bin/tests.py
+++ b/bamboo/bin/tests.py
@@ -28,9 +28,22 @@ class test_asterisk_scf:
         self._component = component
         self._msbuild_path = "/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe"
         self.__build()
-        self.__unit_tests()
+        
+        logger_names = {'logger/server':'logger_server','logger/client':'logger_client'}
+
+        if component == "logger":
+            for comp in logger_names:
+                self.__unit_tests(comp)
+                self.__write_results_xml(logger_names[comp])
+                os.chdir("../../../..")
+                print os.getcwd()
+            os.chdir("build/logger/server")
+        else:
+            print os.getcwd()
+            self.__unit_tests(component)
+            self.__write_results_xml(component)
+
         self.__convert_boost_to_junit()
-        self.__write_results_xml(stdout=True)
 
     def __convert_boost_to_junit(self):
         os.chdir("../..")
@@ -39,22 +52,21 @@ class test_asterisk_scf:
             if len(files)>0:
                 for f in files:
                     if re.search(".*?_test-result.xml", f):
-                       print "matched %s" % f 
-                       os.system("%s /opt/bamboo/boost_to_junit.xsl %s >> converted_%s" % (which("xsltproc"), f, f))
-                       os.remove(f)
+                        os.system("%s /opt/bamboo/boost_to_junit.xsl %s >> converted_%s" % (which("xsltproc"), f, f))
+                        os.remove(f)
 
-    def __unit_tests(self):
+    def __unit_tests(self, component):
         self.total_failures = 0
         self.total_time = 0
         self.tests = 0
         self.passed = 1
         self.did_run = True
-
-        if not os.path.exists("./build/%s/test" % self._component):
-            print "Unable to find the test directory for the '%s' component!" % self._component
+        
+        if not os.path.exists("./build/%s/test" % component):
+            print "Unable to find the test directory for the '%s' component!" % component
             return
 
-        os.chdir("./build/%s/test" % self._component)
+        os.chdir("./build/%s/test" % component)
         start_time = time.time()
         self.passed = uni_make(None, None, 'test')
         self.total_time = time.time() - start_time
@@ -63,10 +75,9 @@ class test_asterisk_scf:
             self.total_failures = 1
         self.tests = 1
 
-    def __write_results_xml(self, stdout=False): 
-        print os.getcwd()          
+    def __write_results_xml(self, component): 
         try:
-            f = open("./unit_test_results.xml", "w")
+            f = open("./%s_unit_test_results.xml" % component, "w")
         except IOError:
             print "Failed to open test results output file: "
             return
@@ -78,7 +89,7 @@ class test_asterisk_scf:
         f.write('<testsuite errors="0" tests="%s" time="%.2f" failures="%d" '
                 'name="Asterisk SCF Test-Suite">\n' %
                 (self.tests, self.total_time, self.total_failures))
-        f.write('\t<testcase time="%.2f" name="%s unit tests"' % (self.total_time, self._component))
+        f.write('\t<testcase time="%.2f" name="%s unit tests"' % (self.total_time, component))
         if self.passed == 0:
             f.write('/>\n')
         else:
@@ -87,16 +98,15 @@ class test_asterisk_scf:
         f.write('</testsuite>\n')
         f.close()
 
-        if stdout is True:
-            try:
-                f = open("./unit_test_results.xml", "r")
-            except IOError:
-                print "Failed to open test results output file:"
-            except:
-                print "Unexpected error: %s" % sys.exc_info()[0]
-            else:
-                print f.read()
-                f.close()
+        try:
+            f = open("./%s_unit_test_results.xml" % component, "r")
+        except IOError:
+            print "Failed to open test results output file:"
+        except:
+            print "Unexpected error: %s" % sys.exc_info()[0]
+        else:
+            print f.read()
+            f.close()
 
     def __build(self):
         if os.path.exists("./gitall"):
@@ -210,7 +220,7 @@ def readinfile(file):
     try:
         f = open(file, "r")
     except IOError:
-        errorout("Failed to open file:")
+        errorout("Failed to open file: %s" % file)
     except:
         errorout("Unexpected error: %s" % sys.exc_info()[0])
     else:

-----------------------------------------------------------------------


-- 
asterisk-scf/release/testsuite.git



More information about the asterisk-scf-commits mailing list