summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2018-01-15 15:00:44 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2018-01-15 15:00:44 +0300
commit75af52fd65a7a55bf340727a3d47ae3b337c3b56 (patch)
tree12397171ad7d9f0c36b3f4bbcb131db438f24cfa
parentac433f1f304c65127403cd79fef6e7ad5526940c (diff)
downloadunit-75af52fd65a7a55bf340727a3d47ae3b337c3b56.tar.gz
unit-75af52fd65a7a55bf340727a3d47ae3b337c3b56.tar.bz2
Tests: check_version() function introduced.
-rw-r--r--test/unit.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/test/unit.py b/test/unit.py
index 9b3f76ef..1bd927f3 100644
--- a/test/unit.py
+++ b/test/unit.py
@@ -12,6 +12,8 @@ from multiprocessing import Process
class TestUnit(unittest.TestCase):
+ pardir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
+
def setUp(self):
self._run()
@@ -54,6 +56,17 @@ class TestUnit(unittest.TestCase):
if missed_module:
raise unittest.SkipTest('Unit has no ' + missed_module + ' module')
+ def check_version(self, version):
+ with open(self.pardir + '/src/nxt_main.h' , 'r') as f:
+ m = re.search('NXT_VERSION\s+"(\d+\.\d+)"', f.read(), re.M | re.S)
+
+ current = m.group(1).split('.')
+ need = version.split('.')
+
+ for i in range(len(need)):
+ if need[i] > current[i]:
+ raise unittest.SkipTest('Unit too old')
+
def _run(self):
self.testdir = tempfile.mkdtemp(prefix='unit-test-')
@@ -62,12 +75,9 @@ class TestUnit(unittest.TestCase):
print()
def _run_unit():
- pardir = os.path.abspath(os.path.join(os.path.dirname(__file__),
- os.pardir))
-
- call([pardir + '/build/unitd',
+ call([self.pardir + '/build/unitd',
'--no-daemon',
- '--modules', pardir + '/build',
+ '--modules', self.pardir + '/build',
'--state', self.testdir + '/state',
'--pid', self.testdir + '/unit.pid',
'--log', self.testdir + '/unit.log',