[asterisk-commits] mnicholson: testsuite/asterisk/trunk r841 - in /asterisk/trunk/asttest: lib/l...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Nov 16 13:53:44 CST 2010
Author: mnicholson
Date: Tue Nov 16 13:53:40 2010
New Revision: 841
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=841
Log:
Add support for parsing BE version numbers to asttest
Modified:
asterisk/trunk/asttest/lib/lua/astlib.lua
asterisk/trunk/asttest/self-tests/asterisk_version/test.lua
Modified: asterisk/trunk/asttest/lib/lua/astlib.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/lib/lua/astlib.lua?view=diff&rev=841&r1=840&r2=841
==============================================================================
--- asterisk/trunk/asttest/lib/lua/astlib.lua (original)
+++ asterisk/trunk/asttest/lib/lua/astlib.lua Tue Nov 16 13:53:40 2010
@@ -374,6 +374,7 @@
function asterisk_version:new(version)
local v = {
version = version,
+ order = {},
}
setmetatable(v, self)
@@ -395,10 +396,10 @@
-- generate a synthetic version number for svn branch versions
self.patch = self.revision:match("(%d+)M?")
- self.concept, self.major, self.minor = self.branch:match("branch%-(%d+).(%d+).(%d+)")
+ self.concept, self.major, self.minor = self.branch:match("branch%-([^.]+).(%d+).(%d+)")
if not self.concept then
self.minor = "999" -- assume the SVN branch is newer than all released versions
- self.concept, self.major = self.branch:match("branch%-(%d+).(%d+)")
+ self.concept, self.major = self.branch:match("branch%-([^.]+).(%d+)")
end
if not self.concept then
if self.branch == "trunk" then
@@ -413,13 +414,34 @@
self.minor = "0"
end
end
+
+ -- branch C.3 is minor version 998, other C.3 branches are 999
+ if self.branch == "branch-C.3" then
+ self.minor = "998"
+ end
+
+ -- store ordering information
+ -- if self.concept is not a number, assume a BE branch. Treat
+ -- BE like asterisk 1.5.
+ if not self.concept:match("^%d+$") then
+ self.order.concept = 1
+ self.order.major = 5
+ self.order.minor = tonumber(self.minor)
+ self.order.patch = tonumber(self.patch)
+ else
+ self.order.concept = tonumber(self.concept)
+ self.order.major = tonumber(self.major)
+ self.order.minor = tonumber(self.minor)
+ self.order.patch = tonumber(self.patch)
+ end
+
else
- self.concept, self.major, self.minor, self.patch = self.version:match("(%d+).(%d+).(%d+).(%d+)")
+ self.concept, self.major, self.minor, self.patch = self.version:match("([^.]+).(%d+).(%d+).(%d+)")
if not self.concept then
- self.concept, self.major, self.minor = self.version:match("(%d+).(%d+).(%d+)")
+ self.concept, self.major, self.minor = self.version:match("([^.]+).(%d+).(%d+)")
end
if not self.concept then
- self.concept, self.major, self.minor = self.version:match("(%d+).(%d+)")
+ self.concept, self.major, self.minor = self.version:match("([^.]+).(%d+)")
end
if not self.concept then
@@ -434,6 +456,21 @@
self.branch = self.branch .. "." .. self.minor
end
self.revision = "00000"
+
+ -- store ordering information
+ -- if self.concept is not a number, assume a BE branch. Treat
+ -- BE like asterisk 1.5.
+ if not self.concept:match("^%d+$") then
+ self.order.concept = 1
+ self.order.major = 5
+ self.order.minor = tonumber(self.major:match("%d"))
+ self.order.patch = tonumber(self.patch or 0)
+ else
+ self.order.concept = tonumber(self.concept)
+ self.order.major = tonumber(self.major)
+ self.order.minor = tonumber(self.minor or 0)
+ self.order.patch = tonumber(self.patch or 0)
+ end
end
end
@@ -447,10 +484,10 @@
-- versions.
local v = {
- {tonumber(self.concept), tonumber(other.concept)},
- {tonumber(self.major), tonumber(other.major)},
- {tonumber(self.minor or 0), tonumber(other.minor or 0)},
- {tonumber(self.patch or 0), tonumber(other.patch or 0)},
+ {self.order.concept, other.order.concept},
+ {self.order.major, other.order.major},
+ {self.order.minor, other.order.minor},
+ {self.order.patch, other.order.patch},
}
for _, i in ipairs(v) do
Modified: asterisk/trunk/asttest/self-tests/asterisk_version/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/self-tests/asterisk_version/test.lua?view=diff&rev=841&r1=840&r2=841
==============================================================================
--- asterisk/trunk/asttest/self-tests/asterisk_version/test.lua (original)
+++ asterisk/trunk/asttest/self-tests/asterisk_version/test.lua Tue Nov 16 13:53:40 2010
@@ -68,12 +68,19 @@
normal_version("1.4.30", "1", "4", "30")
normal_version("1.4.30.1", "1", "4", "30", "1")
normal_version("1.4", "1", "4")
+normal_version("C.3", "C", "3")
+normal_version("C.3.5", "C", "3", "5")
synthetic_svn_version("1.4.30", "branch-1.4", "00000")
synthetic_svn_version("1.4.30.1", "branch-1.4", "00000")
synthetic_svn_version("1.4", "branch-1.4", "00000")
+synthetic_svn_version("C.3", "branch-C.3", "00000")
+synthetic_svn_version("C.3.5", "branch-C.3", "00000")
+synthetic_svn_version("C.3", "branch-C.3", "00000")
svn_version("SVN-trunk-r252849", "trunk", "252849")
svn_version("SVN-branch-1.6.2-r245581M", "branch-1.6.2", "245581M")
+svn_version("SVN-branch-C.3-r1234", "branch-C.3", "1234")
+svn_version("SVN-branch-C.3-duckpond-r1234", "branch-C.3-duckpond", "1234")
svn_version("SVN-russell-cdr-q-r249059M-/trunk", "russell-cdr-q", "249059M", "/trunk")
svn_version("SVN-russell-rest-r1234", "russell-rest", "1234")
synthetic_version("SVN-trunk-r252849", "999", "0", "0", "252849")
@@ -81,6 +88,8 @@
synthetic_version("SVN-russell-cdr-q-r249059M-/trunk", "998", "0", "0", "249059")
synthetic_version("SVN-russell-rest-r1234", "998", "0", "0", "1234")
synthetic_version("SVN-branch-1.4-r1234", "1", "4", "999", "1234")
+synthetic_version("SVN-branch-C.3-r1234", "C", "3", "998", "1234")
+synthetic_version("SVN-branch-C.3-duckpond-r1234", "C", "3", "999", "1234")
major_version("1.4", "1.4.30")
major_version("1.4", "1.4.30.1")
@@ -88,12 +97,16 @@
major_version("1.4", "SVN-branch-1.4-r224353")
major_version("1.6.2", "SVN-branch-1.6.2-r224353")
major_version("1.6.2", "1.6.2.0")
+major_version("C.3", "C.3")
+major_version("C.3", "C.3.5")
not_major_version("1.4", "1.6.2")
not_major_version("1.4", "1.8")
not_major_version("1.6", "SVN-trunk-r224353")
not_major_version("1.6.1", "1.6.2")
not_major_version("trunk", "1.6.2")
+not_major_version("trunk", "C.3")
+not_major_version("C.3", "1.4.3")
print("testing comparisons")
fail_if(ast.version("1.6") > ast.version("1.6.2"), "1.6 > 1.6.2 failed")
@@ -107,9 +120,11 @@
fail_if(not (ast.version("1.4.30") < ast.version("SVN-branch-1.4-r224353")), "1.4.30 < SVN-branch-1.4-r224353 failed")
fail_if(not (ast.version("SVN-branch-1.6.2-r224353") == ast.version("SVN-branch-1.6.2-r224353")), "SVN-branch-1.6.2-r224353 == SVN-branch-1.6.2-r224353 failed")
fail_if(not (ast.version("SVN-branch-1.6.2-r224352") < ast.version("SVN-branch-1.6.2-r224353")), "SVN-branch-1.6.2-r224352 < SVN-branch-1.6.2-r224353 failed")
-fail_if(not (ast.version("SVN-trunk-r1234") > ast.version("SVN-branch-1.6.2-r224353")), "SVN-trunk-r1234 < SVN-branch-1.6.2-r224353 failed")
+fail_if(not (ast.version("SVN-trunk-r1234") > ast.version("SVN-branch-1.6.2-r224353")), "SVN-trunk-r1234 > SVN-branch-1.6.2-r224353 failed")
fail_if(not (ast.version("1.4.30") < ast.version("SVN-branch-1.6.2-r224353")), "1.4.30 < SVN-branch-1.6.2-r224353 failed")
fail_if(not (ast.version("1.4.30") < ast.version("SVN-branch-1.6.2-r224353")), "1.4.30 < SVN-branch-1.6.2-r224353 failed")
+fail_if(not (ast.version("C.3") < ast.version("1.6.2")), "C.3 < 1.6.2 failed")
+fail_if(not (ast.version("C.3") > ast.version("1.4.34")), "C.3 > 1.4.34 failed")
if ast.exists() then
print("automatically detected version " .. tostring(ast.version()))
More information about the asterisk-commits
mailing list