feat(daemon): report per-unit compile arguments; deepen registry search tests
This commit is contained in:
1 parent
2b18a0331a
commit
624016d904
9 files changed
+335
-27
No files matched your search
@@ -1631,6 +1631,75 @@ VOID_TEST(Daemon, init_scaffolds_project_confined_to_root) {
|
||||
Void::Testing::expect(!bool_field(*escaped, "ok", true));
|
||||
}
|
||||
|
||||
VOID_TEST(Daemon, target_flags_reports_compile_units) {
|
||||
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 all = request_object(socket, R"({"op":"target_flags","target":"app"})",
|
||||
std::chrono::seconds{120});
|
||||
auto filtered = request_object(
|
||||
socket, R"({"op":"target_flags","target":"app","file":"nope.cpp"})",
|
||||
std::chrono::seconds{120});
|
||||
auto unknown = request_object(socket, R"({"op":"target_flags","target":"nope"})",
|
||||
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(all.has_value());
|
||||
Void::Testing::expect(bool_field(*all, "ok"));
|
||||
Void::Testing::expect_eq(str_field(*all, "target"), std::string{"app"});
|
||||
const auto *units = field(*all, "units");
|
||||
Void::Testing::require(units != nullptr);
|
||||
const auto *unit_array = std::get_if<JsonValue::Array>(&units->value);
|
||||
Void::Testing::require(unit_array != nullptr && !unit_array->empty());
|
||||
const auto *first = std::get_if<JsonObject>(&unit_array->front().value);
|
||||
Void::Testing::require(first != nullptr);
|
||||
Void::Testing::expect(str_field(*first, "source").find("main.cpp") != std::string::npos);
|
||||
const auto *arguments = field(*first, "arguments");
|
||||
Void::Testing::require(arguments != nullptr);
|
||||
const auto *argument_array = std::get_if<JsonValue::Array>(&arguments->value);
|
||||
Void::Testing::require(argument_array != nullptr && !argument_array->empty());
|
||||
|
||||
Void::Testing::require(filtered.has_value());
|
||||
Void::Testing::expect(bool_field(*filtered, "ok"));
|
||||
const auto *filtered_units = field(*filtered, "units");
|
||||
Void::Testing::require(filtered_units != nullptr);
|
||||
const auto *filtered_array = std::get_if<JsonValue::Array>(&filtered_units->value);
|
||||
Void::Testing::require(filtered_array != nullptr);
|
||||
Void::Testing::expect(filtered_array->empty());
|
||||
|
||||
Void::Testing::require(unknown.has_value());
|
||||
Void::Testing::expect(!bool_field(*unknown, "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