diff options
author | oxpa <iippolitov@gmail.com> | 2024-09-17 14:21:10 +0100 |
---|---|---|
committer | oxpa <iippolitov@gmail.com> | 2024-09-17 14:21:10 +0100 |
commit | 2417826d8bebf921ee1be102ef8ce702f0683d66 (patch) | |
tree | 76d29a1705415ed7368870826dbb2f04942ee794 /test/unit/applications/lang | |
parent | 0e79d961bb1ea68674961da1703ffedb1ddf6e43 (diff) | |
parent | 24ed91f40634372d99f67f0e4e3c2ac0abde81bd (diff) | |
download | unit-2417826d8bebf921ee1be102ef8ce702f0683d66.tar.gz unit-2417826d8bebf921ee1be102ef8ce702f0683d66.tar.bz2 |
Merge tag '1.33.0' into packaging.
Unit 1.33.0 release.
Diffstat (limited to 'test/unit/applications/lang')
-rw-r--r-- | test/unit/applications/lang/java.py | 2 | ||||
-rw-r--r-- | test/unit/applications/lang/wasm_component.py | 63 |
2 files changed, 64 insertions, 1 deletions
diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py index 351d04ce..2b3194ae 100644 --- a/test/unit/applications/lang/java.py +++ b/test/unit/applications/lang/java.py @@ -53,7 +53,7 @@ class ApplicationJava(ApplicationProto): os.makedirs(classes_path) classpath = ( - f'{option.current_dir}/build/tomcat-servlet-api-9.0.86.jar' + f'{option.current_dir}/build/tomcat-servlet-api-9.0.93.jar' ) ws_jars = glob.glob( diff --git a/test/unit/applications/lang/wasm_component.py b/test/unit/applications/lang/wasm_component.py new file mode 100644 index 00000000..a6c8dd14 --- /dev/null +++ b/test/unit/applications/lang/wasm_component.py @@ -0,0 +1,63 @@ +from pathlib import Path +import shutil +import subprocess +from urllib.parse import quote + +from unit.applications.proto import ApplicationProto +from unit.option import option + + +class ApplicationWasmComponent(ApplicationProto): + @staticmethod + def prepare_env(script): + try: + subprocess.check_output( + ['cargo', 'component', '--help'], + stderr=subprocess.STDOUT, + ) + except (subprocess.CalledProcessError, FileNotFoundError): + return None + + temp_dir = Path(f'{option.temp_dir}/wasm_component/') + + if not temp_dir.exists(): + temp_dir.mkdir() + + app_path = f'{temp_dir}/{script}' + + shutil.copytree(f'{option.test_dir}/wasm_component/{script}', app_path) + + try: + output = subprocess.check_output( + ['cargo', 'component', 'build', '--release'], + cwd=app_path, + stderr=subprocess.STDOUT, + ) + except KeyboardInterrupt: + raise + + except subprocess.CalledProcessError: + return None + + return output + + def load(self, script, **kwargs): + self.prepare_env(script) + + component_path = f'{option.temp_dir}/wasm_component/{script}/target/wasm32-wasip1/release/test_wasi_component.wasm' + + self._load_conf( + { + "listeners": { + "*:8080": {"pass": f"applications/{quote(script, '')}"} + }, + "applications": { + script: { + "type": "wasm-wasi-component", + "processes": {"spare": 0}, + "component": component_path, + } + }, + }, + **kwargs, + ) |