`vendor/MetasequoiaImeEngine` submodule 改为 `engine/` 目录,导入的是 product-lock.json 原本钉住的提交 c810d201,逐文件核对过 blob,因此这是一次 搬迁而不是引擎升级。引擎自己的嵌套 submodule(googlepinyinime-rev、utfcpp、 miniaudio)按各自 gitlink 一并展开,来源与提交见 engine/UPSTREAM.md。 Windows 专门化裁掉了不属于本产品的部分:whisper.cpp 与本地推理 provider、 macOS 示例宿主、整个 dictionary/ 建库流水线、上游 CI 与 release-please 配置。 词库仍按 product-lock.json 在构建时取发布产物。 引擎不再进 product-lock.json:没有 gitlink 就没有可比对的东西,锁里写一个上游 commit 等于宣称这棵树仍等于上游,而第一个 Windows 专门化改动落地时这句话就假了。 verify-contracts / verify-checkout 随之移除,verify-published 保留。 CI 与工具链:引擎源码并入根 scripts/format.sh(删掉引擎自己的那份,避免两套排除 列表分叉);引擎 voice.yml 里的 silero_vad.onnx 摘要校验移到本仓 lock job; engine-bump-triage 工作流与其测试删除;gitsubmodule 的 dependabot 频率由 daily 改为 monthly。 README、README.en、AGENTS.md、CONTRIBUTING、docs/product-release.md 及各子目录 文档同步说明新的位置与边界。
75 lines
2.8 KiB
C++
75 lines
2.8 KiB
C++
#include "tests/includes/test_framework.h"
|
|
#include "tests/includes/test_utf8_path.h"
|
|
|
|
#include "engine/core/data_path.h"
|
|
#include "engine/user_dictionary/user_dictionary_journal.h"
|
|
|
|
#include <windows.h>
|
|
|
|
#include <filesystem>
|
|
#include <string>
|
|
#include <system_error>
|
|
|
|
namespace
|
|
{
|
|
constexpr const wchar_t *kChineseDirectory = L"陆傲天";
|
|
} // namespace
|
|
|
|
// Narrow strings in this repo are UTF-8, but std::filesystem converts narrow strings through the
|
|
// system ANSI code page. The two only agree on ASCII, so every path that crosses the narrow boundary
|
|
// has to go through these helpers. This pins that difference down so the reason the helpers exist
|
|
// stays visible: path::string() does not merely mangle a Chinese path, it throws.
|
|
TEST_CASE(filesystem_narrow_conversions_are_utf8_not_ansi)
|
|
{
|
|
const std::filesystem::path path = std::filesystem::path(LR"(C:\tmp)") / kChineseDirectory / L"msime_user.db";
|
|
|
|
// 陆 U+9646, 傲 U+50B2, 天 U+5929 in UTF-8.
|
|
const std::string expected = "C:\\tmp\\\xE9\x99\x86\xE5\x82\xB2\xE5\xA4\xA9\\msime_user.db";
|
|
REQUIRE_EQ(test::Utf8(path), expected);
|
|
|
|
// The round trip has to be lossless, otherwise a path handed to an engine API cannot come back.
|
|
REQUIRE_EQ(metasequoia::path_from_utf8(test::Utf8(path).c_str()), path);
|
|
|
|
// path::string() is not an alternative spelling of the above: it either produces different bytes
|
|
// or, on a code page that cannot represent the characters at all, throws. Both are failures, and
|
|
// a throw here is what fastfailed the replay tool during upgrades.
|
|
bool matched_utf8 = false;
|
|
try
|
|
{
|
|
matched_utf8 = (path.string() == expected);
|
|
}
|
|
catch (const std::exception &)
|
|
{
|
|
matched_utf8 = false;
|
|
}
|
|
if (GetACP() != CP_UTF8)
|
|
{
|
|
REQUIRE(!matched_utf8);
|
|
}
|
|
}
|
|
|
|
// The journal API is the one the replay tool drives, and it takes its paths as UTF-8. Exercised
|
|
// in-process here so a regression in the library is caught even if the tool around it is fine.
|
|
TEST_CASE(user_dictionary_journal_round_trips_under_non_ascii_path)
|
|
{
|
|
namespace fs = std::filesystem;
|
|
const fs::path unique_root =
|
|
fs::temp_directory_path() / (L"msime-journal-test-" + std::to_wstring(GetCurrentProcessId()));
|
|
|
|
std::error_code ec;
|
|
fs::remove_all(unique_root, ec);
|
|
|
|
const fs::path data_dir = unique_root / kChineseDirectory / L"metasequoiaime";
|
|
fs::create_directories(data_dir, ec);
|
|
REQUIRE(!ec);
|
|
|
|
const std::string user_db = test::Utf8(data_dir / L"msime_user.db");
|
|
REQUIRE(user_dictionary::ensure_user_database(user_db));
|
|
REQUIRE(fs::exists(data_dir / L"msime_user.db"));
|
|
|
|
// Opening the database it just created must work through the same UTF-8 spelling.
|
|
REQUIRE(user_dictionary::ensure_user_database(user_db));
|
|
|
|
fs::remove_all(unique_root, ec);
|
|
}
|