• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2024 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/runtime_core/ark_config.gni")
15import("$ark_root/tests/test_helper.gni")
16import("$build_root/config/components/ets_frontend/es2abc_config.gni")
17
18abc2prog_test_configs = [
19  "$ark_root:ark_config",
20  "$ark_root/assembler:arkassembler_public_config",
21  "$ark_root/libpandabase:arkbase_public_config",
22  "$ark_root/libpandafile:arkfile_public_config",
23]
24
25abc2prog_test_deps = [
26  "$ark_root/abc2program:abc2program",
27  "$ark_root/assembler:libarkassembler_static",
28  "$ark_root/libpandabase:libarkbase_static",
29  "$ark_root/libpandafile:libarkfile_static",
30]
31
32test_ts_dir = "//arkcompiler/runtime_core/abc2program/tests/ts/"
33test_column_number_dir =
34    "//arkcompiler/runtime_core/abc2program/tests/ts/release-column-number/"
35test_line_number_dir =
36    "//arkcompiler/runtime_core/abc2program/tests/ts/release-line-number/"
37test_json_dir = "//arkcompiler/runtime_core/abc2program/tests/json/"
38
39abc2prog_test_release_line_number_files = [
40  "InvalidOpcode",
41  "CommonSyntax",
42  "TsNewFeatrueSyntax",
43]
44
45foreach(file, abc2prog_test_release_line_number_files) {
46  es2abc_gen_abc("gen_${file}_abc") {
47    test_ts = "${test_line_number_dir}${file}.ts"
48    test_abc = "$target_out_dir/${file}.abc"
49
50    src_js = rebase_path(test_ts)
51    dst_file = rebase_path(test_abc)
52    extra_args = [ "--module" ]
53    in_puts = [ test_ts ]
54    out_puts = [ test_abc ]
55  }
56}
57
58abc2prog_test_release_column_number_files = [
59  "ReleaseEnableColumnNumberCallargs",
60  "ReleaseEnableColumnNumberCallthis",
61]
62
63foreach(file, abc2prog_test_release_column_number_files) {
64  es2abc_gen_abc("gen_${file}_abc") {
65    test_ts = "${test_column_number_dir}${file}.ts"
66    test_abc = "$target_out_dir/${file}.abc"
67
68    src_js = rebase_path(test_ts)
69    dst_file = rebase_path(test_abc)
70    extra_args = [
71      "--enable-release-column",
72      "--module",
73    ]
74    in_puts = [ test_ts ]
75    out_puts = [ test_abc ]
76  }
77}
78
79abc2prog_test_ts_files = [
80  "HelloWorld",
81  "Annotations",
82  "etsImplements",
83]
84
85foreach(file, abc2prog_test_ts_files) {
86  es2abc_gen_abc("gen_${file}_abc") {
87    test_ts = "${test_ts_dir}${file}.ts"
88    test_abc = "$target_out_dir/${file}.abc"
89
90    src_js = rebase_path(test_ts)
91    dst_file = rebase_path(test_abc)
92    extra_args = [ "--module" ]
93    if (file == "Annotations") {
94      extra_args += [ "--enable-annotations" ]
95    } else if (file == "etsImplements") {
96      extra_args += [ "--enable-ets-implements" ]
97    }
98    in_puts = [ test_ts ]
99    out_puts = [ test_abc ]
100  }
101}
102
103abc2prog_debug_test_ts_files = [ "HelloWorld" ]
104
105foreach(file, abc2prog_debug_test_ts_files) {
106  es2abc_gen_abc("gen_${file}_debug_abc") {
107    test_ts = "${test_ts_dir}${file}.ts"
108    test_abc = "$target_out_dir/${file}Debug.abc"
109
110    src_js = rebase_path(test_ts)
111    dst_file = rebase_path(test_abc)
112    extra_args = [
113      "--debug",
114      "--module",
115    ]
116    in_puts = [ test_ts ]
117    out_puts = [ test_abc ]
118  }
119}
120
121abc2prog_test_json_files = [ "JsonTest" ]
122
123foreach(file, abc2prog_test_json_files) {
124  es2abc_gen_abc("gen_${file}_abc") {
125    test_json = "${test_json_dir}${file}.json"
126    test_abc = "$target_out_dir/${file}.abc"
127
128    src_js = rebase_path(test_json)
129    dst_file = rebase_path(test_abc)
130    extra_args = [
131      "--module",
132      "--merge-abc",
133    ]
134    in_puts = [ test_json ]
135    out_puts = [ test_abc ]
136  }
137}
138
139abc2prog_include_dirs = [
140  "$ark_root/abc2program",
141  "$ark_root/assembler",
142  "$target_gen_dir",
143  "$target_gen_dir/../",
144  "$target_gen_dir/../../assembler",
145]
146
147script_sources = [
148  "cpp_sources/abc2program_test_utils.cpp",
149  "cpp_sources/hello_world_test.cpp",
150  "cpp_sources/release_column_number.cpp",
151  "cpp_sources/release_line_number.cpp",
152  "cpp_sources/etsImplements_test.cpp",
153]
154
155host_unittest_action("Abc2ProgScriptTest") {
156  module_out_path = module_output_path
157  sources = script_sources
158  include_dirs = abc2prog_include_dirs
159  configs = abc2prog_test_configs
160  external_deps = [ sdk_libc_secshared_dep ]
161  deps = abc2prog_test_deps
162  test_abc_dir = rebase_path(target_out_dir)
163  test_abc_dump_dir = rebase_path(test_ts_dir)
164  defines = [
165    "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"",
166    "GRAPH_TEST_ABC_DUMP_DIR=\"${test_abc_dump_dir}/\"",
167  ]
168
169  foreach(file, abc2prog_test_ts_files) {
170    deps += [ ":gen_${file}_abc" ]
171  }
172  foreach(file, abc2prog_debug_test_ts_files) {
173    deps += [ ":gen_${file}_debug_abc" ]
174  }
175  foreach(file, abc2prog_test_json_files) {
176    deps += [ ":gen_${file}_abc" ]
177  }
178  foreach(file, abc2prog_test_release_column_number_files) {
179    deps += [ ":gen_${file}_abc" ]
180  }
181  foreach(file, abc2prog_test_release_line_number_files) {
182    deps += [ ":gen_${file}_abc" ]
183  }
184}
185
186action("gen_filesinfo_action") {
187  script = "handle_fileinfo.py"
188
189  inputs = [ "sourceLang/filesInfo.txt" ]
190  outputs = [ "${target_out_dir}/sourceLang/filesInfo.txt" ]
191  args = [
192    rebase_path("sourceLang/filesInfo.txt"),
193    rebase_path("${target_out_dir}/sourceLang/filesInfo.txt"),
194    rebase_path("./"),
195  ]
196}
197
198es2abc_gen_abc("gen_sourceLang_abc") {
199  test_abc = "$target_out_dir/sourceLang.abc"
200  fileinfo_path = rebase_path("${target_out_dir}/sourceLang/filesInfo.txt")
201  src_js = "@${fileinfo_path}"
202  dst_file = rebase_path(test_abc)
203  extra_args = [
204    "--module",
205    "--merge-abc",
206    "--enable-annotations",
207  ]
208  out_puts = [ test_abc ]
209}
210
211host_unittest_action("Abc2ProgSourceLangTest") {
212  module_out_path = module_output_path
213  sources = [ "cpp_sources/sourceLang_test.cpp" ]
214  include_dirs = abc2prog_include_dirs
215  configs = abc2prog_test_configs
216  external_deps = [ sdk_libc_secshared_dep ]
217  deps = abc2prog_test_deps
218  test_abc_dir = rebase_path(target_out_dir)
219  test_abc_dump_dir = rebase_path(test_ts_dir)
220  defines = [
221    "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"",
222    "GRAPH_TEST_ABC_DUMP_DIR=\"${test_abc_dump_dir}/\"",
223  ]
224
225  deps += [
226    ":gen_filesinfo_action",
227    ":gen_sourceLang_abc",
228  ]
229}
230
231group("host_unittest") {
232  testonly = true
233  deps = [
234    ":Abc2ProgScriptTestAction",
235    ":Abc2ProgSourceLangTestAction",
236  ]
237}
238