[asterisk-commits] mnicholson: branch mnicholson/fancy-versions r2414 - in /asterisk/team/mnicho...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 22 14:54:36 CDT 2011


Author: mnicholson
Date: Thu Sep 22 14:54:32 2011
New Revision: 2414

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2414
Log:
Pass version checks if any check matches. Also provide a better way to diagnose version checking failures.

Modified:
    asterisk/team/mnicholson/fancy-versions/README.txt
    asterisk/team/mnicholson/fancy-versions/lib/python/asterisk/TestConfig.py
    asterisk/team/mnicholson/fancy-versions/runtests.py

Modified: asterisk/team/mnicholson/fancy-versions/README.txt
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mnicholson/fancy-versions/README.txt?view=diff&rev=2414&r1=2413&r2=2414
==============================================================================
--- asterisk/team/mnicholson/fancy-versions/README.txt (original)
+++ asterisk/team/mnicholson/fancy-versions/README.txt Thu Sep 22 14:54:32 2011
@@ -321,7 +321,8 @@
     versions:
 	# A set of versions that a test should run against can be specified
 	# here. Versions can be specified as a particular release, a particular
-	# asterisk branch, or a specific svn branch and or set of revisions.
+	# asterisk branch, or a specific svn branch and or set of revisions. If
+	# any of the conditions are met, the test will run.
 
         - release: 1.8.7.0-rc1
         - release: 10.0.0

Modified: asterisk/team/mnicholson/fancy-versions/lib/python/asterisk/TestConfig.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mnicholson/fancy-versions/lib/python/asterisk/TestConfig.py?view=diff&rev=2414&r1=2413&r2=2414
==============================================================================
--- asterisk/team/mnicholson/fancy-versions/lib/python/asterisk/TestConfig.py (original)
+++ asterisk/team/mnicholson/fancy-versions/lib/python/asterisk/TestConfig.py Thu Sep 22 14:54:32 2011
@@ -232,6 +232,7 @@
         test_name -- The path to the directory containing the test-config.yaml file to load
         """
         self.can_run = True
+        self.why_not = []
         self.test_name = test_name
         self.skip = None
         self.config = None
@@ -270,22 +271,22 @@
                 self.minversion = AsteriskVersion(properties["minversion"])
             except:
                 self.can_run = False
-                print "ERROR: '%s' is not a valid minversion" % \
-                        properties["minversion"]
+                self.why_not.append("ERROR: '%s' is not a valid minversion" % \
+                        properties["minversion"])
         if "maxversion" in properties:
             try:
                 self.maxversion = AsteriskVersion(properties["maxversion"])
             except:
                 self.can_run = False
-                print "ERROR: '%s' is not a valid maxversion" % \
-                        properties["maxversion"]
+                self.why_not.append("ERROR: '%s' is not a valid maxversion" % \
+                        properties["maxversion"])
         if "expectedResult" in properties:
             try:
                 self.expectPass = not (properties["expectedResult"].upper().strip() == "FAIL")
             except:
                 self.can_run = False
-                print "ERROR: '%s' is not a valid value for expectedResult" %\
-                        properties["expectedResult"]
+                self.why_not.append("ERROR: '%s' is not a valid value for expectedResult" %\
+                        properties["expectedResult"])
 
     def __parse_config(self, dummy_config = None):
 
@@ -344,10 +345,16 @@
         """
 
         def branch_is_compatible(ast_version, branch):
-            return ast_version.has_major_version(str(branch))
+            res = ast_version.has_major_version(str(branch))
+            if not res:
+                self.why_not.append("asterisk branch mismatch: %s is not major version %s" % (ast_version, branch))
+            return res
 
         def release_is_compatible(ast_version, release):
-            return ast_version == AsteriskVersion(release)
+            res = ast_version == AsteriskVersion(release)
+            if not res:
+                self.why_not.append("asterisk release version mismatch: %s != %s" % (ast_version, release))
+            return res
 
         def svn_is_compatible(ast_version, svn):
             def rev(r):
@@ -367,21 +374,26 @@
                 branch = svn["branch"]
                 if isinstance(branch, int) or isinstance(branch, float) or '.' in branch:
                     if ast_version.branch != "branch-" + str(branch):
