feat(test): report results to CDash
VoidBuildSystem CI / sanitizers-gcc16 (push) Failing after 10s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 14s
VoidBuildSystem CI / fuzz-clang (push) Failing after 8s
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 7s
VoidBuildSystem CI / wine-windows-gcc16 (push) Failing after 54s

This commit is contained in:
faumaray committed 2026-12-05 13:02:45 +03:00
1 parent 6befa6b5e2
commit 9d7c801e2d
9 files changed
+458 -2

No files matched your search

+83
View File
@@ -2267,3 +2267,86 @@ VOID_TEST(RegistryTests, worker_action_queue_enqueue_lease_and_complete) {
}
(*svc)->stop_http();
}
// `vbs test --cdash-output FILE --cdash URL`: writes a CDash Test.xml report and submits it as
// multipart/form-data to submit.php (captured by a loopback HTTP server).
VOID_TEST(RegistryTests, cdash_test_report_output_and_submission) {
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_cdash_"};
const auto proj = tmp / "proj";
const auto bdir = tmp / "build";
std::filesystem::create_directories(proj / "tests");
(void)Platform::atomic_write_file(proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
void build(Void::Build::Project &p) {
p.test("cdn_pass")
.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"tests/pass.cpp"})
.label("cdash");
p.test("cdn_fail")
.cxx_standard(Void::Build::CxxStandard::Cxx26)
.sources({"tests/fail.cpp"})
.label("cdash");
}
)cpp",
false);
(void)Platform::atomic_write_file(proj / "tests" / "pass.cpp", "int main() { return 0; }\n",
false);
(void)Platform::atomic_write_file(proj / "tests" / "fail.cpp", "int main() { return 1; }\n",
false);
std::mutex capture_mutex;
std::string captured_body;
std::string captured_type;
std::string captured_target;
HttpServer server;
auto started = server.start({}, [&](const HttpRequest &req) {
std::lock_guard lock{capture_mutex};
captured_body = req.body;
captured_target = req.raw_target;
if (const auto it = req.headers.find("content-type"); it != req.headers.end()) {
captured_type = it->second;
}
return HttpResponse::json(200, "{}");
});
Void::Testing::require(started.has_value());
const std::string cdash_url = "http://127.0.0.1:" + std::to_string(server.bound_port());
const auto report_path = tmp / "Test.xml";
Platform::ProcessRequest req;
req.executable = vbs_bin;
req.arguments = {"test", "--project", proj.string(),
"--build-dir", bdir.string(), "--label",
"cdash", "--cdash-output", report_path.string(),
"--cdash", cdash_url, "--cdash-project",
"Demo"};
req.timeout = std::chrono::seconds{300};
auto res = Platform::run_supervised(req);
// The intentionally failing test fails the run, but the report is still produced.
Void::Testing::expect(res.has_value() && !res->succeeded());
auto xml = Void::FileSystem::read_file(report_path);
Void::Testing::require(xml.has_value());
Void::Testing::expect(xml->find("<Site BuildName=\"vbs\"") != std::string::npos);
Void::Testing::expect(xml->find("<Test Status=\"passed\">") != std::string::npos);
Void::Testing::expect(xml->find("<Test Status=\"failed\">") != std::string::npos);
Void::Testing::expect(xml->find("<Name>cdn_pass</Name>") != std::string::npos);
Void::Testing::expect(xml->find("<Name>cdn_fail</Name>") != std::string::npos);
{
std::lock_guard lock{capture_mutex};
Void::Testing::expect(!captured_body.empty());
Void::Testing::expect(captured_target.find("submit.php") != std::string::npos);
Void::Testing::expect(captured_target.find("project=Demo") != std::string::npos);
Void::Testing::expect(captured_type.find("multipart/form-data") != std::string::npos);
Void::Testing::expect(captured_body.find("name=\"type\"") != std::string::npos);
Void::Testing::expect(captured_body.find("\r\nTest\r\n") != std::string::npos);
Void::Testing::expect(captured_body.find("name=\"content\"; filename=\"Test.xml\"") !=
std::string::npos);
Void::Testing::expect(captured_body.find("<Site BuildName=\"vbs\"") != std::string::npos);
}
server.stop();
}