• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  if (!defined(run_with_qemu)) {
108    run_with_qemu = false
109  }
110
111  if (!run_with_qemu) {
112    sources += [ "js_pandafile_snapshot_test.cpp" ]
113  }
114
115  configs = [
116    "//arkcompiler/ets_runtime:ecma_test_config",
117  ]
118
119  if (ark_standalone_build || is_arkui_x) {
120    configs += [
121      "$ark_root/assembler:arkassembler_public_config",
122      "$ark_root/libpandafile:arkfile_public_config",
123    ]
124  }
125
126  deps = [
127    "$js_root:libark_jsruntime_test",
128  ]
129
130  foreach(file, test_js_files) {
131    deps += [ ":gen_${file}_abc" ]
132  }
133
134  deps += [
135    ":gen_base_abc",
136    ":gen_patch_abc",
137  ]
138
139  if (is_ohos && is_standard_system) {
140    test_abc_dir = "/data/test"
141  } else {
142    test_abc_dir = rebase_path(target_out_dir)
143  }
144  defines = [ "QUICKFIX_ABC_PATH=\"${test_abc_dir}/\"" ]
145
146  # hiviewdfx libraries
147  external_deps = hiviewdfx_ext_deps
148  external_deps += [
149    "icu:shared_icui18n",
150    "icu:shared_icuuc",
151    "zlib:libz",
152    "runtime_core:libarkassembler_static",
153  ]
154  if (!ark_standalone_build && !is_arkui_x) {
155    external_deps += [
156      "runtime_core:arkassembler_public_headers",
157      "runtime_core:arkfile_public_headers",
158    ]
159  }
160  deps += hiviewdfx_deps
161}
162
163group("unittest") {
164  testonly = true
165
166  # deps file
167  deps = [ ":JSPandaFileTest" ]
168}
169
170group("host_unittest") {
171  testonly = true
172
173  # deps file
174  deps = [ ":JSPandaFileTestAction" ]
175
176  if (is_mac) {
177    deps -= [ ":JSPandaFileTestAction" ]
178  }
179}
180