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 = "arkcompiler/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 "//arkcompiler/ets_runtime:libark_jsruntime_test", 75 "//arkcompiler/runtime_core/assembler:libarkassembler_static", 76 sdk_libc_secshared_dep, 77 ] 78 79 foreach(file, test_js_files) { 80 deps += [ ":gen_${file}_abc" ] 81 } 82 83 if (is_ohos && is_standard_system) { 84 test_abc_dir = "/data/test" 85 } else { 86 test_abc_dir = rebase_path(target_out_dir) 87 } 88 defines = [ "MODULE_ABC_PATH=\"${test_abc_dir}/\"" ] 89 90 # hiviewdfx libraries 91 external_deps = hiviewdfx_ext_deps 92 deps += hiviewdfx_deps 93 external_deps += [ "zlib:libz" ] 94} 95 96group("unittest") { 97 testonly = true 98 99 # deps file 100 deps = [ ":ModuleTest" ] 101} 102 103group("host_unittest") { 104 testonly = true 105 106 # deps file 107 deps = [ ":ModuleTestAction" ] 108 109 if (is_mac) { 110 deps -= [ ":ModuleTestAction" ] 111 } 112} 113