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