From 1b14f38342424102be12d0664803bb375b50f7e8 Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Sun, 6 Jul 2025 12:29:22 -0400 Subject: [PATCH 1/3] port to StandardPaths --- CMakeLists.txt | 4 ++-- src/hallelujah.cpp | 14 +++++++------- test/testhallelujah.cpp | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 170ad36..5c8e3af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.6.0) -project(fcitx5-hallelujah VERSION 5.0.2) +project(fcitx5-hallelujah VERSION 5.0.3) find_package(ECM 1.0.0 REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) @@ -12,7 +12,7 @@ option(ENABLE_TEST "Build Test" On) option(BUILD_DATA "Build data" On) find_package(Gettext REQUIRED) -find_package(Fcitx5Core 5.1.12 REQUIRED) +find_package(Fcitx5Core 5.1.13 REQUIRED) find_package(Fcitx5Module REQUIRED COMPONENTS Spell TestFrontend) find_package(PkgConfig REQUIRED) diff --git a/src/hallelujah.cpp b/src/hallelujah.cpp index 9241a46..55a9e3b 100644 --- a/src/hallelujah.cpp +++ b/src/hallelujah.cpp @@ -1,7 +1,7 @@ #include "hallelujah.h" #include #include -#include +#include #include #include #include @@ -286,8 +286,8 @@ void HallelujahEngine::reset(const InputMethodEntry &, } void HallelujahEngine::loadTrie() { - const auto &sp = fcitx::StandardPath::global(); - std::string trie_path = sp.locate(fcitx::StandardPath::Type::Data, + const auto &sp = fcitx::StandardPaths::global(); + std::string trie_path = sp.locate(fcitx::StandardPathsType::Data, "hallelujah/google_227800_words.bin"); if (trie_path.empty()) { throw std::runtime_error("Failed to load google_227800_words.bin"); @@ -296,9 +296,9 @@ void HallelujahEngine::loadTrie() { } void HallelujahEngine::loadWords() { - const auto &sp = fcitx::StandardPath::global(); + const auto &sp = fcitx::StandardPaths::global(); std::string words_path = - sp.locate(fcitx::StandardPath::Type::Data, "hallelujah/words.json"); + sp.locate(fcitx::StandardPathsType::Data, "hallelujah/words.json"); if (words_path.empty()) { throw std::runtime_error("Failed to load words.json"); } @@ -335,9 +335,9 @@ void HallelujahEngine::loadWords() { } void HallelujahEngine::loadPinyin() { - const auto &sp = fcitx::StandardPath::global(); + const auto &sp = fcitx::StandardPaths::global(); std::string pinyin_path = - sp.locate(fcitx::StandardPath::Type::Data, "hallelujah/cedict.json"); + sp.locate(fcitx::StandardPathsType::Data, "hallelujah/cedict.json"); if (pinyin_path.empty()) { throw std::runtime_error("Failed to load cedict.json"); } diff --git a/test/testhallelujah.cpp b/test/testhallelujah.cpp index f60b370..4dbb120 100644 --- a/test/testhallelujah.cpp +++ b/test/testhallelujah.cpp @@ -2,7 +2,7 @@ #include "testfrontend_public.h" #include #include -#include +#include #include #include #include @@ -64,7 +64,7 @@ void scheduleEvent(EventDispatcher *dispatcher, Instance *instance) { int main() { setupTestingEnvironment( TESTING_BINARY_DIR, {TESTING_BINARY_DIR "/src"}, - {TESTING_BINARY_DIR "/test", StandardPath::fcitxPath("pkgdatadir")}); + {TESTING_BINARY_DIR "/test", StandardPaths::fcitxPath("pkgdatadir")}); char arg0[] = "testhallelujah"; char arg1[] = "--disable=all"; char arg2[] = "--enable=testim,testfrontend,spell,hallelujah"; From aa0e830acf5948ef05cd8c0f76a113e9b14c0c9c Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Sun, 6 Jul 2025 14:51:53 -0400 Subject: [PATCH 2/3] blind try --- test/testhallelujah.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testhallelujah.cpp b/test/testhallelujah.cpp index 4dbb120..9894522 100644 --- a/test/testhallelujah.cpp +++ b/test/testhallelujah.cpp @@ -63,7 +63,7 @@ void scheduleEvent(EventDispatcher *dispatcher, Instance *instance) { int main() { setupTestingEnvironment( - TESTING_BINARY_DIR, {TESTING_BINARY_DIR "/src"}, + TESTING_BINARY_DIR, {"bin"}, {TESTING_BINARY_DIR "/test", StandardPaths::fcitxPath("pkgdatadir")}); char arg0[] = "testhallelujah"; char arg1[] = "--disable=all"; From c0ae0d05da221b1003a21b3123cc7d12e229a93f Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Sun, 6 Jul 2025 15:42:25 -0400 Subject: [PATCH 3/3] try fix test --- .github/workflows/ci.yml | 1 + test/CMakeLists.txt | 7 ------- test/addon/CMakeLists.txt | 2 -- test/inputmethod/CMakeLists.txt | 2 -- test/testdir.h.in | 6 ------ test/testhallelujah.cpp | 6 ------ 6 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 test/addon/CMakeLists.txt delete mode 100644 test/inputmethod/CMakeLists.txt delete mode 100644 test/testdir.h.in diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b5adf5..b79b050 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: container: archlinux:latest env: XDG_DATA_DIRS: /opt/fcitx/share # for test + FCITX_DATA_DIRS: /opt/fcitx/share/fcitx5/testing/addon:/opt/fcitx/share/fcitx5/testing steps: - name: Install dependencies run: pacman -Syu --noconfirm base-devel clang cmake ninja extra-cmake-modules fmt libuv marisa diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b1d6a8b..71959ca 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,10 +1,3 @@ -configure_file(testdir.h.in ${CMAKE_CURRENT_BINARY_DIR}/testdir.h @ONLY) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -add_subdirectory(addon) -add_subdirectory(inputmethod) - add_executable(testhallelujah testhallelujah.cpp) target_link_libraries(testhallelujah Fcitx5::Core Fcitx5::Module::TestFrontend) -add_dependencies(testhallelujah hallelujah copy-addon copy-im) add_test(NAME testhallelujah COMMAND testhallelujah) diff --git a/test/addon/CMakeLists.txt b/test/addon/CMakeLists.txt deleted file mode 100644 index e60d9f6..0000000 --- a/test/addon/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_custom_target(copy-addon DEPENDS hallelujah-addon.conf.in-fmt) -add_custom_command(TARGET copy-addon COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/src/hallelujah-addon.conf ${CMAKE_CURRENT_BINARY_DIR}/hallelujah.conf) diff --git a/test/inputmethod/CMakeLists.txt b/test/inputmethod/CMakeLists.txt deleted file mode 100644 index d71682d..0000000 --- a/test/inputmethod/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_custom_target(copy-im DEPENDS hallelujah.conf.in-fmt) -add_custom_command(TARGET copy-im COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/src/hallelujah.conf ${CMAKE_CURRENT_BINARY_DIR}/hallelujah.conf) diff --git a/test/testdir.h.in b/test/testdir.h.in deleted file mode 100644 index 1ec3884..0000000 --- a/test/testdir.h.in +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _TEST_TESTDIR_H_ -#define _TEST_TESTDIR_H_ - -#define TESTING_BINARY_DIR "@CMAKE_BINARY_DIR@" - -#endif // _TEST_TESTDIR_H_ diff --git a/test/testhallelujah.cpp b/test/testhallelujah.cpp index 9894522..5214964 100644 --- a/test/testhallelujah.cpp +++ b/test/testhallelujah.cpp @@ -1,9 +1,6 @@ -#include "testdir.h" #include "testfrontend_public.h" #include #include -#include -#include #include #include #include @@ -62,9 +59,6 @@ void scheduleEvent(EventDispatcher *dispatcher, Instance *instance) { } int main() { - setupTestingEnvironment( - TESTING_BINARY_DIR, {"bin"}, - {TESTING_BINARY_DIR "/test", StandardPaths::fcitxPath("pkgdatadir")}); char arg0[] = "testhallelujah"; char arg1[] = "--disable=all"; char arg2[] = "--enable=testim,testfrontend,spell,hallelujah";