[svn-commits] russell: testsuite/asterisk/trunk r121 - /asterisk/trunk/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 24 07:43:04 CDT 2010


Author: russell
Date: Wed Mar 24 07:43:00 2010
New Revision: 121

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=121
Log:
Add a 'python' dependency type for checking for specific python modules

Modified:
    asterisk/trunk/README.txt
    asterisk/trunk/runtests.py

Modified: asterisk/trunk/README.txt
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/README.txt?view=diff&rev=121&r1=120&r2=121
==============================================================================
--- asterisk/trunk/README.txt (original)
+++ asterisk/trunk/README.txt Wed Mar 24 07:43:00 2010
@@ -174,8 +174,14 @@
     maxversion : '1.8' # OPTIONAL
     dependencies : |   # OPTIONAL
         # List dependencies that must be met for this test to run
+        #
+        # Checking for an 'app' dependency behaves like the 'which' command
         - app : 'bash'
         - app : 'sipp'
+        # A 'python' dependency is a python module.  An attempt will be made to
+        # import a module by this name to determine whether the dependency is
+        # met.
+        - python : 'yaml'
 
 
 

Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=121&r1=120&r2=121
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Wed Mar 24 07:43:00 2010
@@ -33,9 +33,21 @@
 
 
 class Dependency:
-    def __init__(self, name):
-        self.name = name
-        self.found = self.__which(name) is not None
+    def __init__(self, dep):
+        self.name = ""
+        self.met = False
+        if dep.has_key("app"):
+            self.name = dep["app"]
+            self.met = self.__which(self.name) is not None
+        elif dep.has_key("python"):
+            self.name = dep["python"]
+            try:
+                __import__(self.name)
+                self.met = True
+            except ImportError:
+                pass
+        else:
+            print "Unknown dependency type specified."
 
     def __which(self, program):
         '''
@@ -107,7 +119,7 @@
 
     def __check_deps(self, ast_version):
         self.deps = [
-            Dependency(d["app"])
+            Dependency(d)
                 for d in self.config["properties"]["dependencies"]
         ]
 
@@ -124,7 +136,7 @@
             return
 
         for d in self.deps:
-            if d.found is False:
+            if d.met is False:
                 self.can_run = False
                 break
 
@@ -149,19 +161,21 @@
             TestConfig(t["test"], ast_version) for t in self.config["tests"]
         ]
 
-    def __str__(self):
-        s = "Configured tests:\n"
+    def list_tests(self):
+        print "Configured tests:"
         i = 1
         for t in self.tests:
-            s += "%.3d) %s\n" % (i, t.test_name)
-            s += "      --> Summary: %s\n" % t.summary
-            s += "      --> Minimum Version: %s (%s)\n" % \
-                            (str(t.minversion), str(t.minversion_check))
+            print "%.3d) %s" % (i, t.test_name)
+            print "      --> Summary: %s" % t.summary
+            print "      --> Minimum Version: %s (%s)" % \
+                         (str(t.minversion), str(t.minversion_check))
             if t.maxversion is not None:
-                s += "      --> Maximum Version: %s (%s) \n" % \
-                            (str(t.maxversion), str(t.maxversion_check))
+                print "      --> Maximum Version: %s (%s)" % \
+                             (str(t.maxversion), str(t.maxversion_check))
+            for d in t.deps:
+                print "      --> Dependency: %s -- Met: %s" % (d.name,
+                             str(d.met))
             i += 1
-        return s
 
     def run(self, ast_version):
         test_suite_dir = os.getcwd()
@@ -170,7 +184,7 @@
             if t.can_run is False:
                 print "--> Can not run test '%s'" % t.test_name
                 for d in t.deps:
-                    print "--- --> Dependency: %s - %s" % (d.name, str(d.found))
+                    print "--- --> Dependency: %s - %s" % (d.name, str(d.met))
                 print
                 continue
 
@@ -275,7 +289,7 @@
 
     if options.list_tests is True:
         print "Asterisk Version: %s\n" % str(ast_version)
-        print test_suite
+        test_suite.list_tests()
         return 0
 
     if os.geteuid() != 0:




More information about the svn-commits mailing list