feat(test): labels, exclusive resources and parallel test execution
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s
VoidBuildSystem CI / fuzz-clang (push) Failing after 6s
VoidBuildSystem CI / sanitizers-gcc16 (push) Failing after 6s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 10s
VoidBuildSystem CI / wine-windows-gcc16 (push) Failing after 51s

This commit is contained in:
faumaray committed 2026-12-05 12:44:50 +03:00
1 parent e135ae3023
commit 617d783e84
10 files changed
+281 -42

No files matched your search

+2
View File
@@ -356,6 +356,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B
- **Wave 131 (Warm-Build Latency & Generated Plugin Tests)**: descriptor identity hashing is memoized by stat fingerprint (size + mtime) in `.vbs/config/identity_cache.json`, and cached header entries carry the same fingerprint, so unchanged inputs are not re-hashed. In the benchmark project the descriptor check fell from ~106 ms to ~0.8 ms and `benchmarks/compare.sh` warm no-op from ~209 ms to **92 ms** (CMake 8 ms, Meson 175 ms on the same 20-source project). `vbs ide plugin --editor vscode` now also emits `test/extension.test.js` plus an `npm test` script, and the generated harness was executed with Node against a mocked VS Code API (6 commands passed).
- **Wave 132 (Test Labels, Resource Locks & Parallel Tests)**: the SDK gained `.label("name")` and `.resource("name")` on targets (round-tripped through the descriptor JSON), and `vbs test` now runs test targets in parallel up to `--jobs` while serializing tests that share a resource, and filters with `--label`. `FullV1Tests.test_labels_filter_and_resource_locks_serialize` covers label filtering and asserts that shared-resource start/end intervals never overlap under 4 jobs.
## 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
@@ -132,4 +132,5 @@ Base HEAD: `fe0d1a6`
| Wave 127 (Continuous worker loop) | `vbs worker --queue` loop with local record export, retries, skip-on-missing, `--once`, exit on empty queue | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; worker E2E passes, full CTest 8/8) | `src/Main.cpp`, `tests/RegistryTests.cpp`, docs |
| Wave 128 (Lease renewal + idle timeout) | `actions/<key>/renew`, `renew_action_lease`, `worker --idle-timeout/--once` | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; worker E2E passes, full CTest 8/8) | `registry/service/RegistryService.cpp`, `src/Package/RegistryClient.cpp`, `src/Main.cpp`, `tests/RegistryTests.cpp`, docs |
| Wave 131 (warm-build latency + plugin tests) | Stat-fingerprint memo for descriptor identity/header hashes; generated VS Code test harness | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; vbs warm 92 ms vs 209 ms baseline, generated harness passes under Node, full CTest 8/8) | `src/Config/Frontend.cpp`, `src/Editor/CompDb.cpp`, `tests/FullV1Tests.cpp`, `benchmarks/compare.sh`, docs |
| Wave 132 (Test labels, resource locks, parallel tests) | `.label()`/`.resource()` SDK, `--label` filter, parallel test runner with exclusive resources | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; E2E passes, full CTest 8/8) | `include/Void/Build.hpp`, `sdk/Build.cpp`, `src/Main.cpp`, `src/Graph/Graph.cpp`, `tests/FullV1Tests.cpp`, 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) |
+11
View File
@@ -1741,6 +1741,17 @@ VOID_INCLUDE_DIR=/tmp/opencode/vl-pin/include dev cpp -c bash fuzz/run.sh 30
`extension tests passed: 6 commands`.
- Full CTest: **8 / 8 passed** in 288.56 s.
## Test Labels, Resource Locks & Parallel Tests (GCC 16.2, pin `0002e74`)
- SDK: `.label("fast")` and `.resource("shared")` are serialized by the descriptor and parsed
back into `TargetRecord`/`ResolvedTargetSummary`.
- Runner: `vbs test --label LABEL` filters by label; tests run on a `--jobs`-bounded thread pool
where a resource is held exclusively for the duration of its test.
- `FullV1Tests.test_labels_filter_and_resource_locks_serialize` **passed** (3.81 s): with
`--label fast` only `lab_a`/`lab_c` run; with 4 jobs the shared-resource test intervals in
`order.log` never overlap (a manual run shows `a-start a-end b-start b-end`).
- Full CTest: **8 / 8 passed** in 295.18 s.
## 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).
+2 -2
View File
@@ -15,7 +15,7 @@ build2 documentation was **not** available through Context7; build2 statements b
| Remote / distributed execution workers | Deferred | `20`, R-015 |
| VoidLibrary's own `build.cpp` | Open | `recipes/VoidLibrary/` builds it inside VBS, but VoidLibrary is not yet migrated |
| Installer generators | Partial | deterministic tar + self-extracting `sh` + SBOM + Ed25519; DEB/RPM/MSI/DMG-style generators missing |
| Test-runner parity | Partial | `VOID_TEST` runner; fixtures/labels/locks/timeouts/JUnit incomplete |
| Test-runner parity | Partial | `VOID_TEST` runner; labels/resource locks/timeouts/JUnit done; fixtures and CDash missing |
| IDE ecosystem | Partial | `vbs ide` + CompDB + daemon protocol; no File API shim, presets import, or plugins |
| CI on real runners, sanitizers, fuzzing | Unverified | the GitHub Actions workflow is a template that has never run |
@@ -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 (rpm 6.1-validated)**, **WiX source for MSI** (candle/light on Windows), 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; `vbs test --junit --test-timeout` | fixtures, labels, resource locks, CDash |
| 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 --label`; parallel tests with resource locks | fixtures, 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 |
+4
View File
@@ -201,6 +201,8 @@ struct TargetRecord {
std::vector<std::string> action_outputs;
std::string working_directory;
std::map<std::string, std::string, std::less<>> environment;
std::vector<std::string> labels; // Test labels for filtering (`vbs test --label`).
std::vector<std::string> resources; // Exclusive resources held while the test runs.
bool nondeterministic{false};
bool enabled{true};
bool use_conventional_sources{false};
@@ -284,6 +286,8 @@ class Target {
Target &outputs(std::vector<std::string> paths);
Target &working_directory(std::string directory);
Target &env(std::string key, std::string value);
Target &label(std::string label);
Target &resource(std::string name);
Target &nondeterministic(bool enabled = true);
Target &enabled(bool flag);
Target &install(std::string destination = {}, std::string component = "default");
+2
View File
@@ -98,6 +98,8 @@ struct ResolvedTargetSummary {
std::string name;
TargetKind kind{TargetKind::Executable};
bool enabled{true};
std::vector<std::string> labels;
std::vector<std::string> resources;
std::vector<std::filesystem::path> expanded_sources;
std::vector<std::filesystem::path> primary_outputs;
std::vector<std::filesystem::path> runtime_shared_libraries;
+14
View File
@@ -854,6 +854,18 @@ Target &Target::nondeterministic(bool enabled) {
return *this;
}
Target &Target::label(std::string label) {
require_text(label, "test label");
owner(owner_)->targets.at(index_).labels.push_back(std::move(label));
return *this;
}
Target &Target::resource(std::string name) {
require_text(name, "test resource");
owner(owner_)->targets.at(index_).resources.push_back(std::move(name));
return *this;
}
Target &Target::enabled(bool flag) {
owner(owner_)->targets.at(index_).enabled = flag;
return *this;
@@ -1222,6 +1234,8 @@ std::string Project::to_json() const {
",\"action_outputs\":" + json_array(target.action_outputs, json_quote) +
",\"working_directory\":" + json_quote(target.working_directory) +
",\"environment\":" + env_json(target.environment) +
",\"labels\":" + json_array(target.labels, json_quote) +
",\"resources\":" + json_array(target.resources, json_quote) +
",\"nondeterministic\":" + std::string{target.nondeterministic ? "true" : "false"} +
",\"enabled\":" + std::string{target.enabled ? "true" : "false"} +
",\"use_conventional_sources\":" +
+4
View File
@@ -331,6 +331,8 @@ ProjectDescription::from_json(std::string_view json_text) {
}
}
t.nondeterministic = get_bool(*to, "nondeterministic", false);
t.labels = get_str_array(*to, "labels");
t.resources = get_str_array(*to, "resources");
t.enabled = get_bool(*to, "enabled", true);
t.use_conventional_sources = get_bool(*to, "use_conventional_sources", false);
if (const auto *irv = find_key(*to, "install_rule")) {
@@ -741,6 +743,8 @@ lower_project_graph(const ProjectDescription &description,
summary.name = t.name;
summary.kind = t.kind;
summary.enabled = t.enabled;
summary.labels = t.labels;
summary.resources = t.resources;
// 1. Collect prerequisite action IDs (explicit depends_on + linked target producers).
std::vector<std::string> target_prereq_actions;
+141 -40
View File
@@ -54,6 +54,7 @@
#include <cctype>
#include <charconv>
#include <chrono>
#include <condition_variable>
#include <cstdint>
#include <cstdlib>
#include <filesystem>
@@ -371,6 +372,7 @@ struct BuildCmdOptions {
std::optional<std::string> build_arg;
std::vector<std::string> profiles;
std::vector<std::string> targets;
std::vector<std::string> labels;
std::vector<std::string> extra_build_sources;
std::optional<std::string> editor_profile;
std::optional<std::string> compiler_arg;
@@ -830,6 +832,24 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
}
if (run_tests) {
std::optional<std::filesystem::path> wine;
if (windows_cross_target) {
// Cross-built Windows test binaries execute under Wine (Track C3 Wine-first).
auto resolved = Platform::resolve_executable("wine");
if (!resolved) {
std::cerr << "vbs test: Windows target tests require 'wine' in PATH\n";
all_ok = false;
} else {
wine = *resolved;
}
}
struct TestJob {
std::string name;
std::filesystem::path executable;
std::vector<std::string> resources;
};
std::vector<TestJob> test_jobs;
for (const auto &t : graph->targets) {
if (t.kind != TargetKind::Test || t.primary_outputs.empty()) {
continue;
@@ -837,53 +857,133 @@ int execute_build_or_test(BuildCmdOptions opts, bool run_tests) {
if (!opts.targets.empty() && !std::ranges::contains(opts.targets, t.name)) {
continue;
}
Void::Log::info("Test", "[{}] Running test target '{}'...", prof_name, t.name);
const auto tsw = Void::Time::Stopwatch::started();
Platform::ProcessRequest treq;
if (windows_cross_target) {
// Cross-built Windows test binaries execute under Wine (Track C3 Wine-first).
auto wine = Platform::resolve_executable("wine");
if (!wine) {
std::cerr << "vbs test: Windows target tests require 'wine' in PATH\n";
all_ok = false;
if (!opts.labels.empty() &&
!std::ranges::any_of(opts.labels, [&](const std::string &label) {
return std::ranges::contains(t.labels, label);
})) {
continue;
}
test_jobs.push_back(TestJob{t.name, t.primary_outputs.front(), t.resources});
}
// Tests run in parallel up to --jobs, except that tests sharing a resource are
// serialized (a resource is held exclusively while its test runs).
std::vector<std::optional<TestRunRecord>> records(test_jobs.size());
std::mutex test_mutex;
std::condition_variable test_cv;
std::set<std::string> held_resources;
std::vector<bool> claimed(test_jobs.size(), false);
std::size_t remaining = test_jobs.size();
const std::size_t worker_count = std::max<std::size_t>(
1, std::min<std::size_t>(
jobs == 0 ? std::max(1u, std::thread::hardware_concurrency()) : jobs,
std::max<std::size_t>(1, test_jobs.size())));
const auto any_runnable = [&] {
for (std::size_t i = 0; i < test_jobs.size(); ++i) {
if (claimed[i]) {
continue;
}
treq.executable = *wine;
treq.arguments = {t.primary_outputs.front().string()};
} else {
treq.executable = t.primary_outputs.front();
}
treq.working_directory = project_root;
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());
std::cerr << "vbs test: FAILED '" << t.name << "'\n";
if (tres && !tres->stdout_data.empty()) {
std::cerr << tres->stdout_data << '\n';
if (std::ranges::none_of(test_jobs[i].resources, [&](const std::string &r) {
return held_resources.contains(r);
})) {
return true;
}
if (tres && !tres->stderr_data.empty()) {
std::cerr << tres->stderr_data << '\n';
}
return false;
};
const auto worker = [&] {
for (;;) {
std::size_t index = 0;
{
std::unique_lock lock{test_mutex};
test_cv.wait(lock, [&] { return remaining == 0 || any_runnable(); });
if (remaining == 0) {
return;
}
for (; index < test_jobs.size(); ++index) {
if (claimed[index]) {
continue;
}
if (std::ranges::none_of(test_jobs[index].resources,
[&](const std::string &r) {
return held_resources.contains(r);
})) {
break;
}
}
claimed[index] = true;
for (const auto &r : test_jobs[index].resources) {
held_resources.insert(r);
}
}
const auto &job = test_jobs[index];
Void::Log::info("Test", "[{}] Running test target '{}'...", prof_name,
job.name);
const auto tsw = Void::Time::Stopwatch::started();
Platform::ProcessRequest treq;
if (wine) {
treq.executable = *wine;
treq.arguments = {job.executable.string()};
} else {
treq.executable = job.executable;
}
treq.working_directory = project_root;
treq.timeout = std::chrono::seconds{test_timeout_seconds};
auto tres = Platform::run_supervised(treq);
TestRunRecord record;
record.profile = prof_name;
record.name = job.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();
}
const bool passed = record.passed;
if (!passed) {
Void::Log::error("Test", "[{}] FAILED '{}' ({:.0f} ms)", prof_name,
job.name, tsw.elapsed_ms());
} else {
Void::Log::info("Test", "[{}] PASSED '{}' ({:.0f} ms)", prof_name, job.name,
tsw.elapsed_ms());
}
{
std::lock_guard lock{test_mutex};
for (const auto &r : job.resources) {
held_resources.erase(r);
}
records[index] = std::move(record);
--remaining;
}
test_cv.notify_all();
}
};
std::vector<std::thread> pool;
pool.reserve(worker_count);
if (!windows_cross_target || wine.has_value()) {
for (std::size_t i = 0; i < worker_count; ++i) {
pool.emplace_back(worker);
}
for (auto &thread : pool) {
thread.join();
}
}
for (auto &record : records) {
if (!record) {
continue;
}
if (!record->passed) {
std::cerr << "vbs test: FAILED '" << record->name << "'\n";
if (!record->output.empty()) {
std::cerr << record->output << '\n';
}
all_ok = false;
} else {
Void::Log::info("Test", "[{}] PASSED '{}' ({:.0f} ms)", prof_name, t.name,
tsw.elapsed_ms());
std::cout << "vbs test: PASSED '" << t.name << "'\n";
std::cout << "vbs test: PASSED '" << record->name << "'\n";
}
test_records.push_back(std::move(*record));
}
}
}
@@ -3166,6 +3266,7 @@ int main(int argc, char **argv) {
.option("--build-dir", "-B", "Build output directory", build_opts.build_arg)
.option_many("--profile", "-p", "Profile to build", build_opts.profiles)
.option_many("--target", "-t", "Target to build/test", build_opts.targets)
.option_many("--label", "", "Only run tests carrying this label", build_opts.labels)
.option("--compiler", "", "Override compiler family (gcc|clang)",
build_opts.compiler_arg)
.option("--target-os", "", "Target operating system (default: host, e.g. windows)",
+100
View File
@@ -2113,6 +2113,106 @@ VOID_TEST(FullV1Tests, cli_init_graph_clean_doctor_end_to_end) {
Void::Testing::expect(!std::filesystem::exists(bdir));
}
// === Test-runner parity: labels filter and exclusive resource locks ===
VOID_TEST(FullV1Tests, test_labels_filter_and_resource_locks_serialize) {
const auto vbs_bin = locate_vbs_binary();
Void::Testing::expect(!vbs_bin.empty() && std::filesystem::exists(vbs_bin));
if (vbs_bin.empty() || !std::filesystem::exists(vbs_bin)) {
return;
}
Void::FileSystem::TempDir tmp{"vbs_labels_"};
const auto proj = tmp / "proj";
const auto bdir = tmp / "build";
write_file(proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
void build(Void::Build::Project &p) {
p.test("lab_a")
.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"tests/a.cpp"})
.label("fast")
.resource("shared");
p.test("lab_b")
.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"tests/b.cpp"})
.label("slow")
.resource("shared");
p.test("lab_c")
.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"tests/c.cpp"})
.label("fast");
}
)cpp");
for (const char name : {'a', 'b', 'c'}) {
write_file(proj / "tests" / (std::string{name} + ".cpp"),
"#include <chrono>\n"
"#include <fstream>\n"
"#include <thread>\n"
"int main() {\n"
" { std::ofstream out{\"order.log\", std::ios::app}; out << \"" +
std::string{name} +
"-start\\n\"; }\n"
" std::this_thread::sleep_for(std::chrono::milliseconds{150});\n"
" { std::ofstream out{\"order.log\", std::ios::app}; out << \"" +
std::string{name} +
"-end\\n\"; }\n"
" return 0;\n"
"}\n");
}
auto run_vbs = [&](std::vector<std::string> args) {
Platform::ProcessRequest req;
req.executable = vbs_bin;
req.arguments = std::move(args);
req.timeout = std::chrono::seconds{300};
return Platform::run_supervised(req);
};
// Label filtering: only 'fast' tests run.
auto filtered = run_vbs({"test", "--project", proj.string(), "--build-dir", bdir.string(),
"--label", "fast", "--jobs", "4"});
Void::Testing::expect(filtered.has_value() && filtered->succeeded());
if (filtered) {
Void::Testing::expect(filtered->stdout_data.find("PASSED 'lab_a'") != std::string::npos);
Void::Testing::expect(filtered->stdout_data.find("PASSED 'lab_c'") != std::string::npos);
Void::Testing::expect(filtered->stdout_data.find("lab_b") == std::string::npos);
}
// Resource serialization: lab_a and lab_b share 'shared', so their start/end intervals
// must never overlap even with 4 parallel jobs.
std::filesystem::remove(proj / "order.log");
auto all =
run_vbs({"test", "--project", proj.string(), "--build-dir", bdir.string(), "--jobs", "4"});
Void::Testing::expect(all.has_value() && all->succeeded());
auto order_text = Void::FileSystem::read_file(proj / "order.log");
Void::Testing::require(order_text.has_value());
std::set<std::string> running;
bool overlapped = false;
std::size_t starts = 0;
for (std::size_t pos = 0; pos < order_text->size();) {
const auto eol = order_text->find('\n', pos);
const std::string line = order_text->substr(pos, eol - pos);
pos = eol == std::string::npos ? order_text->size() : eol + 1;
if (line.size() < 5) {
continue;
}
const std::string who = line.substr(0, 1);
const bool is_start = line.ends_with("-start");
if (is_start) {
++starts;
if (who == "a" || who == "b") {
if (running.contains("a") || running.contains("b")) {
overlapped = true;
}
running.insert(who);
}
} else if (who == "a" || who == "b") {
running.erase(who);
}
}
Void::Testing::expect_eq(starts, std::size_t{3});
Void::Testing::expect(!overlapped);
}
// === Track A1: Native VBS subproject dependency (builder == "native", zero CMake!) ===
VOID_TEST(FullV1Tests, native_vbs_subproject_dependency_builds_without_cmake) {
const auto vbs_bin = locate_vbs_binary();