+                        self.why_not.append("svn branch mismatch: %s != %s" % (ast_version.branch, "branch-" + str(branch)))
                         return False
                 else:
                     if ast_version.branch != branch:
+                        self.why_not.append("svn branch mismatch: %s != %s" % (ast_version.branch, branch))
                         return False
 
             if "to" in svn:
                 if ast_version > rev(svn["to"]):
+                    self.why_not.append("svn version to new: %s > %s" % (ast_version, svn["to"]))
                     return False
 
             if "from" in svn:
                 if ast_version < rev(svn["from"]):
+                    self.why_not.append("svn version to old: %s < %s" % (ast_version, svn["from"]))
                     return False
 
             if "revision" in svn:
                 if ast_version != rev(svn["revision"]):
+                    self.why_not.append("svn revision mismatch: %s != %s" % (ast_version, svn["revision"]))
                     return False
 
             return True
@@ -398,13 +410,18 @@
             key, value = item.items()[0]
 
             if key not in compatibility_checks:
-                print "ERROR: unknown version spec '%s'" % key
-                continue
-
-            if not compatibility_checks[key](ast_version, value):
+                self.why_not.append("ERROR: unknown version spec '%s'" % key)
                 return False
 
-        return True
+            if compatibility_checks[key](ast_version, value):
+                return True
+
+        # if there are no checks specified, assume compatibility
+        if not self.config["properties"].get("versions"):
+            return True
+
+        self.why_not.append("no version checks passed")
+        return False
 
 
     def check_deps(self, ast_version):
@@ -418,6 +435,7 @@
         """
 
         if not self.config:
+            self.why_not.append("no configuration found")
             return False
 
         self.deps = [
@@ -429,21 +447,25 @@
         if ast_version < self.minversion:
             self.can_run = False
             self.minversion_check = False
+            self.why_not.append("minimum version check failed %s < %s" % (ast_version, self.minversion))
             return self.can_run
 
         self.maxversion_check = True
         if self.maxversion is not None and ast_version > self.maxversion:
             self.can_run = False
             self.maxversion_check = False
+            self.why_not.append("maximum version check failed %s > %s" % (ast_version, self.maxversion))
             return self.can_run
 
         if not self.__version_is_compatible(ast_version):
             self.can_run = False
+            self.why_not.append("version compatibility check failed")
             return self.can_run
 
         for d in self.deps:
             if d.met is False:
                 self.can_run = False
+                self.why_not.append("dependency check failed")
                 break
         return self.can_run
 
@@ -549,6 +571,15 @@
 
         config = self.__versions_stub(
 """
+- branch: 1.8
+- branch: 10
+""")
+        self.assertTrue(config.check_deps(AsteriskVersion("1.8")))
+        self.assertTrue(config.check_deps(AsteriskVersion("10")))
+        self.assertFalse(config.check_deps(AsteriskVersion("1.4")))
+
+        config = self.__versions_stub(
+"""
 - branch: 1.6.2.1
 """)
         self.assertTrue(config.check_deps(AsteriskVersion("1.6.2")))

Modified: asterisk/team/mnicholson/fancy-versions/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mnicholson/fancy-versions/runtests.py?view=diff&rev=2414&r1=2413&r2=2414
==============================================================================
--- asterisk/team/mnicholson/fancy-versions/runtests.py (original)
+++ asterisk/team/mnicholson/fancy-versions/runtests.py Thu Sep 22 14:54:32 2011
@@ -185,12 +185,10 @@
                     continue
 
                 print "--> Cannot run test '%s'" % t.test_name
-		if t.test_config.minversion is not None:
-			print "--- --> Minimum Version: %s (%s)" % \
-			    (str(t.test_config.minversion), str(t.test_config.minversion_check))
-                if t.test_config.maxversion is not None:
-                    print "--- --> Maximum Version: %s (%s)" % \
-                        (str(t.test_config.maxversion), str(t.test_config.maxversion_check))
+
+		print "--- ---> The following problems were detected:"
+		print t.test_config.why_not.join("\n")
+
                 for d in t.test_config.deps:
                     print "--- --> Dependency: %s - %s" % (d.name, str(d.met))
                 print




More information about the asterisk-commits mailing list