feat(test): write JUnit reports and honour a per-test timeout
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 16s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 13s

This commit is contained in:
faumaray committed 2026-12-05 07:25:33 +03:00
1 parent ce47c23cda
commit 1e670cb96b
7 files changed
+147 -3

No files matched your search

+2
View File
@@ -298,6 +298,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- **Wave 102 (VoidLibrary Migration Trial)**: in a separate VoidLibrary clone at the pin (`0002e74`), a native `build.cpp` (using the shared module-closure logic) built VoidLibrary entirely with VBS - 23 actions, module archives plus `void_smoke` - and `vbs test` reported `PASSED 'void_smoke'` with no CMake. The reusable assets live in `contrib/voidlibrary-migration/` (outside the globbed source trees), and the missing first-class upstream build description was filed as [Void/Library#61](https://git.faumaray.com/Void/Library/issues/61).
- **Wave 103 (Test-Runner Parity: JUnit XML & Test Timeout)**: `vbs test` gained `--test-timeout SECONDS` (1..86400, validated before any project work) and `--junit FILE`, which writes a JUnit XML report aggregating every executed test target across profiles (`testcase` with classname/name/time, `failure` with exit status and captured output, escaped). Covered by `FullV1Tests.native_vbs_subproject_dependency_builds_without_cmake` (asserts the suite/testcase/failures fields) and a CLI contract for invalid timeouts.
## Remaining future scope
- **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order.
+1
View File
@@ -106,4 +106,5 @@ Base HEAD: `fe0d1a6`
| Wave 100 (CMakePresets import) | `Config::load_cmake_presets` (inherits, `${sourceDir}`, cache merge, profile/compiler mapping) + `vbs presets` CLI | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; presets test passes, full CTest 8/8) | `include/Void/Build/Config/Presets.hpp`, `src/Config/Presets.cpp`, `src/Main.cpp`, `tests/{FullV1Tests,CliContracts}.cpp/cmake`, docs |
| Wave 101 (CMake File API shim) | `vbs ide generate` emits `.cmake/api/v1/reply` codemodel-v2 + directory + per-target JSON from the lowered graph | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; IDE integration test passes, full CTest 8/8) | `src/Editor/CompDb.cpp`, `tests/FullV1Tests.cpp`, docs |
| Wave 102 (VoidLibrary migration trial) | Separate-clone `build.cpp` builds and tests VoidLibrary with VBS; assets in `contrib/voidlibrary-migration/`; upstream issue #61 | VERIFIED IN CLONE (23 actions, `vbs test` PASSED; no CMake) | `contrib/voidlibrary-migration/`, docs |
| Wave 103 (JUnit & test timeout) | `vbs test --junit FILE --test-timeout SECONDS` with aggregated JUnit XML | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; JUnit assertions and CLI contract pass, full CTest 8/8) | `src/Main.cpp`, `tests/{FullV1Tests,CliContracts}.cpp/cmake`, docs |
| Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) |
+9
View File
@@ -1447,6 +1447,15 @@ vbs test --project /tmp/opencode/vl-migrate --build-dir /tmp/opencode/vl-migrat
- Upstream gap filed as [Void/Library#61](https://git.faumaray.com/Void/Library/issues/61) because
VoidLibrary lacks an in-repo VBS build description and many modules have no native entry.
## Test-Runner Parity: JUnit XML & Test Timeout (GCC 16.2, pin `0002e74`)
- `vbs test --junit report.xml --test-timeout 120` on the native subproject fixture writes a JUnit
report containing `<testsuites`, `<testsuite name="debug"`, `name="consumer_test"`, and
`failures="0"` (`FullV1Tests.native_vbs_subproject_dependency_builds_without_cmake`, 4.03 s).
- `vbs test --test-timeout 0` exits 2 with `invalid --test-timeout value '0'` before any project
work (CLI contract).
- Full CTest: **8 / 8 passed** after both slices.
## Limits and Unrun Checks
1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified).
+1 -1
View File
@@ -54,7 +54,7 @@ Concrete work this implies:
| Package/registry | External (vcpkg, Conan, FetchContent) | wrapdb, subprojects | cppget.org / brep | **Built-in registry + solver + lock + binary variants + signatures + SBOM** | federation, mirrors, key distribution |
| Install/package | `install()`, `install(EXPORT)`, CPack (TGZ/ZIP/DEB/RPM/WIX/DMG/NuGet/APK…) | `install_data`, `install_headers`, dist scripts | install module | prefix staging, components, relocatable CMake + native exports, tar, self-extracting `sh`, **stored ZIP**, **DEB (dpkg-validated)**, SBOM, **Ed25519-signed archives with checksums** | RPM, MSI/DMG-style |
| IDE integration | File API, presets, every IDE | `meson-info` introspection | limited | `vbs ide generate/query`, CompDB, daemon protocol | File API shim, `CMakePresets.json` import, plugins |
| Test runner | CTest: fixtures, labels, resource locks, timeouts, JUnit/CDash | `meson test`: suites, timeouts, JUnit | test module | `VOID_TEST` runner | fixtures, labels, locks, timeouts, JUnit |
| Test runner | CTest: fixtures, labels, resource locks, timeouts, JUnit/CDash | `meson test`: suites, timeouts, JUnit | test module | `VOID_TEST` runner; `vbs test --junit --test-timeout` | fixtures, labels, resource locks, CDash |
| Incremental / cache | compiler depfiles, ccache external | depfiles, ccache | internal caching model | **content-addressed state, immutable snapshots, remote action cache** | scale benchmarks |
| Modules / PCH / unity / LTO / sanitizers | yes (with generator quirks) | yes | yes | **native with capability probing** | more compilers |
| Reproducibility | opt-in | opt-in | partial | **default deterministic** (epoch, prefix maps, canonical mtimes) | cross-platform determinism |
+121 -1
View File
@@ -356,6 +356,15 @@ combine_trusted_keys(const std::vector<std::string> &inline_keys,
return combined;
}
struct TestRunRecord {
std::string profile;
std::string name;
bool passed{false};
int exit_code{-1};
double elapsed_ms{0};
std::string output;
};
struct BuildCmdOptions {
std::string project_arg;
std::optional<std::string> build_arg;
@@ -377,6 +386,8 @@ struct BuildCmdOptions {
std::vector<std::string> trusted_key_files;
std::optional<std::string> target_os_arg;
std::optional<std::string> target_arch_arg;
std::optional<std::string> junit_arg;
std::string test_timeout_arg{"300"};
bool publish_editor_selection{true};
bool no_cache{false};
bool locked{false};
@@ -386,6 +397,14 @@ struct BuildCmdOptions {
int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
const std::string cmd_name = run_tests ? "vbs test" : "vbs build";
int test_timeout_seconds = 300;
if (!Void::Str::to_int(opts.test_timeout_arg, test_timeout_seconds) ||
test_timeout_seconds <= 0 || test_timeout_seconds > 86400) {
std::cerr << cmd_name << ": invalid --test-timeout value '" << opts.test_timeout_arg
<< "' (expected 1..86400 seconds)\n";
return 2;
}
std::vector<TestRunRecord> test_records;
const auto total_sw = Void::Time::Stopwatch::started();
std::optional<CompilerFamily> compiler_override;
@@ -495,6 +514,7 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
return 1;
}
const std::string target_os = opts.target_os_arg.value_or(Toolchain::host_os_name());
const std::string target_arch =
opts.target_arch_arg.value_or(Toolchain::host_architecture_name());
@@ -834,8 +854,20 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
treq.executable = t.primary_outputs.front();
}
treq.working_directory = project_root;
treq.timeout = std::chrono::seconds{300};
treq.timeout = std::chrono::seconds{test_timeout_seconds};
auto tres = Platform::run_supervised(treq);
TestRunRecord record;
record.profile = prof_name;
record.name = t.name;
record.passed = tres.has_value() && tres->succeeded();
record.elapsed_ms = tsw.elapsed_ms();
if (tres) {
record.output = tres->stdout_data + tres->stderr_data;
record.exit_code = tres->exit_code;
} else {
record.output = tres.error().message();
}
test_records.push_back(std::move(record));
if (!tres || !tres->succeeded()) {
Void::Log::error("Test", "[{}] FAILED '{}' ({:.0f} ms)", prof_name, t.name,
tsw.elapsed_ms());
@@ -856,6 +888,91 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
}
}
// JUnit XML report for CI systems (aggregated across selected profiles).
if (opts.junit_arg && !opts.junit_arg->empty() && !test_records.empty()) {
const auto xml_escape = [](std::string_view text) {
std::string out;
out.reserve(text.size());
for (const char c : text) {
switch (c) {
case '&':
out += "&amp;";
break;
case '<':
out += "&lt;";
break;
case '>':
out += "&gt;";
break;
case '"':
out += "&quot;";
break;
case '\'':
out += "&apos;";
break;
default:
if (static_cast<unsigned char>(c) >= 0x20 || c == '\n' || c == '\t') {
out.push_back(c);
}
break;
}
}
return out;
};
std::size_t failures = 0;
for (const auto &record : test_records) {
if (!record.passed) {
++failures;
}
}
std::string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
xml += std::format("<testsuites name=\"vbs\" tests=\"{}\" failures=\"{}\">\n",
test_records.size(), failures);
std::string current_profile;
auto open_suite = [&] {
if (!current_profile.empty()) {
xml += " </testsuite>\n";
}
std::size_t suite_tests = 0;
std::size_t suite_failures = 0;
for (const auto &record : test_records) {
if (record.profile == current_profile) {
++suite_tests;
if (!record.passed) {
++suite_failures;
}
}
}
xml += std::format(" <testsuite name=\"{}\" tests=\"{}\" failures=\"{}\">\n",
xml_escape(current_profile), suite_tests, suite_failures);
};
for (const auto &record : test_records) {
if (record.profile != current_profile) {
current_profile = record.profile;
open_suite();
}
xml += std::format(" <testcase classname=\"{}\" name=\"{}\" time=\"{:.3f}\"",
xml_escape(record.profile), xml_escape(record.name),
record.elapsed_ms / 1000.0);
if (record.passed) {
xml += "/>\n";
} else {
xml += std::format(">\n <failure message=\"exited with status "
"{}\">{}</failure>\n </testcase>\n",
record.exit_code, xml_escape(record.output));
}
}
if (!current_profile.empty()) {
xml += " </testsuite>\n";
}
xml += "</testsuites>\n";
if (auto written = Platform::atomic_write_file(*opts.junit_arg, xml, false); !written) {
std::cerr << "vbs test: cannot write JUnit report: " << written.error().message()
<< '\n';
all_ok = false;
}
}
Void::Log::debug("Build", "Total wall time: {:.2f}s", total_sw.elapsed_ms() / 1000.0);
return all_ok ? 0 : 1;
}
@@ -2798,6 +2915,9 @@ int main(int argc, char **argv) {
build_opts.target_os_arg)
.option("--target-arch", "", "Target architecture (default: host, e.g. x86_64)",
build_opts.target_arch_arg)
.option_default("--test-timeout", "", "Per-test timeout in seconds (1..86400)",
build_opts.test_timeout_arg, "300")
.option("--junit", "", "Write a JUnit XML report of test results", build_opts.junit_arg)
.option("--editor-profile", "", "Editor profile for compile_commands.json",
build_opts.editor_profile)
.option_many("--build-source", "", "Additional build description source",
+1
View File
@@ -24,6 +24,7 @@ check_process(2 "" "--version cannot be combined with subcommands" --version bui
check_process(2 "" "unknown subcommand: invalid" invalid)
check_process(0 "Usage: vbs build .*--native-foreign.*--profile.*\\(repeatable\\)" "" build --help)
check_process(0 "Usage: vbs test " "" test --help)
check_process(2 "" "invalid --test-timeout" test --test-timeout 0)
check_process(0 "Usage: vbs init " "" init --help)
check_process(0 "Usage: vbs clean " "" clean --help)
check_process(0 "Usage: vbs doctor " "" doctor --help)
+12 -1
View File
@@ -1988,7 +1988,10 @@ void build(Void::Build::Project &p) {
Platform::ProcessRequest req;
req.executable = vbs_bin;
req.arguments = {"test", "--project", cons_dir.string(), "--build-dir", cons_build.string()};
const auto junit_report = tmp / "consumer-junit.xml";
req.arguments = {"test", "--project", cons_dir.string(),
"--build-dir", cons_build.string(), "--test-timeout",
"120", "--junit", junit_report.string()};
req.environment.set_vars["PATH"] = trapped_path;
req.timeout = std::chrono::seconds{120};
auto res = Platform::run_supervised(req);
@@ -2000,6 +2003,14 @@ void build(Void::Build::Project &p) {
if (res) {
Void::Testing::expect(res->stdout_data.find("PASSED 'consumer_test'") != std::string::npos);
}
// JUnit XML report for CI consumption.
auto junit = Void::FileSystem::read_file(junit_report);
Void::Testing::require(junit.has_value());
Void::Testing::expect(junit->find("<testsuites") != std::string::npos);
Void::Testing::expect(junit->find("<testsuite name=\"debug\"") != std::string::npos);
Void::Testing::expect(junit->find("name=\"consumer_test\"") != std::string::npos);
Void::Testing::expect(junit->find("failures=\"0\"") != std::string::npos);
}
// === Track B1: First-class C driver & mixed C/C++ native CMake + Meson translation ===