feat(daemon): list editor generation history
This commit is contained in:
1 parent
ba682e8bd1
commit
41a74bc925
8 files changed
+217
-2
No files matched your search
@@ -67,6 +67,7 @@ check_process(0 "Usage: vbs daemon graph .*--format" "" daemon graph --help)
|
||||
check_process(0 "Usage: vbs daemon test .*--profile.*--target.*--jobs" "" daemon test --help)
|
||||
check_process(0 "Usage: vbs daemon workspace members " "" daemon workspace members --help)
|
||||
check_process(0 "Usage: vbs daemon ide configs " "" daemon ide configs --help)
|
||||
check_process(0 "Usage: vbs daemon compdb generations .*--profile" "" daemon compdb generations --help)
|
||||
check_process(0 "Usage: vbs daemon ide wait .*--timeout-ms" "" daemon ide wait --help)
|
||||
check_process(2 "" "missing subcommand for 'vbs daemon'" daemon)
|
||||
|
||||
|
||||
@@ -1088,6 +1088,74 @@ void build(Void::Build::Project &project) {
|
||||
Void::Testing::expect(run_result.has_value());
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, compdb_generations_lists_history_and_active_generation) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
const auto options = make_options(temp->path());
|
||||
|
||||
{
|
||||
std::ofstream descriptor{options.project_root / "build.cpp"};
|
||||
descriptor << R"cpp(#include <Void/Build.hpp>
|
||||
|
||||
void build(Void::Build::Project &project) {
|
||||
auto app = project.executable("app");
|
||||
app.sources({"main.cpp"});
|
||||
}
|
||||
)cpp";
|
||||
Void::Testing::require(descriptor.good());
|
||||
}
|
||||
{
|
||||
std::ofstream source{options.project_root / "main.cpp"};
|
||||
source << "int main() { return 0; }\n";
|
||||
Void::Testing::require(source.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 empty = request_object(socket, R"({"op":"compdb_generations","profile":"debug"})");
|
||||
Void::Testing::require(empty.has_value());
|
||||
Void::Testing::expect(bool_field(*empty, "ok"));
|
||||
Void::Testing::expect(string_array_field(*empty, "generations").empty());
|
||||
|
||||
auto exported = request_object(socket, R"({"op":"compdb_export"})", std::chrono::seconds{120});
|
||||
Void::Testing::require(exported.has_value());
|
||||
Void::Testing::expect(bool_field(*exported, "ok"));
|
||||
|
||||
auto raw = Void::Build::Daemon::request(
|
||||
socket, R"({"op":"compdb_generations","profile":"debug"})", std::chrono::seconds{120});
|
||||
auto invalid = request_object(socket, R"({"op":"compdb_generations","profile":"../x"})");
|
||||
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, "profile"), std::string{"debug"});
|
||||
const auto *generations = field(*object, "generations");
|
||||
Void::Testing::require(generations != nullptr);
|
||||
const auto *generation_array = std::get_if<JsonValue::Array>(&generations->value);
|
||||
Void::Testing::require(generation_array != nullptr && !generation_array->empty());
|
||||
const auto *first = std::get_if<JsonObject>(&generation_array->front().value);
|
||||
Void::Testing::require(first != nullptr);
|
||||
Void::Testing::expect(str_field(*first, "status") == "valid");
|
||||
Void::Testing::expect(int_field(*first, "entries") >= 1);
|
||||
Void::Testing::expect(raw->find("\"active\":\"") != std::string::npos);
|
||||
|
||||
Void::Testing::require(invalid.has_value());
|
||||
Void::Testing::expect(!bool_field(*invalid, "ok", true));
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, describe_empty_project_reports_zero_targets) {
|
||||
auto temp = Void::FileSystem::TempDir::open("vbs_daemon_");
|
||||
Void::Testing::require(temp.has_value());
|
||||
|
||||
Reference in new issue
Block a user