diff options
author | Konstantin Pavlov <thresh@nginx.com> | 2019-09-19 19:04:16 +0300 |
---|---|---|
committer | Konstantin Pavlov <thresh@nginx.com> | 2019-09-19 19:04:16 +0300 |
commit | deb26fa47a9ab1b358938134a8ced8bbc4a083e1 (patch) | |
tree | 0bedf8829f003fa4c0101e3421b7184acc1c8343 /test/unit/applications/lang | |
parent | fcb1f851d0b5d1774a6cb876288ea29cfef58618 (diff) | |
parent | db777d1e7f607d1b0f01dfb73ad0bac12987202b (diff) | |
download | unit-deb26fa47a9ab1b358938134a8ced8bbc4a083e1.tar.gz unit-deb26fa47a9ab1b358938134a8ced8bbc4a083e1.tar.bz2 |
Merged with the default branch.
Diffstat (limited to '')
-rw-r--r-- | test/unit/applications/lang/go.py | 32 | ||||
-rw-r--r-- | test/unit/applications/lang/java.py | 26 | ||||
-rw-r--r-- | test/unit/applications/lang/node.py | 12 |
3 files changed, 53 insertions, 17 deletions
diff --git a/test/unit/applications/lang/go.py b/test/unit/applications/lang/go.py index e4ab8ffa..15ac1cd9 100644 --- a/test/unit/applications/lang/go.py +++ b/test/unit/applications/lang/go.py @@ -4,12 +4,22 @@ from unit.applications.proto import TestApplicationProto class TestApplicationGo(TestApplicationProto): - def load(self, script, name='app'): + @classmethod + def setUpClass(cls, complete_check=True): + unit = super().setUpClass(complete_check=False) - if not os.path.isdir(self.testdir + '/go'): - os.mkdir(self.testdir + '/go') + # check go module + + go_app = TestApplicationGo() + go_app.testdir = unit.testdir + if go_app.prepare_env('empty', 'app').returncode == 0: + cls.available['modules']['go'] = [] - go_app_path = self.current_dir + '/go/' + return unit if not complete_check else unit.complete() + + def prepare_env(self, script, name): + if not os.path.exists(self.testdir + '/go'): + os.mkdir(self.testdir + '/go') env = os.environ.copy() env['GOPATH'] = self.pardir + '/go' @@ -19,12 +29,18 @@ class TestApplicationGo(TestApplicationProto): 'build', '-o', self.testdir + '/go/' + name, - go_app_path + script + '/' + name + '.go', + self.current_dir + '/go/' + script + '/' + name + '.go', ], env=env, ) + process.communicate() + return process + + def load(self, script, name='app'): + self.prepare_env(script, name) + self._load_conf( { "listeners": {"*:7080": {"pass": "applications/" + script}}, @@ -32,8 +48,10 @@ class TestApplicationGo(TestApplicationProto): script: { "type": "external", "processes": {"spare": 0}, - "working_directory": go_app_path + script, - "executable": self.testdir + '/go/' + name, + "working_directory": self.current_dir + + "/go/" + + script, + "executable": self.testdir + "/go/" + name, } }, } diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py index ec1c95d9..40bf3662 100644 --- a/test/unit/applications/lang/java.py +++ b/test/unit/applications/lang/java.py @@ -1,4 +1,5 @@ import os +import glob import shutil from subprocess import Popen from unit.applications.proto import TestApplicationProto @@ -6,11 +7,9 @@ from unit.applications.proto import TestApplicationProto class TestApplicationJava(TestApplicationProto): def load(self, script, name='app'): - app_path = self.testdir + '/java' web_inf_path = app_path + '/WEB-INF/' classes_path = web_inf_path + 'classes/' - script_path = self.current_dir + '/java/' + script + '/' if not os.path.isdir(app_path): @@ -19,39 +18,48 @@ class TestApplicationJava(TestApplicationProto): src = [] for f in os.listdir(script_path): + file_path = script_path + f + if f.endswith('.java'): - src.append(script_path + f) + src.append(file_path) continue if f.startswith('.') or f == 'Makefile': continue - if os.path.isdir(script_path + f): + if os.path.isdir(file_path): if f == 'WEB-INF': continue - shutil.copytree(script_path + f, app_path + '/' + f) + shutil.copytree(file_path, app_path + '/' + f) continue if f == 'web.xml': if not os.path.isdir(web_inf_path): os.makedirs(web_inf_path) - shutil.copy2(script_path + f, web_inf_path) + shutil.copy2(file_path, web_inf_path) else: - shutil.copy2(script_path + f, app_path) + shutil.copy2(file_path, app_path) if src: if not os.path.isdir(classes_path): os.makedirs(classes_path) - tomcat_jar = self.pardir + '/build/tomcat-servlet-api-9.0.13.jar' + classpath = self.pardir + '/build/tomcat-servlet-api-9.0.13.jar' + + ws_jars = glob.glob( + self.pardir + '/build/websocket-api-java-*.jar' + ) + + if not ws_jars: + self.fail('websocket api jar not found.') javac = [ 'javac', '-encoding', 'utf-8', '-d', classes_path, - '-classpath', tomcat_jar, + '-classpath', classpath + ':' + ws_jars[0], ] javac.extend(src) diff --git a/test/unit/applications/lang/node.py b/test/unit/applications/lang/node.py index 931c6596..3cc72669 100644 --- a/test/unit/applications/lang/node.py +++ b/test/unit/applications/lang/node.py @@ -4,8 +4,18 @@ from unit.applications.proto import TestApplicationProto class TestApplicationNode(TestApplicationProto): - def load(self, script, name='app.js'): + @classmethod + def setUpClass(cls, complete_check=True): + unit = super().setUpClass(complete_check=False) + + # check node module + + if os.path.exists(unit.pardir + '/node/node_modules'): + cls.available['modules']['node'] = [] + return unit if not complete_check else unit.complete() + + def load(self, script, name='app.js'): # copy application shutil.copytree( |