Adds the headless agent architecture for Sprint 9 Phase 9a: - ASTUtils.h: pure AST utilities extracted from EditorUtils.h - HeadlessEditorState.h: GUI-free state with buffer management - HeadlessAgentRPCHandler.h: full RPC dispatch (20+ methods) - step245_test.cpp: 20 tests all passing Also fixes test compilation errors (NotificationSystem API changes, AgentRole permissions, DependencyPanel missing include) and adds SDL2 system library detection fix in CMakeLists.txt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
57 lines
1.9 KiB
C++
57 lines
1.9 KiB
C++
// Step 142 TDD Test: Emacs package browser
|
|
#include "EmacsPackageBrowser.h"
|
|
#include "EmacsIntegration.h"
|
|
#include "NotificationSystem.h"
|
|
#include <iostream>
|
|
|
|
static void expect(bool cond, const std::string& name, int& passed, int& failed) {
|
|
if (cond) {
|
|
std::cout << "Test " << (passed + failed + 1) << " PASS: " << name << "\n";
|
|
++passed;
|
|
} else {
|
|
std::cout << "Test " << (passed + failed + 1) << " FAIL: " << name << "\n";
|
|
++failed;
|
|
}
|
|
}
|
|
|
|
static const EmacsPackageEntry* findPkg(const std::vector<EmacsPackageEntry>& pkgs,
|
|
const std::string& name) {
|
|
for (const auto& pkg : pkgs) {
|
|
if (pkg.name == name) return &pkg;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
int main() {
|
|
int passed = 0;
|
|
int failed = 0;
|
|
|
|
MockEmacsConnection mock;
|
|
EmacsPackageBrowserState state;
|
|
NotificationSystem notifications;
|
|
|
|
refreshEmacsPackages(state, mock, notifications);
|
|
expect(!state.packages.empty(), "packages loaded", passed, failed);
|
|
|
|
const EmacsPackageEntry* usePkg = findPkg(state.packages, "use-package");
|
|
expect(usePkg != nullptr, "loaded package listed", passed, failed);
|
|
if (usePkg) {
|
|
expect(usePkg->status == "loaded", "loaded status set", passed, failed);
|
|
}
|
|
|
|
const EmacsPackageEntry* magitPkg = findPkg(state.packages, "magit");
|
|
expect(magitPkg != nullptr, "available package listed", passed, failed);
|
|
if (magitPkg) {
|
|
expect(magitPkg->status == "available", "available status set", passed, failed);
|
|
}
|
|
|
|
bool loadOk = loadEmacsPackage(mock, "magit", notifications);
|
|
expect(loadOk, "load package command", passed, failed);
|
|
expect(mock.getLastSentCommand().find("(require 'magit)") != std::string::npos,
|
|
"require command sent", passed, failed);
|
|
|
|
std::cout << "\n=== Step 142 Results: " << passed << " passed, "
|
|
<< failed << " failed ===\n";
|
|
return failed == 0 ? 0 : 1;
|
|
}
|