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/go.py | |
parent | fcb1f851d0b5d1774a6cb876288ea29cfef58618 (diff) | |
parent | db777d1e7f607d1b0f01dfb73ad0bac12987202b (diff) | |
download | unit-deb26fa47a9ab1b358938134a8ced8bbc4a083e1.tar.gz unit-deb26fa47a9ab1b358938134a8ced8bbc4a083e1.tar.bz2 |
Merged with the default branch.
Diffstat (limited to 'test/unit/applications/lang/go.py')
-rw-r--r-- | test/unit/applications/lang/go.py | 32 |
1 files changed, 25 insertions, 7 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, } }, } |