- Allowlist Configuration, Crypto and System for the Windows target. - System: link winmm for the Win32 audio backend; include windows.h before mmsystem.h. - Tests: add a whole-file // @requires-posix gate (CMake path and the VBS build.cpp) and mark the POSIX-only System suites; skip helper-based cases on Windows; make setenv/unsetenv and getpid portable. - The POSIX process helper is no longer built on Windows. Cross-built with x86_64-w64-mingw32 GCC 16.2: all modules and VoidTests.exe link. Linux System+Testing suite still passes (477 tests, 474 passed). Refs #65
67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
// @requires-posix: streaming tests drive the POSIX process helper.
|
|
#include <Void/System/Process.hpp>
|
|
#include <Void/Testing/Assert.hpp>
|
|
#include <Void/Testing/Suite.hpp>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace
|
|
{
|
|
|
|
using Void::Testing::Test;
|
|
|
|
struct ProcessStream : Void::Testing::Suite<ProcessStream> {
|
|
Test streams_stdout_lines()
|
|
{
|
|
std::vector<std::string> lines;
|
|
Void::Process::StreamCallbacks cb;
|
|
cb.on_stdout = [&](std::string_view l) {
|
|
lines.emplace_back(l);
|
|
};
|
|
|
|
auto r = Void::Process::run_streaming(
|
|
VOID_PROCESS_HELPER_PATH, {"lines", "a", "b", "c"}, cb);
|
|
Void::Testing::expect(r.has_value());
|
|
Void::Testing::expect_eq(r->exit_code, 0);
|
|
|
|
const std::vector<std::string> expected{"a", "b", "c"};
|
|
Void::Testing::expect(lines == expected);
|
|
Void::Testing::expect_eq(r->out, std::string{"a\nb\nc\n"});
|
|
}
|
|
|
|
Test flushes_trailing_partial_line()
|
|
{
|
|
std::vector<std::string> lines;
|
|
Void::Process::StreamCallbacks cb;
|
|
cb.on_stdout = [&](std::string_view l) {
|
|
lines.emplace_back(l);
|
|
};
|
|
|
|
auto r = Void::Process::run_streaming(
|
|
VOID_PROCESS_HELPER_PATH,
|
|
{"lines", "--no-newline", "no-newline"},
|
|
cb);
|
|
Void::Testing::expect(r.has_value());
|
|
Void::Testing::expect_eq(lines.size(), std::size_t{1});
|
|
Void::Testing::expect_eq(lines.at(0), std::string{"no-newline"});
|
|
}
|
|
|
|
Test streams_stderr_separately()
|
|
{
|
|
std::vector<std::string> errs;
|
|
Void::Process::StreamCallbacks cb;
|
|
cb.on_stderr = [&](std::string_view l) {
|
|
errs.emplace_back(l);
|
|
};
|
|
|
|
auto r = Void::Process::run_streaming(
|
|
VOID_PROCESS_HELPER_PATH, {"lines", "--stderr", "oops"}, cb);
|
|
Void::Testing::expect(r.has_value());
|
|
Void::Testing::expect_eq(errs.size(), std::size_t{1});
|
|
Void::Testing::expect_eq(errs.at(0), std::string{"oops"});
|
|
}
|
|
};
|
|
|
|
} // namespace
|