## Summary - **Use `Tester` as fixture base** for all test suites that need compilation, replacing `TesterFixture` and removing redundant `tester.clear()` calls (eventide zest now creates fresh instances per TEST_CASE) - **Remove local `Tester` variables** in `compilation_tests`, `template_resolver_tests`, `selection_tests` — use inherited fixture members directly - **Normalize helper naming**: `expect_xxx` → `EXPECT_XXX`, `go_to_definition` → `GO_TO_DEFINITION` for consistency - **Extract shared `test/cdb_helper.h`**: deduplicate `CDBEntry`, `json_escape`, `build_cdb_json` from `dependency_graph_tests` and `compile_graph_integration_tests` - **Add new test files/cases**: `project_index_tests.cpp`, expanded `tu_index_tests`, `merged_index_tests`, `compilation_tests` ## Test plan - [x] All existing unit tests pass - [x] New index tests (TUIndex, MergedIndex, ProjectIndex) pass - [x] Compilation tests (PCH, PCM, stop) pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Standardized test fixtures and helper naming, moved suites to a shared fixture, and unified in-memory VFS and compile flows. * Added broad new coverage: indexing, project indexing, compilation/PCH, diagnostics, semantic features, and many targeted unit cases. * Introduced a small compile-database helper and improved driver-style test compilation paths. * **Chores** * Consolidated and reorganized test utilities and tester APIs for easier maintenance and reuse. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
70 lines
2.0 KiB
C++
70 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include "test/annotation.h"
|
|
#include "test/test.h"
|
|
#include "command/command.h"
|
|
#include "compile/compilation.h"
|
|
#include "support/logging.h"
|
|
|
|
namespace clice::testing {
|
|
|
|
struct Tester {
|
|
CompilationParams params;
|
|
CompilationDatabase database;
|
|
std::optional<CompilationUnit> unit;
|
|
std::string src_path;
|
|
|
|
AnnotatedSources sources;
|
|
|
|
/// Owns argument strings so that params.arguments (const char*) remains valid.
|
|
std::vector<std::string> owned_args;
|
|
|
|
/// The VFS used for compilation.
|
|
llvm::IntrusiveRefCntPtr<TestVFS> vfs;
|
|
|
|
void add_main(llvm::StringRef file, llvm::StringRef content) {
|
|
src_path = file.str();
|
|
sources.add_source(file, content);
|
|
}
|
|
|
|
void add_file(llvm::StringRef name, llvm::StringRef content) {
|
|
sources.add_source(name, content);
|
|
}
|
|
|
|
void add_files(llvm::StringRef main_file, llvm::StringRef content) {
|
|
src_path = main_file.str();
|
|
sources.add_sources(content);
|
|
}
|
|
|
|
/// Fast VFS-only path: uses -cc1 directly, no system headers.
|
|
void prepare(llvm::StringRef standard = "-std=c++20");
|
|
|
|
bool compile(llvm::StringRef standard = "-std=c++20");
|
|
|
|
bool compile_with_pch(llvm::StringRef standard = "-std=c++20");
|
|
|
|
/// Driver path: uses CompilationDatabase + toolchain cache, has system headers.
|
|
void prepare_driver(llvm::StringRef standard = "-std=c++20");
|
|
|
|
bool compile_driver(llvm::StringRef standard = "-std=c++20");
|
|
|
|
bool compile_driver_with_pch(llvm::StringRef standard = "-std=c++20");
|
|
|
|
std::uint32_t operator[](llvm::StringRef file, llvm::StringRef pos) {
|
|
return sources.all_files.lookup(file).offsets.lookup(pos);
|
|
}
|
|
|
|
std::uint32_t point(llvm::StringRef name = "", llvm::StringRef file = "");
|
|
|
|
llvm::ArrayRef<std::uint32_t> nameless_points(llvm::StringRef file = "");
|
|
|
|
LocalSourceRange range(llvm::StringRef name = "", llvm::StringRef file = "");
|
|
|
|
void clear();
|
|
};
|
|
|
|
} // namespace clice::testing
|