Restructure into umbrella modules (~55 -> 16 targets)
Headers move, CMake targets merge, C++ namespaces stay unchanged: - Core: Scope, Lazy, Counted, Flags, Hash, Bits, Uuid, TypeList, TypeMap, Variant - Functional: Pipeline, Either, Result, Retry - Containers: Ring, Pool, PriorityQueue, LRU, Trie, Graph, DisjointSet, Bitset, Interval - Math: +Matrix, Numeric, Random, Histogram - Text: Str, Format, Tokenizer, Diff, Encoding, Semver - Data: Json, Csv, Ini - Async: Coro, Concurrency, EventBus, Observable - Time: +Bench - Log: Log facade + Logging framework (facade now header-only, breaking the Stacktrace<->Log link cycle the merge would have created) - System: FileSystem + Process - Configuration: +Argparse - Unchanged: Stacktrace, Plugin, StateMachine, Testing, TestingMock, Detail Module system fixes: - OPTIONAL_DEPS resolution deferred to void_finalize_modules() so it no longer depends on the alphabetical discovery order of src/ subdirs (Testing -> Text would have been silently dropped). - Every header-only module now has a tracked module.cmake; previously the empty src/<Name> marker dirs were untracked, so a fresh clone would have silently skipped those modules. - VOID_HAS_LOGGING/CONCURRENCY/STR consumers renamed to LOG/ASYNC/TEXT. Tests move to tests/standalone/<Umbrella>/<Feature>.cpp (Result suite files prefixed: ResultBasic etc.). Test count verified identical (831) before and after. README/CLAUDE.md module tables updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da2e93c405
commit
28b94883fd
156 files changed
+278
-220
No files matched your search
@@ -0,0 +1,98 @@
|
||||
#include <Void/System/Path.hpp>
|
||||
#include <Void/System/TempDir.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
Void::Testing::Test read_file_returns_contents()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
const auto path = tmp / "data.txt";
|
||||
{
|
||||
std::ofstream f{path};
|
||||
f << "hello\nworld";
|
||||
}
|
||||
auto r = Void::FileSystem::read_file(path);
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect_eq(*r, std::string{"hello\nworld"});
|
||||
}
|
||||
|
||||
Void::Testing::Test read_file_fails_on_missing()
|
||||
{
|
||||
auto r = Void::FileSystem::read_file("/this/path/does/not/exist");
|
||||
Void::Testing::expect(!r.has_value());
|
||||
Void::Testing::expect(r.error().message().find("read_file") !=
|
||||
std::string::npos);
|
||||
}
|
||||
|
||||
Void::Testing::Test write_file_creates_and_overwrites()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
const auto path = tmp / "out.txt";
|
||||
|
||||
auto r1 = Void::FileSystem::write_file(path, "first");
|
||||
Void::Testing::expect(r1.has_value());
|
||||
|
||||
auto r2 = Void::FileSystem::write_file(path, "second");
|
||||
Void::Testing::expect(r2.has_value());
|
||||
|
||||
auto read_back = Void::FileSystem::read_file(path);
|
||||
Void::Testing::expect(read_back.has_value());
|
||||
Void::Testing::expect_eq(*read_back, std::string{"second"});
|
||||
}
|
||||
|
||||
Void::Testing::Test atomic_write_replaces_target()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
const auto path = tmp / "snapshot.json";
|
||||
|
||||
{
|
||||
std::ofstream f{path};
|
||||
f << "old contents";
|
||||
}
|
||||
|
||||
auto r = Void::FileSystem::atomic_write(path, "new contents");
|
||||
Void::Testing::expect(r.has_value());
|
||||
|
||||
auto read_back = Void::FileSystem::read_file(path);
|
||||
Void::Testing::expect(read_back.has_value());
|
||||
Void::Testing::expect_eq(*read_back, std::string{"new contents"});
|
||||
|
||||
// Staging file should not be left behind on success.
|
||||
auto staging = path;
|
||||
staging += ".tmp";
|
||||
Void::Testing::expect(!std::filesystem::exists(staging));
|
||||
}
|
||||
|
||||
Void::Testing::Test ensure_directory_creates_nested_dirs()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
const auto nested = tmp / "a/b/c/d";
|
||||
|
||||
auto r = Void::FileSystem::ensure_directory(nested);
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect(std::filesystem::is_directory(nested));
|
||||
|
||||
// Idempotent — second call still succeeds.
|
||||
auto r2 = Void::FileSystem::ensure_directory(nested);
|
||||
Void::Testing::expect(r2.has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test remove_path_handles_missing_and_recursive()
|
||||
{
|
||||
// Missing path is a no-op (success).
|
||||
auto r1 = Void::FileSystem::remove_path("/nonexistent/path");
|
||||
Void::Testing::expect(r1.has_value());
|
||||
|
||||
// Recursive removal.
|
||||
Void::FileSystem::TempDir tmp;
|
||||
const auto nested = tmp / "a/b";
|
||||
(void)Void::FileSystem::ensure_directory(nested);
|
||||
(void)Void::FileSystem::write_file(nested / "leaf.txt", "x");
|
||||
|
||||
auto r2 = Void::FileSystem::remove_path(tmp.path() / "a");
|
||||
Void::Testing::expect(r2.has_value());
|
||||
Void::Testing::expect(!std::filesystem::exists(tmp.path() / "a"));
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
#include <Void/System/Process.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
Void::Testing::Test shell_echo_captures_stdout()
|
||||
{
|
||||
auto r = Void::Process::shell("echo hello");
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect_eq(r->exit_code, 0);
|
||||
Void::Testing::expect(r->out.find("hello") != std::string::npos);
|
||||
}
|
||||
|
||||
Void::Testing::Test shell_exit_code_propagates()
|
||||
{
|
||||
auto r = Void::Process::shell("exit 42");
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect_eq(r->exit_code, 42);
|
||||
}
|
||||
|
||||
Void::Testing::Test shell_captures_stderr_separately()
|
||||
{
|
||||
auto r = Void::Process::shell("echo err_output >&2");
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect(r->err.find("err_output") != std::string::npos);
|
||||
Void::Testing::expect(r->out.find("err_output") == std::string::npos);
|
||||
}
|
||||
|
||||
Void::Testing::Test run_with_args_builds_correct_argv()
|
||||
{
|
||||
auto r = Void::Process::run("/bin/echo", {"hello", "world"});
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect_eq(r->exit_code, 0);
|
||||
Void::Testing::expect(r->out.find("hello world") != std::string::npos);
|
||||
}
|
||||
|
||||
Void::Testing::Test run_stdin_forwarded_to_cat()
|
||||
{
|
||||
auto r = Void::Process::run("/bin/cat", {}, "piped_input");
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect_eq(r->exit_code, 0);
|
||||
Void::Testing::expect(r->out.find("piped_input") != std::string::npos);
|
||||
}
|
||||
|
||||
Void::Testing::Test run_missing_executable_returns_code_127()
|
||||
{
|
||||
auto r = Void::Process::run("/this/binary/does/not/exist");
|
||||
// fork succeeds, execvp fails, child _exits(127)
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect_eq(r->exit_code, 127);
|
||||
}
|
||||
|
||||
Void::Testing::Test run_stdout_and_stderr_independent()
|
||||
{
|
||||
auto r = Void::Process::shell(
|
||||
"echo to_stdout; echo to_stderr >&2");
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect(r->out.find("to_stdout") != std::string::npos);
|
||||
Void::Testing::expect(r->err.find("to_stderr") != std::string::npos);
|
||||
Void::Testing::expect(r->out.find("to_stderr") == std::string::npos);
|
||||
Void::Testing::expect(r->err.find("to_stdout") == std::string::npos);
|
||||
}
|
||||
|
||||
Void::Testing::Test run_large_output_is_captured_fully()
|
||||
{
|
||||
// Generate 10 000 lines; poll-based reader must accumulate them all.
|
||||
auto r = Void::Process::shell("seq 1 10000");
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect_eq(r->exit_code, 0);
|
||||
// "10000\n" must be present, and total output must be substantial
|
||||
Void::Testing::expect(r->out.find("10000") != std::string::npos);
|
||||
Void::Testing::expect(r->out.size() > 40000);
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
#include <Void/System/Path.hpp>
|
||||
#include <Void/System/Query.hpp>
|
||||
#include <Void/System/TempDir.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
|
||||
Void::Testing::Test exists_returns_true_for_existing_file()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
auto p = tmp / "f.txt";
|
||||
(void)Void::FileSystem::write_file(p, "x");
|
||||
Void::Testing::expect(Void::FileSystem::exists(p));
|
||||
}
|
||||
|
||||
Void::Testing::Test exists_returns_false_for_missing()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
Void::Testing::expect(!Void::FileSystem::exists(tmp / "no_such.txt"));
|
||||
}
|
||||
|
||||
Void::Testing::Test file_size_returns_correct_byte_count()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
auto p = tmp / "sized.txt";
|
||||
(void)Void::FileSystem::write_file(p, "hello");
|
||||
auto r = Void::FileSystem::file_size(p);
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect_eq(*r, std::uintmax_t{5});
|
||||
}
|
||||
|
||||
Void::Testing::Test file_size_fails_for_missing_path()
|
||||
{
|
||||
auto r = Void::FileSystem::file_size("/no/such/file.txt");
|
||||
Void::Testing::expect(!r.has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test last_modified_returns_a_time()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
auto p = tmp / "ts.txt";
|
||||
(void)Void::FileSystem::write_file(p, "data");
|
||||
auto r = Void::FileSystem::last_modified(p);
|
||||
Void::Testing::expect(r.has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test last_modified_fails_for_missing_path()
|
||||
{
|
||||
auto r = Void::FileSystem::last_modified("/no/such/file.txt");
|
||||
Void::Testing::expect(!r.has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test list_directory_returns_created_entries()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
(void)Void::FileSystem::write_file(tmp / "a.txt", "");
|
||||
(void)Void::FileSystem::write_file(tmp / "b.txt", "");
|
||||
auto r = Void::FileSystem::list_directory(tmp.path());
|
||||
Void::Testing::expect(r.has_value());
|
||||
Void::Testing::expect(r->size() >= 2);
|
||||
const auto has_a = std::any_of(r->begin(), r->end(), [&](const auto& p) {
|
||||
return p.filename() == "a.txt";
|
||||
});
|
||||
const auto has_b = std::any_of(r->begin(), r->end(), [&](const auto& p) {
|
||||
return p.filename() == "b.txt";
|
||||
});
|
||||
Void::Testing::expect(has_a);
|
||||
Void::Testing::expect(has_b);
|
||||
}
|
||||
|
||||
Void::Testing::Test list_directory_fails_for_missing_path()
|
||||
{
|
||||
auto r = Void::FileSystem::list_directory("/no/such/directory");
|
||||
Void::Testing::expect(!r.has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test copy_file_creates_duplicate()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
auto src = tmp / "src.txt";
|
||||
auto dst = tmp / "dst.txt";
|
||||
(void)Void::FileSystem::write_file(src, "contents");
|
||||
auto r = Void::FileSystem::copy_file(src, dst);
|
||||
Void::Testing::expect(r.has_value());
|
||||
auto back = Void::FileSystem::read_file(dst);
|
||||
Void::Testing::expect(back.has_value());
|
||||
Void::Testing::expect_eq(*back, std::string{"contents"});
|
||||
}
|
||||
|
||||
Void::Testing::Test copy_file_fails_without_overwrite_when_dst_exists()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
auto src = tmp / "src.txt";
|
||||
auto dst = tmp / "dst.txt";
|
||||
(void)Void::FileSystem::write_file(src, "new");
|
||||
(void)Void::FileSystem::write_file(dst, "old");
|
||||
auto r = Void::FileSystem::copy_file(src, dst, /*overwrite=*/false);
|
||||
Void::Testing::expect(!r.has_value());
|
||||
}
|
||||
|
||||
Void::Testing::Test copy_file_with_overwrite_replaces_dst()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
auto src = tmp / "src.txt";
|
||||
auto dst = tmp / "dst.txt";
|
||||
(void)Void::FileSystem::write_file(src, "new_content");
|
||||
(void)Void::FileSystem::write_file(dst, "old_content");
|
||||
auto r = Void::FileSystem::copy_file(src, dst, /*overwrite=*/true);
|
||||
Void::Testing::expect(r.has_value());
|
||||
auto back = Void::FileSystem::read_file(dst);
|
||||
Void::Testing::expect_eq(*back, std::string{"new_content"});
|
||||
}
|
||||
|
||||
Void::Testing::Test copy_dir_duplicates_tree()
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
auto src = tmp / "src";
|
||||
auto dst = tmp / "dst";
|
||||
(void)Void::FileSystem::ensure_directory(src);
|
||||
(void)Void::FileSystem::write_file(src / "file.txt", "tree");
|
||||
auto r = Void::FileSystem::copy_dir(src, dst);
|
||||
Void::Testing::expect(r.has_value());
|
||||
auto back = Void::FileSystem::read_file(dst / "file.txt");
|
||||
Void::Testing::expect(back.has_value());
|
||||
Void::Testing::expect_eq(*back, std::string{"tree"});
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#include <Void/System/TempDir.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <utility>
|
||||
|
||||
Void::Testing::Test temp_dir_creates_directory_under_temp()
|
||||
{
|
||||
std::filesystem::path captured;
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
captured = tmp.path();
|
||||
Void::Testing::expect(std::filesystem::is_directory(captured));
|
||||
Void::Testing::expect(captured.parent_path() ==
|
||||
std::filesystem::temp_directory_path());
|
||||
}
|
||||
// Removed on destruction.
|
||||
Void::Testing::expect(!std::filesystem::exists(captured));
|
||||
}
|
||||
|
||||
Void::Testing::Test temp_dir_removes_recursive_contents()
|
||||
{
|
||||
std::filesystem::path captured;
|
||||
{
|
||||
Void::FileSystem::TempDir tmp;
|
||||
captured = tmp.path();
|
||||
std::filesystem::create_directories(tmp / "nested/deep");
|
||||
std::ofstream{tmp / "nested/deep/leaf.txt"} << "data";
|
||||
Void::Testing::expect(
|
||||
std::filesystem::exists(tmp / "nested/deep/leaf.txt"));
|
||||
}
|
||||
Void::Testing::expect(!std::filesystem::exists(captured));
|
||||
}
|
||||
|
||||
Void::Testing::Test temp_dir_move_transfers_ownership()
|
||||
{
|
||||
std::filesystem::path captured;
|
||||
{
|
||||
Void::FileSystem::TempDir a;
|
||||
captured = a.path();
|
||||
Void::FileSystem::TempDir b{std::move(a)};
|
||||
// `a` is moved-from; `b` owns the directory.
|
||||
Void::Testing::expect_eq(b.path(), captured);
|
||||
Void::Testing::expect(std::filesystem::is_directory(b.path()));
|
||||
}
|
||||
Void::Testing::expect(!std::filesystem::exists(captured));
|
||||
}
|
||||
|
||||
Void::Testing::Test temp_dir_open_factory_returns_result()
|
||||
{
|
||||
std::filesystem::path captured;
|
||||
{
|
||||
auto r = Void::FileSystem::TempDir::open("void_factory_test_");
|
||||
Void::Testing::expect(r.has_value());
|
||||
captured = r->path();
|
||||
Void::Testing::expect(std::filesystem::is_directory(captured));
|
||||
}
|
||||
// `r` is destroyed at end of scope, which destroys the contained
|
||||
// TempDir and removes the directory.
|
||||
Void::Testing::expect(!std::filesystem::exists(captured));
|
||||
}
|
||||
|
||||
Void::Testing::Test temp_dir_two_concurrent_dirs_have_distinct_paths()
|
||||
{
|
||||
Void::FileSystem::TempDir a;
|
||||
Void::FileSystem::TempDir b;
|
||||
Void::Testing::expect(a.path() != b.path());
|
||||
}
|
||||
Reference in new issue
Block a user