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
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:
1 parent
e135ae3023
commit
617d783e84
10 files changed
+281
-42
No files matched your search
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user