• 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/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]
26
27foreach(file, test_js_files) {
28  es2abc_gen_abc("gen_${file}_abc") {
29    test_js = "${test_js_path}${file}.js"
30    test_abc = "$target_out_dir/${file}.abc"
31
32    # Only targets in this file can depend on this.
33    extra_visibility = [ ":*" ]
34    src_js = rebase_path(test_js)
35    dst_file = rebase_path(test_abc)
36    extra_args = []
37    if (file == "module_test_module_test_A") {
38      extra_args += [ "--commonjs" ]
39    } else {
40      extra_args += [ "--module" ]
41      extra_args += [ "--merge-abc" ]
42    }
43    in_puts = [ test_js ]
44    out_puts = [ test_abc ]
45  }
46}
47
48module_output_path = "arkcompiler/ets_runtime"
49
50host_unittest_action("ModuleTest") {
51  module_out_path = module_output_path
52
53  sources = [
54    # test file
55    "ecma_module_test.cpp",
56  ]
57
58  configs = [
59    "//arkcompiler/ets_runtime:ecma_test_config",
60    "$ark_root/assembler:arkassembler_public_config",
61    "$ark_root/libpandafile:arkfile_public_config",
62  ]
63
64  deps = [
65    "$ark_third_party_root/icu/icu4c:shared_icui18n",
66    "$ark_third_party_root/icu/icu4c:shared_icuuc",
67    "//arkcompiler/ets_runtime:libark_jsruntime_test",
68    "//arkcompiler/runtime_core/assembler:libarkassembler_static",
69    sdk_libc_secshared_dep,
70  ]
71
72  foreach(file, test_js_files) {
73    deps += [ ":gen_${file}_abc" ]
74  }
75
76  if (is_ohos && is_standard_system) {
77    test_abc_dir = "/data/test"
78  } else {
79    test_abc_dir = rebase_path(target_out_dir)
80  }
81  defines = [ "MODULE_ABC_PATH=\"${test_abc_dir}/\"" ]
82
83  # hiviewdfx libraries
84  external_deps = hiviewdfx_ext_deps
85  deps += hiviewdfx_deps
86}
87
88group("unittest") {
89  testonly = true
90
91  # deps file
92  deps = [ ":ModuleTest" ]
93}
94
95group("host_unittest") {
96  testonly = true
97
98  # deps file
99  deps = [ ":ModuleTestAction" ]
100
101  if (is_mac) {
102    deps -= [ ":ModuleTestAction" ]
103  }
104}
105