summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2022-11-15 00:39:21 +0000
committerAndrei Zeliankou <zelenkov@nginx.com>2022-11-15 00:39:21 +0000
commit0d3b31e6710afe4348eb25f1602f5271c92b9a77 (patch)
tree6383fcfa881635a62a2713c2c3b3a98d95a23153
parent40d75c94a039f35505975736bb4f907ec456c9bd (diff)
downloadunit-0d3b31e6710afe4348eb25f1602f5271c92b9a77.tar.gz
unit-0d3b31e6710afe4348eb25f1602f5271c92b9a77.tar.bz2
Tests: features and options checks improved.
Now version output evaluates only once. OpenSSL checks more carefully.
-rw-r--r--test/conftest.py7
-rw-r--r--test/unit/check/regex.py9
-rw-r--r--test/unit/check/tls.py13
3 files changed, 13 insertions, 16 deletions
diff --git a/test/conftest.py b/test/conftest.py
index 18851baa..ac88675a 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -176,6 +176,9 @@ def pytest_sessionstart(session):
option.available = {'modules': {}, 'features': {}}
unit = unit_run()
+ output_version = subprocess.check_output(
+ [unit['unitd'], '--version'], stderr=subprocess.STDOUT
+ ).decode()
# read unit.log
@@ -202,10 +205,10 @@ def pytest_sessionstart(session):
# discover modules from check
- option.available['modules']['openssl'] = check_openssl(unit['unitd'])
option.available['modules']['go'] = check_go()
option.available['modules']['node'] = check_node(option.current_dir)
- option.available['modules']['regex'] = check_regex(unit['unitd'])
+ option.available['modules']['openssl'] = check_openssl(output_version)
+ option.available['modules']['regex'] = check_regex(output_version)
# remove None values
diff --git a/test/unit/check/regex.py b/test/unit/check/regex.py
index 734c0150..51cf966b 100644
--- a/test/unit/check/regex.py
+++ b/test/unit/check/regex.py
@@ -1,13 +1,8 @@
import re
-import subprocess
-def check_regex(unitd):
- output = subprocess.check_output(
- [unitd, '--version'], stderr=subprocess.STDOUT
- )
-
- if re.search('--no-regex', output.decode()):
+def check_regex(output_version):
+ if re.search('--no-regex', output_version):
return False
return True
diff --git a/test/unit/check/tls.py b/test/unit/check/tls.py
index b878ff7d..53ce5ffc 100644
--- a/test/unit/check/tls.py
+++ b/test/unit/check/tls.py
@@ -2,12 +2,11 @@ import re
import subprocess
-def check_openssl(unitd):
- subprocess.check_output(['which', 'openssl'])
+def check_openssl(output_version):
+ try:
+ subprocess.check_output(['which', 'openssl'])
+ except subprocess.CalledProcessError:
+ return None
- output = subprocess.check_output(
- [unitd, '--version'], stderr=subprocess.STDOUT
- )
-
- if re.search('--openssl', output.decode()):
+ if re.search('--openssl', output_version):
return True