commit 614e91b4745f3c344e1cf792a899cf9d0ec0e753 Author: fn-registry agent Date: Mon May 11 16:28:47 2026 +0200 chore: sync from fn-registry agent diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..54beeb9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,15 @@ +# Smoke test app para validar que text_editor + file_watcher compilan +# y enlazan correctamente. NO es una app del registry, solo build gate +# de las funciones nuevas del issue 0025. Sin ImGui events runtime — el +# test crea, settea texto, polea y destruye en 1 frame headless (no abre ventana). + +add_imgui_app(text_editor_smoke + main.cpp + ${CMAKE_SOURCE_DIR}/functions/core/text_editor.cpp + ${CMAKE_SOURCE_DIR}/functions/core/file_watcher.cpp + ${CMAKE_SOURCE_DIR}/functions/core/file_poll_diff.cpp + ${CMAKE_SOURCE_DIR}/vendor/imgui_text_edit/TextEditor.cpp +) +target_include_directories(text_editor_smoke PRIVATE + ${CMAKE_SOURCE_DIR}/vendor/imgui_text_edit +) diff --git a/app.md b/app.md new file mode 100644 index 0000000..a2f332f --- /dev/null +++ b/app.md @@ -0,0 +1,28 @@ +--- +name: text_editor_smoke +lang: cpp +domain: tools +description: "Smoke test CLI (sin GUI) que valida los wrappers PIMPL de text_editor y file_watcher (inotify Linux / ReadDirectoryChangesW Win). No abre ventana ImGui — solo crea/settea texto/lee/poll/destruye." +tags: [cpp, smoke, test, cli] +uses_functions: + - text_editor_cpp_core + - file_watcher_cpp_core +uses_types: [] +framework: "cli" +entry_point: "main.cpp" +dir_path: "cpp/apps/text_editor_smoke" +repo_url: "" +--- + +# text_editor_smoke + +Smoke test que verifica las APIs de `text_editor` y `file_watcher` linkean correctamente. Sin ventana ImGui. + +## Build & run + +```bash +cd cpp && cmake --build build --target text_editor_smoke -j +./build/text_editor_smoke +``` + +Salida esperada: log con bytes leidos del editor + eventos del file_watcher. diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..4b0103f --- /dev/null +++ b/main.cpp @@ -0,0 +1,64 @@ +// Smoke test (no GUI): compila y ejecuta brevemente las APIs nuevas del +// issue 0025 para validar que el wrapper PIMPL del text_editor y el +// file_watcher (inotify Linux / ReadDirectoryChangesW Win) enlazan. +// +// No abre ventana ImGui — solo crea / settea texto / lee / poll / destruye. + +#include "core/text_editor.h" +#include "core/file_watcher.h" + +#include +#include +#include +#include +#include + +int main() { + // ----- text_editor ----- + auto* ed = fn::text_editor_create(fn::CodeLang::GLSL); + if (!ed) { std::fprintf(stderr, "text_editor_create returned null\n"); return 1; } + + fn::text_editor_set_text(ed, "void main(){}\n"); + const char* got = fn::text_editor_get_text(ed); + std::printf("text_editor: get_text -> %zu bytes\n", got ? std::strlen(got) : 0u); + + if (fn::text_editor_is_dirty(ed)) { + std::fprintf(stderr, "text_editor: dirty unexpected after set_text\n"); + return 1; + } + fn::text_editor_destroy(ed); + + // ----- file_watcher ----- + const char* path = "/tmp/fn_smoke_test.txt"; + std::remove(path); + { + FILE* f = std::fopen(path, "w"); std::fputs("init\n", f); std::fclose(f); + } + + auto* fw = fn::file_watcher_create(); + if (!fw) { std::fprintf(stderr, "file_watcher_create returned null\n"); return 1; } + + if (!fn::file_watcher_add(fw, path)) { + std::fprintf(stderr, "file_watcher_add failed: %s\n", fn::file_watcher_last_error(fw)); + // Aun asi continuamos: en CI sin inotify (raro) este test seria flaky. + } + + // Modificar + { + FILE* f = std::fopen(path, "w"); std::fputs("changed\n", f); std::fclose(f); + } + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + auto evs = fn::file_watcher_poll(fw); + std::printf("file_watcher: %zu events\n", evs.size()); + for (auto& e : evs) { + const char* kind = e.kind == fn::FileEvent::Modified ? "MOD" + : e.kind == fn::FileEvent::Created ? "NEW" : "DEL"; + std::printf(" [%s] %s\n", kind, e.path.c_str()); + } + + fn::file_watcher_destroy(fw); + std::remove(path); + std::printf("OK\n"); + return 0; +}