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/jspandafile/tests/quickfix/single_file/" 18 19test_js_files = [ 20 "base/index", 21 "patch/index", 22] 23 24foreach(file, test_js_files) { 25 es2abc_gen_abc("gen_${file}_abc") { 26 test_js = "${test_js_path}${file}.js" 27 test_abc = "$target_out_dir/single_file/${file}.abc" 28 29 # Only targets in this file can depend on this. 30 extra_visibility = [ ":*" ] 31 src_js = rebase_path(test_js) 32 dst_file = rebase_path(test_abc) 33 extra_args = [ 34 "--module", 35 "--merge-abc", 36 ] 37 38 in_puts = [ test_js ] 39 out_puts = [ test_abc ] 40 } 41} 42 43test_multi_files = [ 44 "quickfix/multi_file/base/index.js", 45 "quickfix/multi_file/base/module.js", 46 "quickfix/multi_file/patch/index.js", 47 "quickfix/multi_file/patch/module.js", 48] 49 50_test_js_file_name_ = [ 51 "base", 52 "patch", 53] 54 55_merge_file_raw_ = "//arkcompiler/ets_runtime/ecmascript/jspandafile/tests/quickfix/multi_file/merge.txt" 56 57foreach(filename, _test_js_file_name_) { 58 merge_file = "$target_out_dir/multi_file/${filename}.txt" 59 merge_file_prefix = "//arkcompiler/ets_runtime/ecmascript/jspandafile/tests/quickfix/multi_file/${filename}/" 60 61 action("gen_${filename}_merge_file") { 62 script = "//arkcompiler/ets_runtime/test/quickfix/generate_merge_file.py" 63 args = [ 64 "--input", 65 rebase_path(_merge_file_raw_), 66 "--output", 67 rebase_path(merge_file), 68 "--prefix", 69 rebase_path(merge_file_prefix), 70 ] 71 72 inputs = [ _merge_file_raw_ ] 73 outputs = [ merge_file ] 74 } 75 76 abc_path = "$target_out_dir/multi_file/${filename}/merge.abc" 77 78 es2abc_gen_abc("gen_${filename}_abc") { 79 extra_visibility = [ ":*" ] # Only targets in this file can depend on this. 80 extra_dependencies = [ ":gen_${filename}_merge_file" ] 81 src_js = "@" + rebase_path(merge_file) 82 dst_file = rebase_path(abc_path) 83 extra_args = [ 84 "--module", 85 "--merge-abc", 86 ] 87 88 in_puts = test_multi_files 89 out_puts = [ abc_path ] 90 } 91} 92 93module_output_path = "ets_runtime" 94 95host_unittest_action("JSPandaFileTest") { 96 module_out_path = module_output_path 97 98 sources = [ 99 # test file 100 "js_pandafile_executor_test.cpp", 101 "js_pandafile_manager_test.cpp", 102 "js_pandafile_test.cpp", 103 "panda_file_translator_test.cpp", 104 "quick_fix_test.cpp", 105 ] 106 107 configs = [ 108 "//arkcompiler/ets_runtime:ecma_test_config", 109 "$ark_root/assembler:arkassembler_public_config", 110 "$ark_root/libpandafile:arkfile_public_config", 111 ] 112 113 deps = [ 114 "$ark_third_party_root/icu/icu4c:shared_icui18n", 115 "$ark_third_party_root/icu/icu4c:shared_icuuc", 116 "$js_root:libark_jsruntime_test", 117 "//arkcompiler/runtime_core/assembler:libarkassembler_static", 118 ] 119 120 foreach(file, test_js_files) { 121 deps += [ ":gen_${file}_abc" ] 122 } 123 124 deps += [ 125 ":gen_base_abc", 126 ":gen_patch_abc", 127 ] 128 129 if (is_ohos && is_standard_system) { 130 test_abc_dir = "/data/test" 131 } else { 132 test_abc_dir = rebase_path(target_out_dir) 133 } 134 defines = [ "QUICKFIX_ABC_PATH=\"${test_abc_dir}/\"" ] 135 136 # hiviewdfx libraries 137 external_deps = hiviewdfx_ext_deps 138 external_deps += [ "zlib:libz" ] 139 deps += hiviewdfx_deps 140} 141 142group("unittest") { 143 testonly = true 144 145 # deps file 146 deps = [ ":JSPandaFileTest" ] 147} 148 149group("host_unittest") { 150 testonly = true 151 152 # deps file 153 deps = [ ":JSPandaFileTestAction" ] 154 155 if (is_mac) { 156 deps -= [ ":JSPandaFileTestAction" ] 157 } 158} 159