1# Copyright (c) 2022-2025 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14import("//arkcompiler/ets_runtime/js_runtime_config.gni") 15import("//arkcompiler/ets_runtime/test/test_helper.gni") 16 17test_js_path = "//arkcompiler/ets_runtime/ecmascript/module/tests/module_test/" 18 19test_js_files = [ 20 "module_test_module_test_module", 21 "module_test_module_test_module_base", 22 "module_test_module_test_A", 23 "module_test_module_test_B", 24 "module_test_module_test_C", 25 "module_unexecute", 26 "module_unexecute_A", 27 "module_unexecute_B", 28 "module_unexecute_C", 29] 30 31foreach(file, test_js_files) { 32 es2abc_gen_abc("gen_${file}_abc") { 33 test_js = "${test_js_path}${file}.js" 34 test_abc = "$target_out_dir/${file}.abc" 35 36 # Only targets in this file can depend on this. 37 extra_visibility = [ ":*" ] 38 src_js = rebase_path(test_js) 39 dst_file = rebase_path(test_abc) 40 extra_args = [] 41 if (file == "module_test_module_test_A") { 42 extra_args += [ "--commonjs" ] 43 } else if (file == "module_unexecute_C") { 44 extra_args += [ "--commonjs" ] 45 extra_args += [ "--merge-abc" ] 46 } else { 47 extra_args += [ "--module" ] 48 extra_args += [ "--merge-abc" ] 49 } 50 in_puts = [ test_js ] 51 out_puts = [ test_abc ] 52 } 53} 54 55module_output_path = "ets_runtime" 56 57host_unittest_action("ModuleTest") { 58 module_out_path = module_output_path 59 60 sources = [ 61 # test file 62 "ecma_module_test.cpp", 63 "static_module_loader_test.cpp" 64 ] 65 66 if (!defined(run_with_qemu)) { 67 run_with_qemu = false 68 } 69 70 if (!run_with_qemu) { 71 sources += [ "module_snapshot_test.cpp" ] 72 } 73 74 configs = [ 75 "//arkcompiler/ets_runtime:ecma_test_config", 76 ] 77 78 if (ark_standalone_build || is_arkui_x) { 79 configs += [ 80 "$ark_root/assembler:arkassembler_public_config", 81 "$ark_root/libpandafile:arkfile_public_config", 82 ] 83 } 84 85 deps = [ 86 "$js_root:libark_jsruntime_test", 87 ] 88 89 foreach(file, test_js_files) { 90 deps += [ ":gen_${file}_abc" ] 91 } 92 93 if (is_ohos && is_standard_system) { 94 test_abc_dir = "/data/test" 95 } else { 96 test_abc_dir = rebase_path(target_out_dir) 97 } 98 defines = [ "MODULE_ABC_PATH=\"${test_abc_dir}/\"" ] 99 100 # hiviewdfx libraries 101 external_deps = hiviewdfx_ext_deps 102 deps += hiviewdfx_deps 103 external_deps += [ 104 "icu:shared_icui18n", 105 "icu:shared_icuuc", 106 "zlib:libz", 107 "runtime_core:libarkassembler_static", 108 ] 109 if (!ark_standalone_build && !is_arkui_x) { 110 external_deps += [ 111 "runtime_core:arkassembler_public_headers", 112 "runtime_core:arkfile_public_headers", 113 ] 114 } 115} 116 117group("unittest") { 118 testonly = true 119 120 # deps file 121 deps = [ ":ModuleTest" ] 122} 123 124group("host_unittest") { 125 testonly = true 126 127 # deps file 128 deps = [ ":ModuleTestAction" ] 129 130 if (is_mac) { 131 deps -= [ ":ModuleTestAction" ] 132 } 133} 134