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>
75 lines
2.5 KiB
C++
75 lines
2.5 KiB
C++
#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);
|
|
}
|