diff options
author | Andrey Zelenkov <zelenkov@nginx.com> | 2019-09-16 15:37:32 +0300 |
---|---|---|
committer | Andrey Zelenkov <zelenkov@nginx.com> | 2019-09-16 15:37:32 +0300 |
commit | 962cdb66590b9f9ec57e0a6aa5d0cb359bb8f145 (patch) | |
tree | 10a8c6b432245dab7afde135246c862204bce8fd | |
parent | 13ecbe333a6ce7fda1f25d09412998175b435a1d (diff) | |
download | unit-962cdb66590b9f9ec57e0a6aa5d0cb359bb8f145.tar.gz unit-962cdb66590b9f9ec57e0a6aa5d0cb359bb8f145.tar.bz2 |
Tests: prepare_env() introduced.
-rw-r--r-- | test/unit/applications/lang/go.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/test/unit/applications/lang/go.py b/test/unit/applications/lang/go.py index e4ab8ffa..35ceefa7 100644 --- a/test/unit/applications/lang/go.py +++ b/test/unit/applications/lang/go.py @@ -4,13 +4,10 @@ from unit.applications.proto import TestApplicationProto class TestApplicationGo(TestApplicationProto): - def load(self, script, name='app'): - - if not os.path.isdir(self.testdir + '/go'): + def prepare_env(self, script, name): + if not os.path.exists(self.testdir + '/go'): os.mkdir(self.testdir + '/go') - go_app_path = self.current_dir + '/go/' - env = os.environ.copy() env['GOPATH'] = self.pardir + '/go' process = Popen( @@ -19,12 +16,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 +35,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, } }, } |