Stage 0: continuity test suite
- anm2ed_core static library (anm2 + non-UI util + log) shared by app and tests - Logger is inert until session_open, so the core has no SDL dependency - doctest suite: golden round-trips of 12 synthetic fixtures across every serialization preset, format and merge type; save/reload invariants (fixed point, hash stability, game view equals re-baked game view); operation goldens; env-gated private corpus run (ANM2ED_CORPUS) - ANM2ED_UPDATE_GOLDEN=1 regenerates goldens; tests/MANUAL.md UI checklist Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8e37b5df3b
commit
8953101245
169 files changed
+14803
-19
No files matched your search
+11
-15
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "file.hpp"
|
||||
#include "path.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "strings.hpp"
|
||||
#include "time.hpp"
|
||||
|
||||
@@ -48,12 +47,10 @@ namespace anm2ed
|
||||
#endif
|
||||
}
|
||||
|
||||
std::filesystem::path directory_path_get() { return sdl::preferences_directory_get() / "logs"; }
|
||||
|
||||
std::filesystem::path session_path_get()
|
||||
std::filesystem::path session_path_get(const std::filesystem::path& directory)
|
||||
{
|
||||
auto name = std::format("anm2ed_{}_{}.log", time::get("%Y-%m-%d_%H-%M-%S"), process_id_get());
|
||||
return directory_path_get() / path::from_utf8(name);
|
||||
return directory / "logs" / path::from_utf8(name);
|
||||
}
|
||||
|
||||
std::vector<SessionFile> session_files_get(const std::filesystem::path& directory,
|
||||
@@ -95,8 +92,8 @@ namespace anm2ed
|
||||
void sessions_prune(const std::filesystem::path& directory, const std::filesystem::path& currentPath)
|
||||
{
|
||||
auto files = session_files_get(directory, currentPath);
|
||||
std::sort(files.begin(), files.end(), [](const SessionFile& left, const SessionFile& right)
|
||||
{ return left.time > right.time; });
|
||||
std::sort(files.begin(), files.end(),
|
||||
[](const SessionFile& left, const SessionFile& right) { return left.time > right.time; });
|
||||
|
||||
std::uintmax_t totalSize{};
|
||||
for (const auto& file : files)
|
||||
@@ -117,7 +114,7 @@ namespace anm2ed
|
||||
|
||||
void legacy_log_remove(const std::filesystem::path& currentPath)
|
||||
{
|
||||
auto directory = sdl::preferences_directory_get();
|
||||
auto directory = currentPath.parent_path().parent_path();
|
||||
if (directory.empty()) return;
|
||||
|
||||
auto legacyPath = directory / "log.txt";
|
||||
@@ -288,20 +285,19 @@ namespace anm2ed
|
||||
stderr_redirect_start();
|
||||
}
|
||||
|
||||
std::filesystem::path Logger::path()
|
||||
{
|
||||
static auto path = log::session_path_get();
|
||||
return path;
|
||||
}
|
||||
std::filesystem::path Logger::path() const { return logPath; }
|
||||
|
||||
Logger::Logger()
|
||||
void Logger::session_open(const std::filesystem::path& directory)
|
||||
{
|
||||
open(path());
|
||||
open(log::session_path_get(directory));
|
||||
info(std::format("Initializing {}", localize.get(LABEL_APPLICATION_NAME, ENGLISH)));
|
||||
}
|
||||
|
||||
Logger::Logger() = default;
|
||||
|
||||
Logger::~Logger()
|
||||
{
|
||||
if (logPath.empty()) return;
|
||||
info("Exiting Anm2Ed");
|
||||
stderr_redirect_stop();
|
||||
}
|
||||
|
||||
+2
-1
@@ -61,7 +61,8 @@ namespace anm2ed
|
||||
void stderr_pump();
|
||||
|
||||
public:
|
||||
static std::filesystem::path path();
|
||||
std::filesystem::path path() const;
|
||||
void session_open(const std::filesystem::path&);
|
||||
void write_raw(const std::string&);
|
||||
void write(const Level, const std::string&);
|
||||
void info(const std::string&);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "loader.hpp"
|
||||
#include "log.hpp"
|
||||
#include "sdl.hpp"
|
||||
#include "state.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -62,6 +63,7 @@ namespace anm2ed
|
||||
{
|
||||
int application_run(int argc, const char** argv)
|
||||
{
|
||||
logger.session_open(util::sdl::preferences_directory_get());
|
||||
return log_exceptions([&]()
|
||||
{
|
||||
Loader loader(argc, argv);
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ namespace anm2ed
|
||||
|
||||
auto pathString = path::to_utf8(path);
|
||||
auto ffmpegPathString = path::to_utf8(ffmpegPath);
|
||||
auto loggerPath = Logger::path();
|
||||
auto loggerPath = logger.path();
|
||||
auto loggerPathString = path::to_utf8(loggerPath);
|
||||
#if _WIN32
|
||||
auto ffmpegTempPath = loggerPath.parent_path() / "ffmpeg_log.temp.txt";
|
||||
|
||||
Reference in new issue
Block a user