Files
simian/tests/hot_reload.cpp
nick 4a43160537
CI / build-and-test (push) Successful in 2m19s
feat: math and texture functions. update tests
2025-11-19 15:49:03 +13:00

36 lines
855 B
C++

#define TEST_NO_MAIN
#include "acutest.h"
#include <string.h>
#include <filesystem>
#include <fstream>
#include <thread>
#include <chrono>
#include "../include/HotReload.h"
using namespace std::chrono_literals;
void test_hotreload_directory_watch(void) {
std::filesystem::path tmpDir = std::filesystem::current_path() / "tmp_watch";
std::filesystem::create_directories(tmpDir);
std::filesystem::path f = tmpDir / "a.as";
std::ofstream ofs(f);
ofs << "// test" << std::endl;
ofs.close();
HotReload hr(tmpDir.string());
TEST_CHECK(hr.CheckForChanges() == false);
std::this_thread::sleep_for(1s);
std::ofstream ofs2(f, std::ios::app);
ofs2 << "// changed" << std::endl;
ofs2.close();
TEST_CHECK(hr.CheckForChanges() == true);
std::filesystem::remove(f);
std::filesystem::remove(tmpDir);
}