Files
Library/include/Void/Testing/Subprocess.hpp
T

43 lines
943 B
C++

#pragma once
#include <chrono>
#include <cstddef>
#include <span>
#include <string>
#include <string_view>
namespace Void::Testing
{
struct ProcessTestOptions {
std::chrono::milliseconds timeout{60000};
std::size_t max_output_bytes{1024ULL * 1024ULL};
};
enum class ProcessOutcome {
passed,
failed,
crashed,
timed_out,
infrastructure_error
};
struct ProcessTestResult {
ProcessOutcome outcome{ProcessOutcome::infrastructure_error};
int exit_code{-1};
int term_signal{0};
std::string stdout_captured{};
std::string stderr_captured{};
bool stdout_truncated{false};
bool stderr_truncated{false};
std::string diagnostic{};
};
[[nodiscard]] std::string current_executable_path();
[[nodiscard]] ProcessTestResult run_isolated_subprocess(
std::string_view executable,
std::span<const std::string> args = {},
ProcessTestOptions options = {});
} // namespace Void::Testing