feat(package,daemon): yank releases from the CLI; report workspace and lockfile in info
This commit is contained in:
1 parent
f5eb489e79
commit
1a4c062021
11 files changed
+249
-20
No files matched your search
@@ -1661,6 +1661,21 @@ VOID_TEST(Daemon, info_reports_daemon_paths_and_host) {
|
||||
Void::Testing::expect(!str_field(*info, "version").empty());
|
||||
Void::Testing::expect_eq(str_field(*info, "project_root"), options.project_root.string());
|
||||
Void::Testing::expect_eq(str_field(*info, "build_root"), options.build_root.string());
|
||||
const auto *workspace = field(*info, "workspace");
|
||||
Void::Testing::require(workspace != nullptr);
|
||||
Void::Testing::expect(std::holds_alternative<bool>(workspace->value));
|
||||
Void::Testing::expect(!bool_field(*info, "workspace", true));
|
||||
const auto *lockfile_value = field(*info, "lockfile");
|
||||
Void::Testing::require(lockfile_value != nullptr);
|
||||
const auto *lockfile = as_object(*lockfile_value);
|
||||
Void::Testing::require(lockfile != nullptr);
|
||||
Void::Testing::expect(str_field(*lockfile, "path").find("vbs.lock") != std::string::npos);
|
||||
Void::Testing::expect_eq(str_field(*lockfile, "path"),
|
||||
(options.project_root / "vbs.lock").string());
|
||||
const auto *lockfile_exists = field(*lockfile, "exists");
|
||||
Void::Testing::require(lockfile_exists != nullptr);
|
||||
Void::Testing::expect(std::holds_alternative<bool>(lockfile_exists->value));
|
||||
Void::Testing::expect(!bool_field(*lockfile, "exists", true));
|
||||
Void::Testing::expect_eq(str_field(*info, "socket"), socket.string());
|
||||
Void::Testing::expect_eq(
|
||||
str_field(*info, "host_os"),
|
||||
@@ -1692,6 +1707,98 @@ VOID_TEST(Daemon, info_reports_daemon_paths_and_host) {
|
||||
Void::Testing::expect(std::holds_alternative<bool>(net_backend->value));
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, info_reports_workspace_and_lockfile) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
const auto options = make_options(temp->path());
|
||||
|
||||
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}));
|
||||
|
||||
// A lockfile created after startup must be reported by the next info request.
|
||||
auto before = request_object(socket, R"({"op":"info"})");
|
||||
Void::Testing::require(before.has_value());
|
||||
const auto *before_value = field(*before, "lockfile");
|
||||
Void::Testing::require(before_value != nullptr);
|
||||
const auto *before_lockfile = as_object(*before_value);
|
||||
Void::Testing::require(before_lockfile != nullptr);
|
||||
Void::Testing::expect(!bool_field(*before_lockfile, "exists", true));
|
||||
|
||||
{
|
||||
std::ofstream lockfile{options.project_root / "vbs.lock"};
|
||||
lockfile << "{}\n";
|
||||
Void::Testing::require(lockfile.good());
|
||||
}
|
||||
auto after = request_object(socket, R"({"op":"info"})");
|
||||
Void::Testing::require(after.has_value());
|
||||
const auto *after_value = field(*after, "lockfile");
|
||||
Void::Testing::require(after_value != nullptr);
|
||||
const auto *after_lockfile = as_object(*after_value);
|
||||
Void::Testing::require(after_lockfile != nullptr);
|
||||
Void::Testing::expect(bool_field(*after_lockfile, "exists"));
|
||||
Void::Testing::expect_eq(str_field(*after_lockfile, "path"),
|
||||
(options.project_root / "vbs.lock").string());
|
||||
|
||||
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());
|
||||
|
||||
// Workspace roots report workspace=true, and lockfile path/exists follow lock_root.
|
||||
auto workspace_temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(workspace_temp.has_value());
|
||||
auto workspace_options = make_options(workspace_temp->path());
|
||||
const auto workspace_root = workspace_options.project_root;
|
||||
{
|
||||
std::ofstream workspace{workspace_root / "workspace.cpp"};
|
||||
workspace << "#include <Void/Build.hpp>\n"
|
||||
"void workspace(Void::Build::Workspace &workspace) {\n"
|
||||
" workspace.member(\"lib\", \"packages/lib\");\n"
|
||||
"}\n";
|
||||
Void::Testing::require(workspace.good());
|
||||
}
|
||||
std::filesystem::create_directories(workspace_root / "packages" / "lib");
|
||||
const auto lock_root = workspace_temp->path() / "lock-root";
|
||||
std::filesystem::create_directories(lock_root);
|
||||
{
|
||||
std::ofstream lockfile{lock_root / "vbs.lock"};
|
||||
lockfile << "{}\n";
|
||||
Void::Testing::require(lockfile.good());
|
||||
}
|
||||
workspace_options.lock_root = lock_root;
|
||||
|
||||
auto workspace_server = Void::Build::Daemon::DaemonServer::create(workspace_options);
|
||||
Void::Testing::require(workspace_server.has_value());
|
||||
const auto workspace_socket = workspace_server->socket_path();
|
||||
|
||||
Void::Result::Result<void, Void::Result::Error> workspace_run_result;
|
||||
std::jthread workspace_worker{[&] { workspace_run_result = workspace_server->run(); }};
|
||||
Void::Testing::require(wait_for_path(workspace_socket, std::chrono::seconds{5}));
|
||||
|
||||
auto workspace_info = request_object(workspace_socket, R"({"op":"info"})");
|
||||
Void::Testing::require(workspace_info.has_value());
|
||||
Void::Testing::expect(bool_field(*workspace_info, "workspace"));
|
||||
Void::Testing::expect_eq(str_field(*workspace_info, "lock_root"), lock_root.string());
|
||||
const auto *workspace_value = field(*workspace_info, "lockfile");
|
||||
Void::Testing::require(workspace_value != nullptr);
|
||||
const auto *workspace_lockfile = as_object(*workspace_value);
|
||||
Void::Testing::require(workspace_lockfile != nullptr);
|
||||
Void::Testing::expect_eq(str_field(*workspace_lockfile, "path"),
|
||||
(lock_root / "vbs.lock").string());
|
||||
Void::Testing::expect(bool_field(*workspace_lockfile, "exists"));
|
||||
|
||||
auto workspace_shutdown =
|
||||
Void::Build::Daemon::request(workspace_socket, R"({"op":"shutdown"})");
|
||||
Void::Testing::expect(workspace_shutdown.has_value());
|
||||
workspace_worker.join();
|
||||
Void::Testing::expect(workspace_run_result.has_value());
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, doctor_reports_host_tools_and_backends) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
|
||||
Reference in new issue
Block a user