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.
113 lines
4.0 KiB
C++
113 lines
4.0 KiB
C++
#include <vls/debug/live/LiveSession.hpp>
|
|
|
|
#include <Void/System/TempDir.hpp>
|
|
#include <Void/Testing/Assert.hpp>
|
|
#include <Void/Testing/Test.hpp>
|
|
|
|
#include <chrono>
|
|
#include <csignal>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
namespace {
|
|
namespace fs = std::filesystem;
|
|
// A worker may exit while the session still owns its stdin pipe.
|
|
struct IgnoreSigpipe {
|
|
IgnoreSigpipe() { std::signal(SIGPIPE, SIG_IGN); }
|
|
} ignore_sigpipe;
|
|
using namespace vls::debug::live;
|
|
using namespace std::chrono_literals;
|
|
using Void::Testing::expect;
|
|
using Void::Testing::require;
|
|
|
|
struct Fixture {
|
|
Void::FileSystem::TempDir temp{"vls_live_session_"};
|
|
fs::path source;
|
|
fs::path trace;
|
|
Options options;
|
|
|
|
explicit Fixture(std::string name = "normal.cpp", std::chrono::milliseconds deadline = 5s) {
|
|
source = temp.path() / name;
|
|
std::ofstream{source} << "int value = 17;\n";
|
|
trace = temp.path() / "session.vls";
|
|
const auto worker =
|
|
fs::canonical("/proc/self/exe").parent_path() / "vls_live_worker_fixture";
|
|
options = Options{worker, "/private/cc1plus", std::string(64, 'a'), source, trace, true,
|
|
deadline, 64 * 1024};
|
|
}
|
|
};
|
|
} // namespace
|
|
|
|
VOID_TEST(LiveSession, steps_through_stops_and_inspects_each_generation) {
|
|
Fixture fixture;
|
|
LiveSession session{fixture.options};
|
|
const auto first = session.start();
|
|
if (!first.has_value())
|
|
std::cerr << "start error: " << first.error() << '\n';
|
|
require(first.has_value());
|
|
expect(first->generation == 1 && first->sequence == 1);
|
|
expect(session.state() == State::stopped);
|
|
const auto first_snapshot = session.inspect();
|
|
require(first_snapshot.has_value());
|
|
const auto first_json = Void::LanguageServer::Protocol::serialize_json(*first_snapshot);
|
|
require(first_json.has_value());
|
|
expect(first_json->find("\"17\"") != std::string::npos);
|
|
const auto second = session.step();
|
|
require(second.has_value() && second->has_value());
|
|
expect((*second)->generation == 2 && (*second)->sequence == 2);
|
|
const auto second_snapshot = session.inspect();
|
|
require(second_snapshot.has_value());
|
|
const auto second_json = Void::LanguageServer::Protocol::serialize_json(*second_snapshot);
|
|
require(second_json.has_value());
|
|
expect(second_json->find("\"34\"") != std::string::npos);
|
|
require(session.step().has_value());
|
|
const auto done = session.step();
|
|
require(done.has_value());
|
|
expect(!done->has_value());
|
|
expect(session.state() == State::completed && session.outcome() == "completed");
|
|
}
|
|
|
|
VOID_TEST(LiveSession, continue_finishes_the_session) {
|
|
Fixture fixture;
|
|
LiveSession session{fixture.options};
|
|
require(session.start().has_value());
|
|
const auto done = session.continue_run();
|
|
require(done.has_value());
|
|
expect(!done->has_value() && session.state() == State::completed);
|
|
expect(session.stop() == std::nullopt);
|
|
}
|
|
|
|
VOID_TEST(LiveSession, cancel_terminates_at_a_stop) {
|
|
Fixture fixture;
|
|
LiveSession session{fixture.options};
|
|
require(session.start().has_value());
|
|
require(session.cancel().has_value());
|
|
expect(session.state() == State::cancelled);
|
|
}
|
|
|
|
VOID_TEST(LiveSession, refuses_movement_without_a_stop) {
|
|
Fixture fixture;
|
|
LiveSession session{fixture.options};
|
|
expect(!session.step().has_value());
|
|
expect(!session.inspect().has_value());
|
|
expect(!session.cancel().has_value());
|
|
}
|
|
|
|
VOID_TEST(LiveSession, rejects_malformed_worker_output) {
|
|
Fixture fixture{"malformed.cpp"};
|
|
LiveSession session{fixture.options};
|
|
const auto started = session.start();
|
|
require(!started.has_value());
|
|
expect(started.error().contains("bound") || started.error().contains("JSON"));
|
|
}
|
|
|
|
VOID_TEST(LiveSession, enforces_the_notice_deadline) {
|
|
Fixture fixture{"silent.cpp", 200ms};
|
|
LiveSession session{fixture.options};
|
|
const auto started = session.start();
|
|
require(!started.has_value());
|
|
expect(started.error().contains("deadline"));
|
|
}
|