diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2019-08-06 18:25:13 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2019-08-06 18:25:13 +0300 |
commit | c8c259b9728c57e70042d7630045e5b043f46e5b (patch) | |
tree | 7ecd61a159c154ab4299fa9e07c7b500dc0a6e67 /test | |
parent | 274260bd2824f11d5007587e0f3bf897149d7107 (diff) | |
download | unit-c8c259b9728c57e70042d7630045e5b043f46e5b.tar.gz unit-c8c259b9728c57e70042d7630045e5b043f46e5b.tar.bz2 |
Tests: rerun tests for each module version.
Rerun supported for Python, PHP, Perl, Ruby, and Java modules.
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/applications/lang/java.py | 4 | ||||
-rw-r--r-- | test/unit/applications/lang/perl.py | 4 | ||||
-rw-r--r-- | test/unit/applications/lang/php.py | 4 | ||||
-rw-r--r-- | test/unit/applications/lang/python.py | 4 | ||||
-rw-r--r-- | test/unit/applications/lang/ruby.py | 4 | ||||
-rw-r--r-- | test/unit/main.py | 26 |
6 files changed, 40 insertions, 6 deletions
diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py index c4390f15..ec492d06 100644 --- a/test/unit/applications/lang/java.py +++ b/test/unit/applications/lang/java.py @@ -5,6 +5,8 @@ from unit.applications.proto import TestApplicationProto class TestApplicationJava(TestApplicationProto): + application_type = "java" + def load(self, script, name='app'): app_path = self.testdir + '/java' @@ -64,7 +66,7 @@ class TestApplicationJava(TestApplicationProto): "applications": { script: { "unit_jars": self.pardir + '/build', - "type": "java", + "type": self.application_type, "processes": {"spare": 0}, "working_directory": script_path, "webapp": app_path, diff --git a/test/unit/applications/lang/perl.py b/test/unit/applications/lang/perl.py index 8aaf33a4..79df2cfa 100644 --- a/test/unit/applications/lang/perl.py +++ b/test/unit/applications/lang/perl.py @@ -2,6 +2,8 @@ from unit.applications.proto import TestApplicationProto class TestApplicationPerl(TestApplicationProto): + application_type = "perl" + def load(self, script, name='psgi.pl'): script_path = self.current_dir + '/perl/' + script @@ -10,7 +12,7 @@ class TestApplicationPerl(TestApplicationProto): "listeners": {"*:7080": {"pass": "applications/" + script}}, "applications": { script: { - "type": "perl", + "type": self.application_type, "processes": {"spare": 0}, "working_directory": script_path, "script": script_path + '/' + name, diff --git a/test/unit/applications/lang/php.py b/test/unit/applications/lang/php.py index 99d84164..9c54368d 100644 --- a/test/unit/applications/lang/php.py +++ b/test/unit/applications/lang/php.py @@ -2,6 +2,8 @@ from unit.applications.proto import TestApplicationProto class TestApplicationPHP(TestApplicationProto): + application_type = "php" + def load(self, script, name='index.php'): script_path = self.current_dir + '/php/' + script @@ -10,7 +12,7 @@ class TestApplicationPHP(TestApplicationProto): "listeners": {"*:7080": {"pass": "applications/" + script}}, "applications": { script: { - "type": "php", + "type": self.application_type, "processes": {"spare": 0}, "root": script_path, "working_directory": script_path, diff --git a/test/unit/applications/lang/python.py b/test/unit/applications/lang/python.py index d1b5b839..ded76cb6 100644 --- a/test/unit/applications/lang/python.py +++ b/test/unit/applications/lang/python.py @@ -2,6 +2,8 @@ from unit.applications.proto import TestApplicationProto class TestApplicationPython(TestApplicationProto): + application_type = "python" + def load(self, script, name=None): if name is None: name = script @@ -13,7 +15,7 @@ class TestApplicationPython(TestApplicationProto): "listeners": {"*:7080": {"pass": "applications/" + name}}, "applications": { name: { - "type": "python", + "type": self.application_type, "processes": {"spare": 0}, "path": script_path, "working_directory": script_path, diff --git a/test/unit/applications/lang/ruby.py b/test/unit/applications/lang/ruby.py index c2d8633e..d30735ad 100644 --- a/test/unit/applications/lang/ruby.py +++ b/test/unit/applications/lang/ruby.py @@ -2,6 +2,8 @@ from unit.applications.proto import TestApplicationProto class TestApplicationRuby(TestApplicationProto): + application_type = "ruby" + def load(self, script, name='config.ru'): script_path = self.current_dir + '/ruby/' + script @@ -10,7 +12,7 @@ class TestApplicationRuby(TestApplicationProto): "listeners": {"*:7080": {"pass": "applications/" + script}}, "applications": { script: { - "type": "ruby", + "type": self.application_type, "processes": {"spare": 0}, "working_directory": script_path, "script": script_path + '/' + name, diff --git a/test/unit/main.py b/test/unit/main.py index 49806fe7..212da49e 100644 --- a/test/unit/main.py +++ b/test/unit/main.py @@ -12,6 +12,8 @@ import subprocess from multiprocessing import Process +available_modules = {} + class TestUnit(unittest.TestCase): current_dir = os.path.abspath( @@ -34,6 +36,17 @@ class TestUnit(unittest.TestCase): TestUnit._set_args(args) + def run(self, result=None): + if not hasattr(self, 'application_type'): + return super().run(result) + + type = self.application_type + for prerequisite in self.prerequisites: + if prerequisite in available_modules: + for version in available_modules[prerequisite]: + self.application_type = type + ' ' + version + super().run(result) + @classmethod def main(cls): args, rest = TestUnit._parse_args() @@ -108,6 +121,16 @@ class TestUnit(unittest.TestCase): self.stop() exit("Unit is writing log too long") + # discover all available modules + + global available_modules + available_modules = {} + for module in re.findall(r'module: ([a-zA-Z]+) ([\d\.]*) ', log): + if module[0] not in available_modules: + available_modules[module[0]] = [module[1]] + else: + available_modules[module[0]].append(module[1]) + missed_module = '' for module in modules: if module == 'go': @@ -153,7 +176,8 @@ class TestUnit(unittest.TestCase): m = None else: - m = re.search('module: ' + module, log) + if module not in available_modules: + m = None if m is None: missed_module = module |