14514f5e3Sopenharmony_ci# Copyright (c) 2022 Huawei Device Co., Ltd.
24514f5e3Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
34514f5e3Sopenharmony_ci# you may not use this file except in compliance with the License.
44514f5e3Sopenharmony_ci# You may obtain a copy of the License at
54514f5e3Sopenharmony_ci#
64514f5e3Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
74514f5e3Sopenharmony_ci#
84514f5e3Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
94514f5e3Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
104514f5e3Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114514f5e3Sopenharmony_ci# See the License for the specific language governing permissions and
124514f5e3Sopenharmony_ci# limitations under the License.
134514f5e3Sopenharmony_ci
144514f5e3Sopenharmony_ciimport("//arkcompiler/ets_runtime/js_runtime_config.gni")
154514f5e3Sopenharmony_ciimport("//arkcompiler/ets_runtime/test/test_helper.gni")
164514f5e3Sopenharmony_ci
174514f5e3Sopenharmony_citest_js_path = "//arkcompiler/ets_runtime/ecmascript/module/tests/module_test/"
184514f5e3Sopenharmony_ci
194514f5e3Sopenharmony_citest_js_files = [
204514f5e3Sopenharmony_ci  "module_test_module_test_module",
214514f5e3Sopenharmony_ci  "module_test_module_test_module_base",
224514f5e3Sopenharmony_ci  "module_test_module_test_A",
234514f5e3Sopenharmony_ci  "module_test_module_test_B",
244514f5e3Sopenharmony_ci  "module_test_module_test_C",
254514f5e3Sopenharmony_ci  "module_unexecute",
264514f5e3Sopenharmony_ci  "module_unexecute_A",
274514f5e3Sopenharmony_ci  "module_unexecute_B",
284514f5e3Sopenharmony_ci  "module_unexecute_C",
294514f5e3Sopenharmony_ci]
304514f5e3Sopenharmony_ci
314514f5e3Sopenharmony_ciforeach(file, test_js_files) {
324514f5e3Sopenharmony_ci  es2abc_gen_abc("gen_${file}_abc") {
334514f5e3Sopenharmony_ci    test_js = "${test_js_path}${file}.js"
344514f5e3Sopenharmony_ci    test_abc = "$target_out_dir/${file}.abc"
354514f5e3Sopenharmony_ci
364514f5e3Sopenharmony_ci    # Only targets in this file can depend on this.
374514f5e3Sopenharmony_ci    extra_visibility = [ ":*" ]
384514f5e3Sopenharmony_ci    src_js = rebase_path(test_js)
394514f5e3Sopenharmony_ci    dst_file = rebase_path(test_abc)
404514f5e3Sopenharmony_ci    extra_args = []
414514f5e3Sopenharmony_ci    if (file == "module_test_module_test_A") {
424514f5e3Sopenharmony_ci      extra_args += [ "--commonjs" ]
434514f5e3Sopenharmony_ci    } else if (file == "module_unexecute_C") {
444514f5e3Sopenharmony_ci      extra_args += [ "--commonjs" ]
454514f5e3Sopenharmony_ci      extra_args += [ "--merge-abc" ]
464514f5e3Sopenharmony_ci    } else {
474514f5e3Sopenharmony_ci      extra_args += [ "--module" ]
484514f5e3Sopenharmony_ci      extra_args += [ "--merge-abc" ]
494514f5e3Sopenharmony_ci    }
504514f5e3Sopenharmony_ci    in_puts = [ test_js ]
514514f5e3Sopenharmony_ci    out_puts = [ test_abc ]
524514f5e3Sopenharmony_ci  }
534514f5e3Sopenharmony_ci}
544514f5e3Sopenharmony_ci
554514f5e3Sopenharmony_cimodule_output_path = "arkcompiler/ets_runtime"
564514f5e3Sopenharmony_ci
574514f5e3Sopenharmony_cihost_unittest_action("ModuleTest") {
584514f5e3Sopenharmony_ci  module_out_path = module_output_path
594514f5e3Sopenharmony_ci
604514f5e3Sopenharmony_ci  sources = [
614514f5e3Sopenharmony_ci    # test file
624514f5e3Sopenharmony_ci    "ecma_module_test.cpp",
634514f5e3Sopenharmony_ci  ]
644514f5e3Sopenharmony_ci
654514f5e3Sopenharmony_ci  configs = [
664514f5e3Sopenharmony_ci    "//arkcompiler/ets_runtime:ecma_test_config",
674514f5e3Sopenharmony_ci    "$ark_root/assembler:arkassembler_public_config",
684514f5e3Sopenharmony_ci    "$ark_root/libpandafile:arkfile_public_config",
694514f5e3Sopenharmony_ci  ]
704514f5e3Sopenharmony_ci
714514f5e3Sopenharmony_ci  deps = [
724514f5e3Sopenharmony_ci    "$ark_third_party_root/icu/icu4c:shared_icui18n",
734514f5e3Sopenharmony_ci    "$ark_third_party_root/icu/icu4c:shared_icuuc",
744514f5e3Sopenharmony_ci    "//arkcompiler/ets_runtime:libark_jsruntime_test",
754514f5e3Sopenharmony_ci    "//arkcompiler/runtime_core/assembler:libarkassembler_static",
764514f5e3Sopenharmony_ci    sdk_libc_secshared_dep,
774514f5e3Sopenharmony_ci  ]
784514f5e3Sopenharmony_ci
794514f5e3Sopenharmony_ci  foreach(file, test_js_files) {
804514f5e3Sopenharmony_ci    deps += [ ":gen_${file}_abc" ]
814514f5e3Sopenharmony_ci  }
824514f5e3Sopenharmony_ci
834514f5e3Sopenharmony_ci  if (is_ohos && is_standard_system) {
844514f5e3Sopenharmony_ci    test_abc_dir = "/data/test"
854514f5e3Sopenharmony_ci  } else {
864514f5e3Sopenharmony_ci    test_abc_dir = rebase_path(target_out_dir)
874514f5e3Sopenharmony_ci  }
884514f5e3Sopenharmony_ci  defines = [ "MODULE_ABC_PATH=\"${test_abc_dir}/\"" ]
894514f5e3Sopenharmony_ci
904514f5e3Sopenharmony_ci  # hiviewdfx libraries
914514f5e3Sopenharmony_ci  external_deps = hiviewdfx_ext_deps
924514f5e3Sopenharmony_ci  deps += hiviewdfx_deps
934514f5e3Sopenharmony_ci  external_deps += [ "zlib:libz" ]
944514f5e3Sopenharmony_ci}
954514f5e3Sopenharmony_ci
964514f5e3Sopenharmony_cigroup("unittest") {
974514f5e3Sopenharmony_ci  testonly = true
984514f5e3Sopenharmony_ci
994514f5e3Sopenharmony_ci  # deps file
1004514f5e3Sopenharmony_ci  deps = [ ":ModuleTest" ]
1014514f5e3Sopenharmony_ci}
1024514f5e3Sopenharmony_ci
1034514f5e3Sopenharmony_cigroup("host_unittest") {
1044514f5e3Sopenharmony_ci  testonly = true
1054514f5e3Sopenharmony_ci
1064514f5e3Sopenharmony_ci  # deps file
1074514f5e3Sopenharmony_ci  deps = [ ":ModuleTestAction" ]
1084514f5e3Sopenharmony_ci
1094514f5e3Sopenharmony_ci  if (is_mac) {
1104514f5e3Sopenharmony_ci    deps -= [ ":ModuleTestAction" ]
1114514f5e3Sopenharmony_ci  }
1124514f5e3Sopenharmony_ci}
113