Implement the VLS roadmap on the native VBS build
Native VBS and CMake builds of the server and every registered suite: protocol and document sync, VBS/compdb providers, stock GCC diagnostics (including in-process default profile preparation), the stock occurrence observer and hover/definition, the bounded Scheduler, C++ module graph, scan and artifact cache with real CMI production, the context-aware symbol index with schema-2 snapshot migration, navigation and guarded rename, reflection provenance with splice-origin extraction, index-backed completion and signature help, live GCC worker control with a registered DAP suite, and the Neovim and VS Code clients. VoidLibrary follows main. The private GCC 16.2.0 frontend is reproduced from the versioned patches and verified stepping reflection/template code with projected values 17/34 and 41/82.
This commit is contained in:
1 parent
ca04975d54
commit
da8003f6d4
310 files changed
+47552
-480
No files matched your search
+95
-12
@@ -1,11 +1,14 @@
|
||||
#include "TestExecutable.hpp"
|
||||
#include "TestSupport.hpp"
|
||||
|
||||
#include <Void/System/Process.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cerrno>
|
||||
#include <chrono>
|
||||
#include <poll.h>
|
||||
#include <stdexcept>
|
||||
#include <tuple>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace {
|
||||
@@ -13,7 +16,7 @@ using namespace std::chrono_literals;
|
||||
|
||||
Void::Process::Child spawn(const std::vector<std::string> &arguments = {}) {
|
||||
Void::Process::SpawnOptions options;
|
||||
options.executable = VLS_EXECUTABLE;
|
||||
options.executable = test::server_executable();
|
||||
options.arguments = arguments;
|
||||
options.search_path = false;
|
||||
options.kill_grace = 100ms;
|
||||
@@ -96,9 +99,21 @@ std::string lifecycle() {
|
||||
test::frame(test::shutdown) + test::frame(test::exit);
|
||||
}
|
||||
|
||||
constexpr std::string_view open_document =
|
||||
R"({"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"untitled:sync","languageId":"cpp","version":1,"text":"a"}}})";
|
||||
constexpr std::string_view close_document =
|
||||
R"({"jsonrpc":"2.0","method":"textDocument/didClose","params":{"textDocument":{"uri":"untitled:sync"}}})";
|
||||
|
||||
std::string change_document(int version, std::string_view changes) {
|
||||
return test::frame(
|
||||
std::string{
|
||||
R"({"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"untitled:sync","version":)"} +
|
||||
std::to_string(version) + R"(},"contentChanges":)" + std::string{changes} + "}}");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Void::Testing::Test cli_standalone_and_invalid_modes() {
|
||||
VOID_TEST(ProcessTests, cli_standalone_and_invalid_modes) {
|
||||
for (const auto flag : {"--help", "-h", "--version", "-V"}) {
|
||||
const auto output = run({}, {flag});
|
||||
Void::Testing::expect_eq(output.status.code, 0);
|
||||
@@ -127,7 +142,7 @@ Void::Testing::Test cli_standalone_and_invalid_modes() {
|
||||
}
|
||||
}
|
||||
|
||||
Void::Testing::Test default_and_explicit_stdio_lifecycle() {
|
||||
VOID_TEST(ProcessTests, default_and_explicit_stdio_lifecycle) {
|
||||
for (const auto &args : std::vector<std::vector<std::string>>{{}, {"--stdio"}}) {
|
||||
const auto output = run(lifecycle(), args);
|
||||
Void::Testing::expect_eq(output.status.code, 0);
|
||||
@@ -135,14 +150,82 @@ Void::Testing::Test default_and_explicit_stdio_lifecycle() {
|
||||
const auto replies = test::responses(output.out);
|
||||
Void::Testing::require_eq(replies.size(), std::size_t{2});
|
||||
const auto &result = test::field(replies[0], "result");
|
||||
Void::Testing::expect(
|
||||
std::get<vls::Json::Object>(test::field(result, "capabilities").value).empty());
|
||||
test::expect_sync_capabilities(result);
|
||||
Void::Testing::expect(
|
||||
std::holds_alternative<std::nullptr_t>(test::field(replies[1], "result").value));
|
||||
}
|
||||
}
|
||||
|
||||
Void::Testing::Test fragmented_headers_bodies_and_immediate_flush() {
|
||||
VOID_TEST(ProcessTests, negotiated_incremental_edit_observes_astral_character) {
|
||||
constexpr auto replace =
|
||||
R"([{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":1}},"text":"\uD83D\uDE42"}])";
|
||||
constexpr auto split =
|
||||
R"([{"range":{"start":{"line":0,"character":1},"end":{"line":0,"character":1}},"text":"x"}])";
|
||||
for (const auto &[offered, encoding, diagnostic] :
|
||||
{std::tuple{R"(["utf-32","utf-8","utf-16"])", "utf-8", "splits a Unicode scalar"},
|
||||
std::tuple{R"(["utf-16","utf-8"])", "utf-16", "splits a surrogate pair"}}) {
|
||||
const auto initialize = test::frame(
|
||||
std::string{
|
||||
R"({"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{"general":{"positionEncodings":)"} +
|
||||
offered + "}}}}");
|
||||
auto output = run(initialize + test::frame(test::initialized) + test::frame(open_document) +
|
||||
change_document(2, replace) + change_document(3, split) +
|
||||
test::frame(close_document) + test::frame(test::shutdown) +
|
||||
test::frame(test::exit));
|
||||
Void::Testing::expect_eq(output.status.code, 0);
|
||||
auto replies = test::responses(output.out);
|
||||
Void::Testing::require_eq(replies.size(), std::size_t{2});
|
||||
test::expect_sync_capabilities(test::field(replies[0], "result"), encoding);
|
||||
Void::Testing::expect(output.err.contains(diagnostic));
|
||||
Void::Testing::expect_eq(std::ranges::count(output.err, '\n'), 1);
|
||||
}
|
||||
}
|
||||
|
||||
VOID_TEST(ProcessTests, malformed_batch_blocks_edits_until_newer_full_replacement) {
|
||||
constexpr auto malformed = R"([{"text":"old"},{"text":"bad","range":null}])";
|
||||
constexpr auto full = R"([{"text":"a"}])";
|
||||
constexpr auto ranged =
|
||||
R"([{"text":"b","range":{"start":{"line":0,"character":0},"end":{"line":0,"character":1}}}])";
|
||||
constexpr auto overflow =
|
||||
R"([{"text":"","range":{"start":{"line":0,"character":2147483648},"end":{"line":0,"character":2147483648}}}])";
|
||||
auto output =
|
||||
run(test::frame(test::initialize_request) + test::frame(test::initialized) +
|
||||
test::frame(open_document) + change_document(12, malformed) +
|
||||
change_document(10, full) + change_document(13, ranged) + change_document(14, full) +
|
||||
change_document(15, ranged) + change_document(16, overflow) +
|
||||
change_document(17, full) + test::frame(close_document) + change_document(18, ranged) +
|
||||
test::frame(test::shutdown) + test::frame(open_document) + test::frame(test::exit));
|
||||
Void::Testing::expect_eq(output.status.code, 0);
|
||||
const auto replies = test::responses(output.out);
|
||||
Void::Testing::require_eq(replies.size(), std::size_t{2});
|
||||
test::expect_sync_capabilities(test::field(replies[0], "result"));
|
||||
Void::Testing::expect(output.err.contains("invalid change range"));
|
||||
Void::Testing::expect(output.err.contains("nonmonotonic"));
|
||||
Void::Testing::expect(output.err.contains("newer full-text replacement"));
|
||||
Void::Testing::expect(output.err.contains("document is not open"));
|
||||
Void::Testing::expect_eq(std::ranges::count(output.err, '\n'), 5);
|
||||
}
|
||||
|
||||
VOID_TEST(ProcessTests, malformed_change_envelope_invalidates_an_identifiable_document) {
|
||||
const auto hybrid = test::frame(
|
||||
R"({"jsonrpc":"2.0","method":"textDocument/didChange","result":null,"params":{"textDocument":{"uri":"untitled:sync","version":12},"contentChanges":[{"text":"bad"}]}})");
|
||||
constexpr auto ranged =
|
||||
R"([{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":1}},"text":"b"}])";
|
||||
constexpr auto full = R"([{"text":"a"}])";
|
||||
auto output =
|
||||
run(test::frame(test::initialize_request) + test::frame(test::initialized) +
|
||||
test::frame(open_document) + hybrid + change_document(10, full) +
|
||||
change_document(13, ranged) + change_document(14, full) + change_document(15, ranged) +
|
||||
test::frame(close_document) + test::frame(test::shutdown) + test::frame(test::exit));
|
||||
Void::Testing::expect_eq(output.status.code, 0);
|
||||
Void::Testing::require_eq(test::responses(output.out).size(), std::size_t{2});
|
||||
Void::Testing::expect(output.err.contains("invalid didChange envelope"));
|
||||
Void::Testing::expect(output.err.contains("nonmonotonic"));
|
||||
Void::Testing::expect(output.err.contains("newer full-text replacement"));
|
||||
Void::Testing::expect_eq(std::ranges::count(output.err, '\n'), 3);
|
||||
}
|
||||
|
||||
VOID_TEST(ProcessTests, fragmented_headers_bodies_and_immediate_flush) {
|
||||
auto child = spawn({"--stdio"});
|
||||
const auto input = test::frame(test::initialize_request);
|
||||
const auto split = input.find("\r\n\r\n") + 5;
|
||||
@@ -167,7 +250,7 @@ Void::Testing::Test fragmented_headers_bodies_and_immediate_flush() {
|
||||
Void::Testing::expect_eq(test::error_code(replies[1]), std::int64_t{-32601});
|
||||
}
|
||||
|
||||
Void::Testing::Test unmatched_peer_responses_do_not_create_reply_loops() {
|
||||
VOID_TEST(ProcessTests, unmatched_peer_responses_do_not_create_reply_loops) {
|
||||
const auto responses =
|
||||
test::frame(R"({"jsonrpc":"2.0","id":77,"result":{"ok":true}})") +
|
||||
test::frame(R"({"jsonrpc":"2.0","id":null,"result":null})") +
|
||||
@@ -187,7 +270,7 @@ Void::Testing::Test unmatched_peer_responses_do_not_create_reply_loops() {
|
||||
std::holds_alternative<std::nullptr_t>(test::field(replies[1], "result").value));
|
||||
}
|
||||
|
||||
Void::Testing::Test known_size_malformed_json_continues() {
|
||||
VOID_TEST(ProcessTests, known_size_malformed_json_continues) {
|
||||
const auto output = run(test::frame("{bad") + test::frame("[{}]") + lifecycle());
|
||||
Void::Testing::expect_eq(output.status.code, 0);
|
||||
Void::Testing::expect(output.err.empty());
|
||||
@@ -199,7 +282,7 @@ Void::Testing::Test known_size_malformed_json_continues() {
|
||||
Void::Testing::expect_eq(test::error_code(replies[1]), std::int64_t{-32600});
|
||||
}
|
||||
|
||||
Void::Testing::Test invalid_encoding_and_surrogates_continue() {
|
||||
VOID_TEST(ProcessTests, invalid_encoding_and_surrogates_continue) {
|
||||
const auto output = run(test::frame(std::string{"\"\xED\xA0\x80\""}) +
|
||||
test::frame(R"({"bad":"\uDC00"})") + lifecycle());
|
||||
Void::Testing::expect_eq(output.status.code, 0);
|
||||
@@ -209,7 +292,7 @@ Void::Testing::Test invalid_encoding_and_surrogates_continue() {
|
||||
Void::Testing::expect_eq(test::error_code(replies[1]), std::int64_t{-32700});
|
||||
}
|
||||
|
||||
Void::Testing::Test framing_errors_exit_without_resynchronization() {
|
||||
VOID_TEST(ProcessTests, framing_errors_exit_without_resynchronization) {
|
||||
for (const auto prefix :
|
||||
{"Content-Length: invalid\r\n\r\n", "Other: 2\r\n\r\n", "Content-Length: 16777217\r\n\r\n",
|
||||
"Content-Length: 1\r\nContent-Length: 1\r\n\r\n",
|
||||
@@ -227,7 +310,7 @@ Void::Testing::Test framing_errors_exit_without_resynchronization() {
|
||||
}
|
||||
}
|
||||
|
||||
Void::Testing::Test premature_exit_and_unexpected_eof() {
|
||||
VOID_TEST(ProcessTests, premature_exit_and_unexpected_eof) {
|
||||
for (const auto input : {std::string{}, test::frame(test::exit),
|
||||
test::frame(test::initialize_request) + test::frame(test::exit),
|
||||
test::frame(test::initialize_request) + test::frame(test::shutdown)}) {
|
||||
@@ -238,7 +321,7 @@ Void::Testing::Test premature_exit_and_unexpected_eof() {
|
||||
}
|
||||
}
|
||||
|
||||
Void::Testing::Test lifecycle_error_precedence_and_string_ids() {
|
||||
VOID_TEST(ProcessTests, lifecycle_error_precedence_and_string_ids) {
|
||||
const auto output = run(test::frame(test::shutdown) + test::frame(test::initialize_request) +
|
||||
test::frame(test::initialize_request) +
|
||||
test::frame(R"({"jsonrpc":"2.0","id":"\"\u0416","method":"unknown"})") +
|
||||
|
||||
Reference in new issue
Block a user