chore: sync from fn-registry agent
This commit is contained in:
@@ -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
|
||||
)
|
||||
@@ -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.
|
||||
@@ -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 <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user