From 610616a58396dbfcac298c220af4a8a1077f1dbd Mon Sep 17 00:00:00 2001 From: luobohua Date: Tue, 2 Sep 2025 23:20:37 +0800 Subject: [PATCH] add warning log to output path Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICW2EB Change-Id: If786ba9f2d6ea06e29e969152b2e030bef2323b7 Signed-off-by: luobohua --- .../test-config/incorrect-include/expected.json | 2 +- ets2panda/test/unit/plugin/CMakeLists.txt | 10 +++++----- ets2panda/util/diagnostic/warning.yaml | 8 ++++++++ ets2panda/util/options.cpp | 7 ++++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ets2panda/test/tsconfig/test-config/incorrect-include/expected.json b/ets2panda/test/tsconfig/test-config/incorrect-include/expected.json index 8dd7ddc8c1..3b31e1fa13 100644 --- a/ets2panda/test/tsconfig/test-config/incorrect-include/expected.json +++ b/ets2panda/test/tsconfig/test-config/incorrect-include/expected.json @@ -1,5 +1,5 @@ { "returncode": 1, - "stdout": "Fatal error: Invalid ArkTsConfig: incorrect-include/arktsconfig.json\nArkTS config error: The 'include' must have array type\n", + "stdout": "Fatal error: Invalid ArkTsConfig: incorrect-include/arktsconfig.json\nWarning: Without cli --output argument, the output path is set with outDir in arktsconfig.json file '.abc'.\nArkTS config error: The 'include' must have array type\n", "stderr": "" } diff --git a/ets2panda/test/unit/plugin/CMakeLists.txt b/ets2panda/test/unit/plugin/CMakeLists.txt index 7ba38739e1..57e9786c86 100644 --- a/ets2panda/test/unit/plugin/CMakeLists.txt +++ b/ets2panda/test/unit/plugin/CMakeLists.txt @@ -174,7 +174,7 @@ foreach(TEST_DATA IN ITEMS ${PLUGIN_TESTS}) COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${PANDA_RUN_PREFIX} $ --plugins=${TEST_NAME} --arktsconfig=${ARKTSCONFIG} --extension=ets --ets-unnamed --output="${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.abc" - "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_STS_FILE}" > "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.out" + "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_STS_FILE}" 2>&1 | sed '/Warning: The output path/d' > "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.out" ) endif() if(${PLUGIN_MODE} STREQUAL ${EXECUTABLE_PLUGIN}) @@ -183,7 +183,7 @@ foreach(TEST_DATA IN ITEMS ${PLUGIN_TESTS}) LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${PANDA_RUN_PREFIX} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} $ --extension=ets --arktsconfig=${ARKTSCONFIG} --ets-unnamed --output="${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.abc" - "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_STS_FILE}" > "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.out" 2>&1 + "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_STS_FILE}" 2>&1 | sed '/Warning: The output path/d' > "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.out" ) endif() add_dependencies(es2panda-plugin-test-compile-${TEST_NAME} es2panda ${TEST_NAME} es2panda-lib) @@ -200,7 +200,7 @@ foreach(TEST_DATA IN ITEMS ${PLUGIN_TESTS}) COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${PANDA_RUN_PREFIX} $ ${RUNTIME_ARGUMENTS} "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.abc" ${ENTRY_POINT} - > "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}-runtime.out" + 2>&1 | sed '/Warning: The output path/d' > "${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}-runtime.out" ) add_dependencies(es2panda-plugin-test-runtime-${TEST_NAME} es2panda-plugin-test-compile-${TEST_NAME} ark es2panda-lib) add_dependencies(es2panda-plugin-test es2panda-plugin-test-runtime-${TEST_NAME}) @@ -230,8 +230,8 @@ foreach(TEST_DATA IN ITEMS ${PLUGIN_TESTS}) add_custom_target(update-es2panda-plugin-test-expected-${TEST_NAME} COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${PANDA_RUN_PREFIX} $ - --plugins=${TEST_NAME} --extension=ets --arktsconfig=${ARKTSCONFIG} --ets-unnamed "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_STS_FILE}" > - "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}-expected.txt") + --plugins=${TEST_NAME} --extension=ets --arktsconfig=${ARKTSCONFIG} --ets-unnamed "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_STS_FILE}" + 2>&1 | sed '/Warning: The output path/d' > "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}-expected.txt") else() add_custom_target(update-es2panda-plugin-test-expected-${TEST_NAME} COMMAND ${CMAKE_COMMAND} -E env diff --git a/ets2panda/util/diagnostic/warning.yaml b/ets2panda/util/diagnostic/warning.yaml index dcb80bf69a..6651366f52 100644 --- a/ets2panda/util/diagnostic/warning.yaml +++ b/ets2panda/util/diagnostic/warning.yaml @@ -25,6 +25,14 @@ warning: id: 4 message: "Boost Equality Statement. Change sides of binary expression." +- name: CLI_OUTPUT_OPTION + id: 177420 + message: "The output path is set with cli --output argument '{}' instead of outDir in arktsconfig.json file." + +- name: DEFAULT_OUTPUT + id: 33177 + message: "Without cli --output argument, the output path is set with outDir in arktsconfig.json file '{}'." + - name: DUPLICATE_EXPORT_ALIASES id: 73 message: "Duplicated export aliases for '{}'." diff --git a/ets2panda/util/options.cpp b/ets2panda/util/options.cpp index dbb5e1fbee..e4741d1b2c 100644 --- a/ets2panda/util/options.cpp +++ b/ets2panda/util/options.cpp @@ -190,8 +190,13 @@ bool Options::ParseInputOutput() diagnosticEngine_.LogDiagnostic(diagnostic::PROJ_COMP_WITH_OUTPUT, DiagnosticMessageParams {}); return false; } + diagnosticEngine_.LogDiagnostic(diagnostic::CLI_OUTPUT_OPTION, + util::DiagnosticMessageParams {util::StringView(GetOutput())}); } else { - SetOutput(ark::os::RemoveExtension(BaseName(SourceFileName())).append(".abc")); + std::string defaultOutput = ark::os::RemoveExtension(BaseName(SourceFileName())).append(".abc"); + SetOutput(defaultOutput); + diagnosticEngine_.LogDiagnostic(diagnostic::DEFAULT_OUTPUT, + util::DiagnosticMessageParams {util::StringView(defaultOutput)}); } return true; -- Gitee