feat(test): doctests, sharding, coverage gates, rerun/flaky and fuzzing (G8)
VoidBuildSystem CI / 1 · Requirements (push) Successful in 3s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 2m1s
VoidBuildSystem CI / 2A · Linux build (coverage) (push) Successful in 2m25s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 4m9s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 2m6s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 4m47s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 3m58s
VoidBuildSystem CI / 3A · Linux test (coverage) (push) Failing after 1m23s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 24s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 30s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 1m24s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Failing after 6m27s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Failing after 6m39s
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) Skipped
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Skipped
VoidBuildSystem CI / 5 · Release (push) Skipped

- vbs doctest extracts fenced C++ blocks from ///, //! and Doxygen comments,
  compiles each as main() with #line diagnostics mapped to the header,
  links optional --source files and reports per-block pass/fail.
- vbs test --shard I/N clusters tests with their fixture prerequisites and
  greedily balances clusters using the previous run's timings
  (<build>/.vbs/test_timings.json, written after every run).
- --rerun-failed re-runs only the previously failed closure
  (<build>/.vbs/last_failed_tests.json); --known-flaky FILE reports flaky
  failures without failing the run.
- --coverage-min PCT and --coverage-diff BASE enforce coverage gates from
  the lcov report (summary comparison via Report::read_lcov_summary).
- vbs fuzz compiles a libFuzzer target with clang
  (-fsanitize=fuzzer,address,undefined), runs it over a corpus and reports
  crash artifacts.

Verified: doctest_extracts_compiles_and_runs_blocks,
test_sharding_partitions_tests_and_records_timings,
test_rerun_failed_and_known_flaky,
coverage_gates_enforce_minimum_and_baseline and
fuzz_builds_targets_and_reports_crashes pass; CLI contracts pass;
clang-format clean.
This commit is contained in:
faumaray committed 2026-12-06 20:21:51 +03:00
1 parent 3b5d28d7b0
commit 455a403429
13 files changed
+1238 -7

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
#pragma once
#include <Void/Functional/Error.hpp>
#include <Void/Functional/Result.hpp>
#include <chrono>
#include <cstddef>
#include <filesystem>
#include <string>
#include <vector>
namespace Void::Build::Test {
// One fenced code block extracted from a header's documentation comments
// (``/// ```cpp`` ... ``/// ``` ``, `//!`, or Doxygen `*` lines).
struct DoctestBlock {
std::filesystem::path file;
std::size_t line{0};
std::string code;
std::string language;
};
[[nodiscard]] Void::Result::Result<std::vector<DoctestBlock>, Void::Result::Error>
extract_doctest_blocks(const std::filesystem::path &header);
struct DoctestOptions {
std::filesystem::path project_root;
std::filesystem::path build_dir;
std::vector<std::filesystem::path> headers;
std::vector<std::filesystem::path> include_dirs;
std::vector<std::filesystem::path> extra_sources; // linked into every doctest
std::filesystem::path compiler; // empty = resolve g++/clang++
std::string cxx_standard{"c++26"};
std::chrono::milliseconds timeout{std::chrono::seconds{120}};
};
struct DoctestResult {
std::size_t blocks{0};
std::size_t passed{0};
std::size_t failed{0};
std::vector<std::string> diagnostics;
};
// Compiles and runs each block as the body of `main()` in a generated translation unit that
// includes the header (`#line` maps compiler errors back to the header).
[[nodiscard]] Void::Result::Result<DoctestResult, Void::Result::Error>
run_doctests(const DoctestOptions &options);
} // namespace Void::Build::Test
+38
View File
@@ -0,0 +1,38 @@
#pragma once
#include <Void/Functional/Error.hpp>
#include <Void/Functional/Result.hpp>
#include <chrono>
#include <filesystem>
#include <string>
#include <vector>
namespace Void::Build::Test {
struct FuzzOptions {
std::filesystem::path project_root;
std::filesystem::path build_dir;
std::vector<std::filesystem::path> sources;
std::vector<std::filesystem::path> include_dirs;
std::filesystem::path compiler; // empty = clang++
std::string name{"fuzz"};
std::size_t runs{10000};
std::filesystem::path corpus; // default: <build_dir>/fuzz/corpus
std::chrono::milliseconds timeout{std::chrono::minutes{10}};
};
struct FuzzResult {
std::filesystem::path binary;
int exit_code{-1};
std::string output;
std::vector<std::filesystem::path> artifacts;
};
// Compiles a libFuzzer target (`-fsanitize=fuzzer,address,undefined`) and runs it over the
// corpus for `runs` iterations. A non-zero fuzzer exit (crash, sanitizer finding) is reported in
// the result; setup failures are errors.
[[nodiscard]] Void::Result::Result<FuzzResult, Void::Result::Error>
run_fuzz(const FuzzOptions &options);
} // namespace Void::Build::Test