feat(registry,daemon): patch package metadata; report workspace info
This commit is contained in:
1 parent
85ff7a8c75
commit
e7698a411d
8 files changed
+250
-4
No files matched your search
@@ -1113,6 +1113,94 @@ VOID_TEST(Daemon, workspace_members_lists_declared_members) {
|
||||
Void::Testing::expect(raw->find("packages/lib") != std::string::npos);
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, workspace_info_reports_members_and_lockfile) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
const auto options = make_options(temp->path());
|
||||
const auto ws = options.project_root;
|
||||
|
||||
{
|
||||
std::ofstream workspace{ws / "workspace.cpp"};
|
||||
workspace << "#include <Void/Build.hpp>\n"
|
||||
"void workspace(Void::Build::Workspace &workspace) {\n"
|
||||
" workspace.member(\"lib\", \"packages/lib\");\n"
|
||||
" workspace.member(\"app\", \"packages/app\");\n"
|
||||
"}\n";
|
||||
Void::Testing::require(workspace.good());
|
||||
}
|
||||
std::filesystem::create_directories(ws / "packages" / "lib");
|
||||
std::filesystem::create_directories(ws / "packages" / "app");
|
||||
{
|
||||
std::ofstream lockfile{ws / "vbs.lock"};
|
||||
lockfile << "{}\n";
|
||||
Void::Testing::require(lockfile.good());
|
||||
}
|
||||
|
||||
auto server = Void::Build::Daemon::DaemonServer::create(options);
|
||||
Void::Testing::require(server.has_value());
|
||||
const auto socket = server->socket_path();
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error> run_result;
|
||||
std::jthread worker{[&] { run_result = server->run(); }};
|
||||
Void::Testing::require(wait_for_path(socket, std::chrono::seconds{5}));
|
||||
|
||||
auto raw = Void::Build::Daemon::request(socket, R"({"op":"workspace_info"})",
|
||||
std::chrono::seconds{120});
|
||||
auto shutdown = Void::Build::Daemon::request(socket, R"({"op":"shutdown"})");
|
||||
Void::Testing::expect(shutdown.has_value());
|
||||
worker.join();
|
||||
Void::Testing::expect(run_result.has_value());
|
||||
|
||||
Void::Testing::require(raw.has_value());
|
||||
const auto parsed = parse_json(*raw);
|
||||
Void::Testing::require(parsed.has_value());
|
||||
const auto *object = as_object(*parsed);
|
||||
Void::Testing::require(object != nullptr);
|
||||
Void::Testing::expect(bool_field(*object, "ok"));
|
||||
Void::Testing::expect_eq(str_field(*object, "op"), std::string{"workspace_info"});
|
||||
Void::Testing::expect(bool_field(*object, "workspace"));
|
||||
Void::Testing::expect(raw->find("\"name\":\"lib\"") != std::string::npos);
|
||||
Void::Testing::expect(raw->find("\"name\":\"app\"") != std::string::npos);
|
||||
const auto *lockfile_value = field(*object, "lockfile");
|
||||
Void::Testing::require(lockfile_value != nullptr);
|
||||
const auto *lockfile_object = as_object(*lockfile_value);
|
||||
Void::Testing::require(lockfile_object != nullptr);
|
||||
Void::Testing::expect(bool_field(*lockfile_object, "exists"));
|
||||
Void::Testing::expect(int_field(*lockfile_object, "size_bytes") > 0);
|
||||
Void::Testing::expect(str_field(*lockfile_object, "path").find("vbs.lock") !=
|
||||
std::string::npos);
|
||||
|
||||
// A plain project is not a workspace and reports a null lockfile.
|
||||
auto plain_temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(plain_temp.has_value());
|
||||
const auto plain_options = make_options(plain_temp->path());
|
||||
auto plain_server = Void::Build::Daemon::DaemonServer::create(plain_options);
|
||||
Void::Testing::require(plain_server.has_value());
|
||||
const auto plain_socket = plain_server->socket_path();
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error> plain_run_result;
|
||||
std::jthread plain_worker{[&] { plain_run_result = plain_server->run(); }};
|
||||
Void::Testing::require(wait_for_path(plain_socket, std::chrono::seconds{5}));
|
||||
|
||||
auto plain = request_object(plain_socket, R"({"op":"workspace_info"})");
|
||||
auto plain_shutdown = Void::Build::Daemon::request(plain_socket, R"({"op":"shutdown"})");
|
||||
Void::Testing::expect(plain_shutdown.has_value());
|
||||
plain_worker.join();
|
||||
Void::Testing::expect(plain_run_result.has_value());
|
||||
|
||||
Void::Testing::require(plain.has_value());
|
||||
Void::Testing::expect(bool_field(*plain, "ok"));
|
||||
Void::Testing::expect(!bool_field(*plain, "workspace", true));
|
||||
const auto *plain_members = field(*plain, "members");
|
||||
Void::Testing::require(plain_members != nullptr);
|
||||
const auto *plain_members_array = std::get_if<JsonValue::Array>(&plain_members->value);
|
||||
Void::Testing::require(plain_members_array != nullptr);
|
||||
Void::Testing::expect(plain_members_array->empty());
|
||||
const auto *plain_lockfile = field(*plain, "lockfile");
|
||||
Void::Testing::require(plain_lockfile != nullptr);
|
||||
Void::Testing::expect(std::holds_alternative<std::nullptr_t>(plain_lockfile->value));
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, ide_configs_reports_generated_files) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
|
||||
Reference in new issue
Block a user