1# Copyright (c) 2022 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 ] 64 65 configs = [ 66 "//arkcompiler/ets_runtime:ecma_test_config", 67 "$ark_root/assembler:arkassembler_public_config", 68 "$ark_root/libpandafile:arkfile_public_config", 69 ] 70 71 deps = [ 72 "$ark_third_party_root/icu/icu4c:shared_icui18n", 73 "$ark_third_party_root/icu/icu4c:shared_icuuc", 74 "$js_root:libark_jsruntime_test", 75 "//arkcompiler/runtime_core/assembler:libarkassembler_static", 76 ] 77 78 foreach(file, test_js_files) { 79 deps += [ ":gen_${file}_abc" ] 80 } 81 82 if (is_ohos && is_standard_system) { 83 test_abc_dir = "/data/test" 84 } else { 85 test_abc_dir = rebase_path(target_out_dir) 86 } 87 defines = [ "MODULE_ABC_PATH=\"${test_abc_dir}/\"" ] 88 89 # hiviewdfx libraries 90 external_deps = hiviewdfx_ext_deps 91 deps += hiviewdfx_deps 92 external_deps += [ "zlib:libz" ] 93} 94 95group("unittest") { 96 testonly = true 97 98 # deps file 99 deps = [ ":ModuleTest" ] 100} 101 102group("host_unittest") { 103 testonly = true 104 105 # deps file 106 deps = [ ":ModuleTestAction" ] 107 108 if (is_mac) { 109 deps -= [ ":ModuleTestAction" ] 110 } 111} 112