## Summary - The `eventide` dep was renamed to [kotatsu](https://github.com/clice-io/kotatsu) with a broad rename of CMake identifiers, namespaces, header paths, and a few module reorgs (`serde` → `codec`, `reflection` → `meta`, `common` → `support`). Align clice to the new names. - CMake: FetchContent target, option prefix (`ETD_*` → `KOTA_*`, `ETD_SERDE_*` → `KOTA_CODEC_*`), target names (`eventide::{ipc::lsp,serde::toml,deco,zest}` → `kota::{ipc::lsp,codec::toml,deco,zest}`). - Namespaces: `eventide::` → `kota::`, `eventide::serde::` → `kota::codec::`, `eventide::refl::` → `kota::meta::`. The short `et` alias is dropped — all usages now spell `kota::` directly. - Headers: `eventide/*` → `kota/*`, including special cases `serde/serde/raw_value.h` → `codec/raw_value.h`, `ipc/json_codec.h` → `ipc/codec/json.h`, `common/meta.h` → `support/type_traits.h`, `common/ranges.h` → `support/ranges.h`. - Kotatsu split `JsonPeer` / `BincodePeer` out of `ipc/peer.h` into the codec-specific headers; added `kota/ipc/codec/{json,bincode}.h` includes where those types are used. - Depends on clice-io/kotatsu#110 (already merged) to prevent `-Wall -Wextra -Werror` from transitively propagating out of `kota::project_options`. ## Test plan - [x] `pixi run unit-test RelWithDebInfo` — 518/518 pass (9 skipped, unchanged from main) - [x] `pixi run integration-test RelWithDebInfo` — 119/119 pass - [x] `pixi run smoke-test RelWithDebInfo` — 2/2 pass - [x] `pixi run format` clean ## Notes - `tests/smoke/rapid_edit.jsonl` was intentionally left untouched: the embedded `#include "eventide/..."` strings are frozen snapshots of file contents the client sent at record time, not clice source. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated internal dependencies from `eventide` to `kota`, including async runtime, IPC transport, serialization codec, and metadata libraries. * Updated build configuration and CMake variables to align with the new dependency. * **Refactor** * Migrated internal implementation to use `kota` namespace and APIs throughout the codebase. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
287 lines
8.1 KiB
C++
287 lines
8.1 KiB
C++
#include <string>
|
|
#include <vector>
|
|
|
|
#include "test/test.h"
|
|
#include "server/protocol.h"
|
|
#include "server/worker_test_helpers.h"
|
|
|
|
#include "kota/codec/bincode/bincode.h"
|
|
#include "kota/codec/raw_value.h"
|
|
|
|
namespace clice::testing {
|
|
|
|
namespace {
|
|
|
|
// ============================================================================
|
|
// Bincode Serialization Tests
|
|
// ============================================================================
|
|
|
|
TEST_SUITE(BincodeRoundTrip) {
|
|
|
|
TEST_CASE(CompileParamsRoundTrip) {
|
|
namespace bincode = kota::codec::bincode;
|
|
|
|
worker::CompileParams params;
|
|
params.path = "/tmp/test.cpp";
|
|
params.version = 1;
|
|
params.text = "int main() { return 0; }";
|
|
params.directory = "/tmp";
|
|
params.arguments = {"clang++", "-c", "test.cpp"};
|
|
params.pch = {"", 0};
|
|
params.pcms = {};
|
|
|
|
auto bytes = bincode::to_bytes(params);
|
|
ASSERT_TRUE(bytes.has_value());
|
|
|
|
worker::CompileParams result;
|
|
auto status =
|
|
bincode::from_bytes(std::span<const std::byte>(bytes->data(), bytes->size()), result);
|
|
ASSERT_TRUE(status.has_value());
|
|
|
|
EXPECT_EQ(result.path, params.path);
|
|
EXPECT_EQ(result.version, params.version);
|
|
EXPECT_EQ(result.text, params.text);
|
|
EXPECT_EQ(result.directory, params.directory);
|
|
EXPECT_EQ(result.arguments.size(), params.arguments.size());
|
|
}
|
|
|
|
TEST_CASE(CompileResultRoundTrip) {
|
|
namespace bincode = kota::codec::bincode;
|
|
|
|
worker::CompileResult result;
|
|
result.version = 1;
|
|
result.diagnostics = {}; // empty
|
|
result.memory_usage = 0;
|
|
|
|
auto bytes = bincode::to_bytes(result);
|
|
ASSERT_TRUE(bytes.has_value());
|
|
|
|
worker::CompileResult decoded;
|
|
auto status =
|
|
bincode::from_bytes(std::span<const std::byte>(bytes->data(), bytes->size()), decoded);
|
|
ASSERT_TRUE(status.has_value());
|
|
EXPECT_EQ(decoded.version, result.version);
|
|
}
|
|
|
|
}; // TEST_SUITE(BincodeRoundTrip)
|
|
|
|
// ============================================================================
|
|
// StatelessWorker Tests
|
|
// ============================================================================
|
|
|
|
TEST_SUITE(StatelessWorker) {
|
|
|
|
TEST_CASE(SpawnAndExit) {
|
|
WorkerHandle w;
|
|
ASSERT_TRUE(w.spawn("stateless-worker"));
|
|
|
|
// Close stdin pipe to signal worker to exit.
|
|
w.peer->close_output();
|
|
w.loop.schedule(w.peer->run());
|
|
w.loop.run();
|
|
}
|
|
|
|
TEST_CASE(BuildPCHRequest) {
|
|
TempDir tmp;
|
|
tmp.touch("test_pch.h", "#pragma once\nint pch_global = 42;\n");
|
|
auto hdr = tmp.path("test_pch.h");
|
|
|
|
WorkerHandle w;
|
|
ASSERT_TRUE(w.spawn("stateless-worker"));
|
|
|
|
bool test_done = false;
|
|
|
|
w.run([&]() -> kota::task<> {
|
|
worker::BuildParams params;
|
|
params.kind = worker::BuildKind::BuildPCH;
|
|
params.file = hdr;
|
|
params.directory = "/tmp";
|
|
params.arguments =
|
|
{"clang++", "-resource-dir", std::string(resource_dir()), "-x", "c++-header", hdr};
|
|
params.text = "#pragma once\nint pch_global = 42;\n";
|
|
params.output_path = tmp.path("test_pch.pch");
|
|
|
|
auto result = co_await w.peer->send_request(params);
|
|
EXPECT_TRUE(result.has_value());
|
|
if(!result.has_value()) {
|
|
w.peer->close_output();
|
|
co_return;
|
|
}
|
|
EXPECT_TRUE(result.value().success);
|
|
EXPECT_FALSE(result.value().output_path.empty());
|
|
test_done = true;
|
|
w.peer->close_output();
|
|
});
|
|
|
|
ASSERT_TRUE(test_done);
|
|
}
|
|
|
|
TEST_CASE(IndexRequest) {
|
|
TempDir tmp;
|
|
tmp.touch("test_index.cpp", "int indexed_var = 1;\n");
|
|
auto src = tmp.path("test_index.cpp");
|
|
|
|
WorkerHandle w;
|
|
ASSERT_TRUE(w.spawn("stateless-worker"));
|
|
|
|
bool test_done = false;
|
|
|
|
w.run([&]() -> kota::task<> {
|
|
worker::BuildParams params;
|
|
params.kind = worker::BuildKind::Index;
|
|
params.file = src;
|
|
params.directory = "/tmp";
|
|
params.arguments = make_args(src);
|
|
|
|
auto result = co_await w.peer->send_request(params);
|
|
EXPECT_TRUE(result.has_value());
|
|
test_done = true;
|
|
w.peer->close_output();
|
|
});
|
|
|
|
ASSERT_TRUE(test_done);
|
|
}
|
|
|
|
}; // TEST_SUITE(StatelessWorker)
|
|
|
|
// ============================================================================
|
|
// StatelessWorker Extended Tests
|
|
// ============================================================================
|
|
|
|
TEST_SUITE(StatelessWorkerExtended) {
|
|
|
|
TEST_CASE(BuildPCMRequest) {
|
|
TempDir tmp;
|
|
tmp.touch("test_module.cppm",
|
|
"export module test_module;\nexport int module_func() { return 1; }\n");
|
|
auto src = tmp.path("test_module.cppm");
|
|
|
|
WorkerHandle w;
|
|
ASSERT_TRUE(w.spawn("stateless-worker"));
|
|
|
|
bool test_done = false;
|
|
|
|
w.run([&]() -> kota::task<> {
|
|
worker::BuildParams params;
|
|
params.kind = worker::BuildKind::BuildPCM;
|
|
params.file = src;
|
|
params.directory = "/tmp";
|
|
params.arguments = {"clang++",
|
|
"-resource-dir",
|
|
std::string(resource_dir()),
|
|
"-std=c++20",
|
|
"--precompile",
|
|
src};
|
|
params.module_name = "test_module";
|
|
params.output_path = tmp.path("test_module.pcm");
|
|
|
|
auto result = co_await w.peer->send_request(params);
|
|
EXPECT_TRUE(result.has_value());
|
|
test_done = true;
|
|
w.peer->close_output();
|
|
});
|
|
|
|
ASSERT_TRUE(test_done);
|
|
}
|
|
|
|
TEST_CASE(CompletionRequest) {
|
|
std::string text = "int foo = 1;\nint bar = fo";
|
|
TempDir tmp;
|
|
tmp.touch("completion_test.cpp", text);
|
|
auto src = tmp.path("completion_test.cpp");
|
|
|
|
WorkerHandle w;
|
|
ASSERT_TRUE(w.spawn("stateless-worker"));
|
|
|
|
bool test_done = false;
|
|
|
|
w.run([&]() -> kota::task<> {
|
|
worker::BuildParams params;
|
|
params.kind = worker::BuildKind::Completion;
|
|
params.file = src;
|
|
params.version = 1;
|
|
params.text = text;
|
|
params.directory = "/tmp";
|
|
params.arguments = make_args(src);
|
|
params.offset = 25; // after "fo" in "int bar = fo" (13 + 12)
|
|
|
|
auto result = co_await w.peer->send_request(params);
|
|
EXPECT_TRUE(result.has_value());
|
|
test_done = true;
|
|
w.peer->close_output();
|
|
});
|
|
|
|
ASSERT_TRUE(test_done);
|
|
}
|
|
|
|
TEST_CASE(SignatureHelpRequest) {
|
|
std::string text = "void foo(int a, int b) {}\nint main() { foo(";
|
|
TempDir tmp;
|
|
tmp.touch("sighelp_test.cpp", text);
|
|
auto src = tmp.path("sighelp_test.cpp");
|
|
|
|
WorkerHandle w;
|
|
ASSERT_TRUE(w.spawn("stateless-worker"));
|
|
|
|
bool test_done = false;
|
|
|
|
w.run([&]() -> kota::task<> {
|
|
worker::BuildParams params;
|
|
params.kind = worker::BuildKind::SignatureHelp;
|
|
params.file = src;
|
|
params.version = 1;
|
|
params.text = text;
|
|
params.directory = "/tmp";
|
|
params.arguments = make_args(src);
|
|
params.offset = 45; // after "foo(" (26 + 19)
|
|
|
|
auto result = co_await w.peer->send_request(params);
|
|
EXPECT_TRUE(result.has_value());
|
|
// Should return signature help for foo(int a, int b).
|
|
test_done = true;
|
|
w.peer->close_output();
|
|
});
|
|
|
|
ASSERT_TRUE(test_done);
|
|
}
|
|
|
|
TEST_CASE(MultipleStatelessRequests) {
|
|
TempDir tmp;
|
|
std::vector<std::string> paths;
|
|
for(int i = 0; i < 3; i++) {
|
|
auto name = "multi_index_" + std::to_string(i) + ".cpp";
|
|
auto text = "int idx_var_" + std::to_string(i) + " = " + std::to_string(i) + ";\n";
|
|
tmp.touch(name, text);
|
|
paths.push_back(tmp.path(name));
|
|
}
|
|
|
|
WorkerHandle w;
|
|
ASSERT_TRUE(w.spawn("stateless-worker"));
|
|
|
|
bool test_done = false;
|
|
|
|
w.run([&]() -> kota::task<> {
|
|
// Send multiple index requests to test stateless worker handles them sequentially.
|
|
for(int i = 0; i < 3; i++) {
|
|
worker::BuildParams params;
|
|
params.kind = worker::BuildKind::Index;
|
|
params.file = paths[i];
|
|
params.directory = "/tmp";
|
|
params.arguments = make_args(paths[i]);
|
|
|
|
auto result = co_await w.peer->send_request(params);
|
|
EXPECT_TRUE(result.has_value());
|
|
}
|
|
test_done = true;
|
|
w.peer->close_output();
|
|
});
|
|
|
|
ASSERT_TRUE(test_done);
|
|
}
|
|
|
|
}; // TEST_SUITE(StatelessWorkerExtended)
|
|
|
|
} // namespace
|
|
|
|
} // namespace clice::testing
|