mirror of
https://github.com/baketnk/frame-yap.git
synced 2026-10-06 05:00:04 +02:00
Add safe transcription errors and opt-in private debug logging
This commit is contained in:
1 parent
29f3729df7
commit
6592e1af1c
21 files changed
+720
-65
No files matched your search
+41
-2
@@ -28,16 +28,55 @@ int main(int argc, char** argv) {
|
||||
::setenv("XDG_CONFIG_HOME", dir.c_str(), 1);
|
||||
assert(load_config(path).buttons.empty());
|
||||
assert(!load_config(path).experimental_input_priority);
|
||||
assert(!load_config(path).advanced_debug);
|
||||
assert(load_config(path).wrist.width == .30f);
|
||||
auto example = load_config(std::filesystem::path(argv[1]) / "config.example.json");
|
||||
assert(example.buttons.at("ptt") == "/user/hand/right/input/x");
|
||||
assert(example.font.empty());
|
||||
assert(!example.experimental_input_priority);
|
||||
assert(!example.advanced_debug);
|
||||
assert(example.wrist.y == .18f && example.wrist.z == .089f);
|
||||
std::filesystem::create_directories(path.parent_path());
|
||||
put(path, R"({"input_priority":"experimental"})");
|
||||
assert(save_advanced_debug(path, true));
|
||||
assert(load_config(path).advanced_debug);
|
||||
assert(get(path).find("\"advanced_debug\":true") != std::string::npos);
|
||||
assert(save_advanced_debug(path, false));
|
||||
assert(!load_config(path).advanced_debug);
|
||||
for (const auto* invalid : {R"({"advanced_debug":"true"})", R"({"advanced_debug":0})",
|
||||
R"({"advanced_debug":null})", R"({"advanced_debug":[]})"}) {
|
||||
put(path, invalid);
|
||||
fails([&] { load_config(path); });
|
||||
assert(!save_advanced_debug(path, true));
|
||||
assert(get(path) == invalid);
|
||||
}
|
||||
put(path, R"({"font":"escaped \u0061 and \"quotes\"","input_priority":"experimental","wrist":{"y":0.21},"theme":{"ink":"#123ABC"},"buttons":{"enter":""}})");
|
||||
const auto customized = get(path);
|
||||
assert(save_advanced_debug(path, true));
|
||||
assert(load_config(path).advanced_debug);
|
||||
assert(get(path).find(customized.substr(1, customized.size() - 2)) != std::string::npos);
|
||||
assert(save_advanced_debug(path, false));
|
||||
assert(!load_config(path).advanced_debug);
|
||||
auto before = get(path);
|
||||
assert(save_advanced_debug(path, false) && get(path) == before);
|
||||
put(path, R"({"advanced_debug":false, "font":"kept"})");
|
||||
assert(save_advanced_debug(path, true));
|
||||
assert(get(path) == R"({"advanced_debug":true, "font":"kept"})");
|
||||
before = get(path);
|
||||
put(path, R"({"font":"bad","font":"duplicate"})");
|
||||
assert(!save_advanced_debug(path, true));
|
||||
assert(get(path) == R"({"font":"bad","font":"duplicate"})");
|
||||
put(path, before);
|
||||
auto link = dir / "linked-config";
|
||||
std::filesystem::create_symlink(path, link);
|
||||
assert(!save_advanced_debug(link, false));
|
||||
assert(get(path) == before);
|
||||
std::filesystem::remove(link);
|
||||
put(path, R"({"font":")" + std::string(4090, 'x') + R"("})");
|
||||
before = get(path);
|
||||
assert(!save_advanced_debug(path, true) && get(path) == before);
|
||||
put(path, R"({"input_priority":"experimental","advanced_debug":true})");
|
||||
auto experimental = load_config(path);
|
||||
assert(experimental.experimental_input_priority);
|
||||
assert(experimental.experimental_input_priority && experimental.advanced_debug);
|
||||
// A priority request must preserve the user's existing action manifest/bindings.
|
||||
assert(action_manifest(argv[1], experimental) == std::filesystem::absolute(std::filesystem::path(argv[1]) / "actions.json"));
|
||||
put(path, R"({"input_priority":"normal"})");
|
||||
|
||||
Reference in new issue
Block a user