-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
tests/ten_manager/install/template_mode_with_same_name_extension/BUILD.gn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# Copyright © 2024 Agora | ||
# This file is part of TEN Framework, an open source project. | ||
# Licensed under the Apache License, Version 2.0, with certain conditions. | ||
# Refer to the "LICENSE" file in the root directory for more information. | ||
# | ||
import("//build/ten_runtime/feature/test.gni") | ||
|
||
ten_package_test_prepare_auxiliary_resources( | ||
"template_mode_with_same_name_extension") { | ||
resources = [ | ||
"//.gnfiles/build/scripts/cmd_exec.py=>common/cmd_exec.py", | ||
"__init__.py", | ||
"mock_app/expected.json", | ||
"mock_app/manifest.json", | ||
"mock_app/ten_packages", | ||
"test_case.py", | ||
] | ||
deps = [ | ||
"//core/src/ten_manager", | ||
"//tests/local_registry", | ||
] | ||
} |
Empty file.
12 changes: 12 additions & 0 deletions
12
tests/ten_manager/install/template_mode_with_same_name_extension/mock_app/expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extension": [ | ||
{ | ||
"name": "default_extension_cpp", | ||
"version": "0.3.0" | ||
}, | ||
{ | ||
"name": "hello_world_extension_cpp", | ||
"version": "0.3.0" | ||
} | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/ten_manager/install/template_mode_with_same_name_extension/mock_app/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "app", | ||
"name": "mock_app", | ||
"version": "0.1.0", | ||
"dependencies": [] | ||
} |
32 changes: 32 additions & 0 deletions
32
...h_same_name_extension/mock_app/ten_packages/extension/default_extension_cpp/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"type": "extension", | ||
"name": "default_extension_cpp", | ||
"version": "0.3.0", | ||
"dependencies": [ | ||
{ | ||
"type": "system", | ||
"name": "ten_runtime", | ||
"version": "0.3.0" | ||
} | ||
], | ||
"package": { | ||
"include": [ | ||
"**" | ||
] | ||
}, | ||
"api": { | ||
"cmd_in": [ | ||
{ | ||
"name": "hello_world" | ||
} | ||
], | ||
"cmd_out": [], | ||
"data_in": [], | ||
"data_out": [], | ||
"video_frame_in": [], | ||
"video_frame_out": [], | ||
"audio_frame_in": [], | ||
"audio_frame_out": [], | ||
"interface_in": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...h_same_name_extension/mock_app/ten_packages/extension/default_extension_cpp/property.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
106 changes: 106 additions & 0 deletions
106
tests/ten_manager/install/template_mode_with_same_name_extension/test_case.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# | ||
# Copyright © 2024 Agora | ||
# This file is part of TEN Framework, an open source project. | ||
# Licensed under the Apache License, Version 2.0, with certain conditions. | ||
# Refer to the "LICENSE" file in the root directory for more information. | ||
# | ||
import os | ||
import sys | ||
import json | ||
from .common import cmd_exec | ||
|
||
|
||
def analyze_resolve_result(app_root_folder: str) -> None: | ||
extension_folder = os.path.join( | ||
app_root_folder, "ten_packages", "extension" | ||
) | ||
|
||
with open( | ||
os.path.join(app_root_folder, "expected.json"), "r" | ||
) as expected_json_file: | ||
expected_json = json.load(expected_json_file) | ||
|
||
# @{ | ||
# Check all expected extensions are installed. | ||
for ext in expected_json["extension"]: | ||
found_in_folder = False | ||
found_in_manifest_deps = False | ||
|
||
for dir_item in os.listdir(extension_folder): | ||
if dir_item == ext["name"]: | ||
found_in_folder = True | ||
with open( | ||
os.path.join( | ||
extension_folder, ext["name"], "manifest.json" | ||
), | ||
"r", | ||
) as ext_manifest_file: | ||
ext_manifest_json = json.load(ext_manifest_file) | ||
assert ext_manifest_json["name"] == ext["name"] | ||
assert ext_manifest_json["version"] == ext["version"] | ||
break | ||
|
||
with open( | ||
os.path.join(app_root_folder, "manifest.json"), "r" | ||
) as app_manifest_file: | ||
app_manifest_json = json.load(app_manifest_file) | ||
for dep in app_manifest_json["dependencies"]: | ||
if dep["name"] == ext["name"]: | ||
found_in_manifest_deps = True | ||
assert dep["version"] == ext["version"] | ||
break | ||
|
||
assert found_in_folder is True | ||
assert found_in_manifest_deps is True | ||
# @} | ||
|
||
# @{ | ||
# Check there is no other unexpected extensions be installed. | ||
installed_extension_cnt = 0 | ||
if os.path.exists(extension_folder): | ||
for dir_item in os.listdir(extension_folder): | ||
installed_extension_cnt += 1 | ||
assert len(expected_json["extension"]) == installed_extension_cnt | ||
# @} | ||
|
||
|
||
def test_tman_install(): | ||
"""Test tman install.""" | ||
base_path = os.path.dirname(os.path.abspath(__file__)) | ||
root_dir = os.path.join(base_path, "../../../../") | ||
|
||
my_env = os.environ.copy() | ||
if sys.platform == "win32": | ||
my_env["PATH"] = ( | ||
os.path.join(root_dir, "ten_manager/lib") + ";" + my_env["PATH"] | ||
) | ||
tman_bin = os.path.join(root_dir, "ten_manager/bin/tman.exe") | ||
else: | ||
tman_bin = os.path.join(root_dir, "ten_manager/bin/tman") | ||
|
||
mock_app_path = os.path.join(base_path, "mock_app") | ||
os.chdir(mock_app_path) | ||
|
||
config_file = os.path.join( | ||
root_dir, | ||
"tests/local_registry/config.json", | ||
) | ||
|
||
returncode, output_text = cmd_exec.run_cmd_realtime( | ||
[ | ||
tman_bin, | ||
f"--config-file={config_file}", | ||
"install", | ||
"extension", | ||
"default_extension_cpp", | ||
"--template-mode", | ||
"--template-data", | ||
"package_name=hello_world", | ||
], | ||
env=my_env, | ||
) | ||
if returncode != 0: | ||
print(output_text) | ||
assert 0 | ||
|
||
analyze_resolve_result(mock_app_path) |