From 65a660df4c47890963c0a4f98342f35e60904cae Mon Sep 17 00:00:00 2001 From: Hu Yueh-Wei Date: Mon, 6 Jan 2025 16:11:05 +0800 Subject: [PATCH] refactor: remove unnecessary test case --- build/ten_runtime/feature/test.gni | 227 ------------------ tests/ten_manager/BUILD.gn | 4 - tests/ten_manager/standalone/BUILD.gn | 9 - tests/ten_manager/standalone/build/BUILD.gn | 36 --- .../ten_manager/standalone/build/__init__.py | 0 .../ten_manager/standalone/build/test_case.py | 69 ------ 6 files changed, 345 deletions(-) delete mode 100644 tests/ten_manager/standalone/BUILD.gn delete mode 100644 tests/ten_manager/standalone/build/BUILD.gn delete mode 100644 tests/ten_manager/standalone/build/__init__.py delete mode 100644 tests/ten_manager/standalone/build/test_case.py diff --git a/build/ten_runtime/feature/test.gni b/build/ten_runtime/feature/test.gni index b3f18f7e9e..14408a20bc 100644 --- a/build/ten_runtime/feature/test.gni +++ b/build/ten_runtime/feature/test.gni @@ -564,230 +564,3 @@ template("ten_package_test_prepare_auxiliary_resources") { deps = res_deps } } - -template("ten_package_standalone_pkg") { - # The following fields are necessary. - assert(defined(invoker.pkg_template) && invoker.pkg_template != "") - - _pkg_type = "extension" - if (defined(invoker.pkg_type) && invoker.pkg_type != "") { - _pkg_type = invoker.pkg_type - } - - _target_name = target_name - - test_case_out_dir_rel_path_str = - get_path_info(get_path_info(target_name, "abspath"), "dir") - test_case_out_dir_rel_path = - "${root_out_dir}/${test_case_out_dir_rel_path_str}" - - test_case_unique_target_name = - string_replace(test_case_out_dir_rel_path_str, "/", "_") - - pkg_root_dir = "${test_case_out_dir_rel_path}/${_target_name}" - - install_standalone_dummy_output_file = - "${target_gen_dir}/${_target_name}/install_standalone_dummy_output_file" - install_standalone_depfile = "${target_gen_dir}/install_standalone_depfile" - - action("${test_case_unique_target_name}_${_target_name}_install_pkg") { - script = "//build/ten_runtime/feature/install_pkg.py" - - args = [ "--tman-path" ] - if (is_win) { - args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman.exe") ] - } else { - args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman") ] - } - - args += [ - "--pkg-type", - _pkg_type, - "--pkg-src-root-dir", - rebase_path(pkg_root_dir), - "--tg-timestamp-proxy-file", - rebase_path(install_standalone_dummy_output_file), - "--src-pkg", - invoker.pkg_template, - ] - - args += [ - "--config-file", - rebase_path("${root_out_dir}/tests/local_registry/config.json"), - ] - - args += [ - "--log-level", - "${log_level}", - ] - - args += [ - "--local-registry-path", - rebase_path("${root_out_dir}/tests/local_registry"), - ] - - if (invoker.deps != []) { - foreach(dep, invoker.deps) { - args += [ - "--possible-published-results", - rebase_path(get_label_info(dep, "target_gen_dir")), - ] - } - args += [ - "--depfile", - rebase_path(install_standalone_depfile), - "--depfile-target", - rebase_path(install_standalone_dummy_output_file, root_build_dir), - ] - } - - sources = [] - outputs = [ install_standalone_dummy_output_file ] - depfile = install_standalone_depfile - - forward_variables_from(invoker, - [ - "deps", - "public_deps", - "data_deps", - ]) - - if (!defined(deps)) { - deps = [] - } - deps += [ - "//build/ten_runtime/feature:create_tman_config", - "//core/src/ten_manager", - ] - } - - install_all_dummy_output_file = - "${target_gen_dir}/${_target_name}/install_dummy_output_file" - - # Install dependencies of the standalone package. - action("${test_case_unique_target_name}_${_target_name}_install") { - script = "//build/ten_runtime/feature/install_all.py" - - args = [ "--tman-path" ] - if (is_win) { - args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman.exe") ] - } else { - args += [ rebase_path("${root_out_dir}/ten_manager/bin/tman") ] - } - - args += [ - "--pkg-src-root-dir", - rebase_path(pkg_root_dir), - ] - - args += [ - "--tg-timestamp-proxy-file", - rebase_path(install_all_dummy_output_file), - ] - - args += [ - "--assume-yes", - "True", - ] - - args += [ - "--config-file", - rebase_path("${root_out_dir}/tests/local_registry/config.json"), - ] - - args += [ - "--log-level", - "${log_level}", - ] - - outputs = [ install_all_dummy_output_file ] - - forward_variables_from(invoker, - [ - "deps", - "public_deps", - "data_deps", - ]) - - if (!defined(deps)) { - deps = [] - } - deps += [ - ":${test_case_unique_target_name}_${_target_name}_install_pkg", - "//build/ten_runtime/feature:create_tman_config", - "//core/src/ten_manager", - ] - } - - # Build this standalone package. - build_pkg_dummy_output_file = - "${target_gen_dir}/${_target_name}/build_pkg_dummy_output_file" - - action("${test_case_unique_target_name}_${_target_name}_build") { - script = "//build/ten_runtime/feature/build_pkg.py" - - args = [ - "--pkg-src-root-dir", - rebase_path(pkg_root_dir), - "--tg-timestamp-proxy-file", - rebase_path(build_pkg_dummy_output_file), - "--log-level", - "${log_level}", - "--pkg-name", - _target_name, - "--pkg-language", - invoker.pkg_language, - "--os", - target_os, - "--cpu", - target_cpu, - "--build", - ] - - if (is_debug) { - args += [ "debug" ] - } else { - args += [ "release" ] - } - - if (is_win) { - args += [ - "--vs-version", - "$vs_version", - ] - } - - if (is_clang) { - args += [ "--is-clang" ] - } else { - args += [ "--no-is-clang" ] - } - - if (enable_sanitizer) { - args += [ "--enable-sanitizer" ] - } else { - args += [ "--no-enable-sanitizer" ] - } - - outputs = [ build_pkg_dummy_output_file ] - - forward_variables_from(invoker, - [ - "deps", - "public_deps", - "data_deps", - ]) - - if (!defined(deps)) { - deps = [] - } - deps += [ - ":${test_case_unique_target_name}_${_target_name}_install", - ":${test_case_unique_target_name}_${_target_name}_install_pkg", - ] - } - - group("${_target_name}") { - deps = [ ":${test_case_unique_target_name}_${_target_name}_build" ] - } -} diff --git a/tests/ten_manager/BUILD.gn b/tests/ten_manager/BUILD.gn index 25b525ea39..f02412f8da 100644 --- a/tests/ten_manager/BUILD.gn +++ b/tests/ten_manager/BUILD.gn @@ -15,8 +15,4 @@ group("ten_manager") { "publish:tman_publish", "//build/ten_runtime/feature:create_tman_config", ] - - if (ten_enable_ten_manager) { - deps += [ "standalone" ] - } } diff --git a/tests/ten_manager/standalone/BUILD.gn b/tests/ten_manager/standalone/BUILD.gn deleted file mode 100644 index f545b217ee..0000000000 --- a/tests/ten_manager/standalone/BUILD.gn +++ /dev/null @@ -1,9 +0,0 @@ -# -# Copyright © 2025 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. -# -group("standalone") { - deps = [ "build" ] -} diff --git a/tests/ten_manager/standalone/build/BUILD.gn b/tests/ten_manager/standalone/build/BUILD.gn deleted file mode 100644 index d192f18913..0000000000 --- a/tests/ten_manager/standalone/build/BUILD.gn +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright © 2025 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") -import("//build/ten_runtime/options.gni") - -if (ten_enable_ten_manager) { - ten_package_standalone_pkg("build_extension") { - pkg_template = "default_extension_cpp" - pkg_language = "cpp" - - deps = [ - "//core/src/ten_manager", - "//core/src/ten_runtime:upload_ten_runtime_system_package_to_server", - "//packages/core_extensions/default_extension_cpp:upload_default_extension_cpp_to_server", - ] - } -} - -ten_package_test_prepare_auxiliary_resources("build_test_files") { - resources = [ - "__init__.py", - "test_case.py", - ] -} - -group("build") { - deps = [ ":build_test_files" ] - - if (ten_enable_ten_manager) { - deps += [ ":build_extension" ] - } -} diff --git a/tests/ten_manager/standalone/build/__init__.py b/tests/ten_manager/standalone/build/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/ten_manager/standalone/build/test_case.py b/tests/ten_manager/standalone/build/test_case.py deleted file mode 100644 index 96627ae8e2..0000000000 --- a/tests/ten_manager/standalone/build/test_case.py +++ /dev/null @@ -1,69 +0,0 @@ -""" -Test standalone build. -""" - -import json -import os -import sys - - -def check_if_template_mode_works(base_path: str): - manifest_file = os.path.join(base_path, "manifest.json") - if not os.path.exists(manifest_file): - assert False, "The manifest file is not found." - - with open(manifest_file, "r") as f: - manifest_json = json.load(f) - if manifest_json["name"] != "build_extension": - assert False, "The package name is not build_extension." - - -def check_if_standalone_install_works(base_path: str): - deps_dir = os.path.join(base_path, ".ten/app") - if not os.path.exists(deps_dir): - assert False, "The .ten/app is not found." - - runtime_manifest = os.path.join( - deps_dir, "ten_packages/system/ten_runtime/manifest.json" - ) - if not os.path.exists(runtime_manifest): - assert False, "The manifest.json of ten_runtime is not found in deps." - - with open(runtime_manifest, "r") as f: - manifest_json = json.load(f) - if manifest_json["name"] != "ten_runtime": - assert False, "The package name is not ten_runtime." - - -def check_if_standalone_build_works(base_path: str): - out_dir = os.path.join(base_path, "out", sys.platform) - if not os.path.exists(out_dir): - assert False, "The out directory is not found." - - dirs = os.listdir(out_dir) - assert len(dirs) == 1 - - out_dir = os.path.join( - out_dir, dirs[0], "ten_packages/extension/build_extension/lib" - ) - if not os.path.exists(out_dir): - assert False, "The out directory is not found." - - found_output_lib = False - for f in os.listdir(out_dir): - if "build_extension" in f: - found_output_lib = True - break - - assert found_output_lib, "The output lib is not found." - - -def test_standalone_build(): - base_path = os.path.dirname(os.path.abspath(__file__)) - extension = os.path.join(base_path, "build_extension") - if not os.path.exists(extension): - assert False, "The extension is not found." - - check_if_template_mode_works(extension) - check_if_standalone_install_works(extension) - check_if_standalone_build_works(extension)