13af6ab5fSopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd.
23af6ab5fSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
33af6ab5fSopenharmony_ci# you may not use this file except in compliance with the License.
43af6ab5fSopenharmony_ci# You may obtain a copy of the License at
53af6ab5fSopenharmony_ci#
63af6ab5fSopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
73af6ab5fSopenharmony_ci#
83af6ab5fSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
93af6ab5fSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
103af6ab5fSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
113af6ab5fSopenharmony_ci# See the License for the specific language governing permissions and
123af6ab5fSopenharmony_ci# limitations under the License.
133af6ab5fSopenharmony_ci
143af6ab5fSopenharmony_ciets2panda_add_gtest(ast_builder_test
153af6ab5fSopenharmony_ci    CPP_SOURCES ast_builder_test.cpp
163af6ab5fSopenharmony_ci)
173af6ab5fSopenharmony_ci
183af6ab5fSopenharmony_ciets2panda_add_gtest(es2panda_public_test
193af6ab5fSopenharmony_ci    CPP_SOURCES es2panda_public_test.cpp
203af6ab5fSopenharmony_ci)
213af6ab5fSopenharmony_ci
223af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_short_test
233af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_short_test.cpp
243af6ab5fSopenharmony_ci)
253af6ab5fSopenharmony_ci
263af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_private_protected_public_access_correct_test
273af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_private_protected_public_access_correct_test.cpp
283af6ab5fSopenharmony_ci)
293af6ab5fSopenharmony_ci
303af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_private_access_negative_test_1_4
313af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_private_access_negative_test_1_4.cpp
323af6ab5fSopenharmony_ci)
333af6ab5fSopenharmony_ci
343af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_private_access_negative_test_5_7
353af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_private_access_negative_test_5_7.cpp
363af6ab5fSopenharmony_ci)
373af6ab5fSopenharmony_ci
383af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_protected_access_correct_test
393af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_protected_access_correct_test.cpp
403af6ab5fSopenharmony_ci)
413af6ab5fSopenharmony_ci
423af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_protected_access_negative_test_1_3
433af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_protected_access_negative_test_1_3.cpp
443af6ab5fSopenharmony_ci)
453af6ab5fSopenharmony_ci
463af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_protected_access_negative_test_4_6
473af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_protected_access_negative_test_4_6.cpp
483af6ab5fSopenharmony_ci)
493af6ab5fSopenharmony_ci
503af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_reference_typeannotation_test
513af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_reference_typeannotation_test.cpp
523af6ab5fSopenharmony_ci)
533af6ab5fSopenharmony_ci
543af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_identifier_has_variable_test
553af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_identifier_has_variable_test.cpp
563af6ab5fSopenharmony_ci)
573af6ab5fSopenharmony_ci
583af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_variable_has_enclosing_scope_test
593af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_variable_has_enclosing_scope_test.cpp
603af6ab5fSopenharmony_ci)
613af6ab5fSopenharmony_ci
623af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_variable_has_scope_test
633af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_variable_has_scope_test.cpp
643af6ab5fSopenharmony_ci)
653af6ab5fSopenharmony_ci
663af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_every_child_has_valid_parent_test
673af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_every_child_has_valid_parent_test.cpp
683af6ab5fSopenharmony_ci)
693af6ab5fSopenharmony_ci
703af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_check_infinite_loop_test
713af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_check_infinite_loop_test.cpp
723af6ab5fSopenharmony_ci)
733af6ab5fSopenharmony_ci
743af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_check_normal_loop_test
753af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_check_normal_loop_test.cpp
763af6ab5fSopenharmony_ci)
773af6ab5fSopenharmony_ci
783af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_check_abstract_call_test
793af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_check_abstract_call_test.cpp
803af6ab5fSopenharmony_ci)
813af6ab5fSopenharmony_ci
823af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_getter_setter_test
833af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_getter_setter_test.cpp
843af6ab5fSopenharmony_ci)
853af6ab5fSopenharmony_ci
863af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_getter_setter_neg_test
873af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_getter_setter_neg_test.cpp
883af6ab5fSopenharmony_ci)
893af6ab5fSopenharmony_ci
903af6ab5fSopenharmony_ciets2panda_add_gtest(ast_verifier_check_scope_declaration_test
913af6ab5fSopenharmony_ci    CPP_SOURCES ast_verifier_check_scope_declaration_test.cpp
923af6ab5fSopenharmony_ci)
933af6ab5fSopenharmony_ci
943af6ab5fSopenharmony_cipanda_add_library(e2p_test_plugin SHARED e2p_test_plugin.c)
953af6ab5fSopenharmony_cipanda_target_include_directories(e2p_test_plugin
963af6ab5fSopenharmony_ci    PRIVATE "${ES2PANDA_PATH}"
973af6ab5fSopenharmony_ci    PRIVATE ${OUTPUT_DIR}
983af6ab5fSopenharmony_ci)
993af6ab5fSopenharmony_cipanda_target_link_libraries(e2p_test_plugin es2panda-public)
1003af6ab5fSopenharmony_ci
1013af6ab5fSopenharmony_ci
1023af6ab5fSopenharmony_cipanda_add_library(e2p_test_plugin_dump_json SHARED e2p_test_plugin_dump_json.c)
1033af6ab5fSopenharmony_cipanda_target_include_directories(e2p_test_plugin_dump_json
1043af6ab5fSopenharmony_ci    PRIVATE "${ES2PANDA_PATH}"
1053af6ab5fSopenharmony_ci    PRIVATE ${OUTPUT_DIR}
1063af6ab5fSopenharmony_ci)
1073af6ab5fSopenharmony_cipanda_target_link_libraries(e2p_test_plugin_dump_json es2panda-public)
1083af6ab5fSopenharmony_ci
1093af6ab5fSopenharmony_ci
1103af6ab5fSopenharmony_cipanda_add_library(e2p_test_plugin_ets_src SHARED e2p_test_plugin_ets_src.c)
1113af6ab5fSopenharmony_cipanda_target_include_directories(e2p_test_plugin_ets_src
1123af6ab5fSopenharmony_ci    PRIVATE "${ES2PANDA_PATH}"
1133af6ab5fSopenharmony_ci    PRIVATE ${OUTPUT_DIR}
1143af6ab5fSopenharmony_ci)
1153af6ab5fSopenharmony_cipanda_target_link_libraries(e2p_test_plugin_ets_src es2panda-public)
1163af6ab5fSopenharmony_ci
1173af6ab5fSopenharmony_ci
1183af6ab5fSopenharmony_cipanda_add_library(e2p_test_plugin_is SHARED e2p_test_plugin_is.c)
1193af6ab5fSopenharmony_cipanda_target_include_directories(e2p_test_plugin_is
1203af6ab5fSopenharmony_ci    PRIVATE "${ES2PANDA_PATH}"
1213af6ab5fSopenharmony_ci    PRIVATE ${OUTPUT_DIR}
1223af6ab5fSopenharmony_ci)
1233af6ab5fSopenharmony_cipanda_target_link_libraries(e2p_test_plugin_is es2panda-public)
1243af6ab5fSopenharmony_ci
1253af6ab5fSopenharmony_ci
1263af6ab5fSopenharmony_ciadd_custom_target(es2panda-plugin-test
1273af6ab5fSopenharmony_ci  COMMENT "Test es2panda plugin functionality"
1283af6ab5fSopenharmony_ci
1293af6ab5fSopenharmony_ci  COMMAND ${CMAKE_COMMAND} -E env
1303af6ab5fSopenharmony_ci    LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> --plugins=e2p_test_plugin
1313af6ab5fSopenharmony_ci    --extension=sts "${CMAKE_CURRENT_SOURCE_DIR}/t.sts" > "${CMAKE_CURRENT_BINARY_DIR}/plugin_test.out"
1323af6ab5fSopenharmony_ci  COMMAND ${CMAKE_COMMAND} -E compare_files
1333af6ab5fSopenharmony_ci    "${CMAKE_CURRENT_BINARY_DIR}/plugin_test.out" "${CMAKE_CURRENT_SOURCE_DIR}/plugin_test-expected.txt"
1343af6ab5fSopenharmony_ci
1353af6ab5fSopenharmony_ci  COMMAND ${CMAKE_COMMAND} -E env
1363af6ab5fSopenharmony_ci    LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> --plugins=e2p_test_plugin_dump_json
1373af6ab5fSopenharmony_ci    "${CMAKE_CURRENT_SOURCE_DIR}/t.sts" > "${CMAKE_CURRENT_BINARY_DIR}/e2p_test_plugin_dump_json.out"
1383af6ab5fSopenharmony_ci  COMMAND ${CMAKE_COMMAND} -E compare_files
1393af6ab5fSopenharmony_ci    "${CMAKE_CURRENT_BINARY_DIR}/e2p_test_plugin_dump_json.out" "${CMAKE_CURRENT_SOURCE_DIR}/e2p_test_plugin_dump_json-expected.txt"
1403af6ab5fSopenharmony_ci
1413af6ab5fSopenharmony_ci  COMMAND ${CMAKE_COMMAND} -E env
1423af6ab5fSopenharmony_ci    LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> --plugins=e2p_test_plugin_ets_src
1433af6ab5fSopenharmony_ci    "${CMAKE_CURRENT_SOURCE_DIR}/t.sts" > "${CMAKE_CURRENT_BINARY_DIR}/e2p_test_plugin_ets_src.out"
1443af6ab5fSopenharmony_ci  COMMAND ${CMAKE_COMMAND} -E compare_files
1453af6ab5fSopenharmony_ci    "${CMAKE_CURRENT_BINARY_DIR}/e2p_test_plugin_ets_src.out" "${CMAKE_CURRENT_SOURCE_DIR}/e2p_test_plugin_ets_src-expected.txt"
1463af6ab5fSopenharmony_ci
1473af6ab5fSopenharmony_ci  COMMAND ${CMAKE_COMMAND} -E env
1483af6ab5fSopenharmony_ci    LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> --plugins=e2p_test_plugin_is
1493af6ab5fSopenharmony_ci    "${CMAKE_CURRENT_SOURCE_DIR}/t.sts" > "${CMAKE_CURRENT_BINARY_DIR}/e2p_test_plugin_is.out"
1503af6ab5fSopenharmony_ci  COMMAND ${CMAKE_COMMAND} -E compare_files
1513af6ab5fSopenharmony_ci    "${CMAKE_CURRENT_BINARY_DIR}/e2p_test_plugin_is.out" "${CMAKE_CURRENT_SOURCE_DIR}/e2p_test_plugin_is-expected.txt"
1523af6ab5fSopenharmony_ci)
1533af6ab5fSopenharmony_ci
1543af6ab5fSopenharmony_ci
1553af6ab5fSopenharmony_ciadd_dependencies(es2panda-plugin-test es2panda e2p_test_plugin e2p_test_plugin_dump_json e2p_test_plugin_ets_src e2p_test_plugin_is)
1563af6ab5fSopenharmony_ciadd_dependencies(es2panda_tests es2panda-plugin-test)
157