refactor(tests): use Tester fixture, normalize helpers, add index tests (#377)
## 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>
This commit is contained in:
@@ -15,35 +15,35 @@ using namespace std::string_view_literals;
|
||||
|
||||
TEST_SUITE(Toolchain) {
|
||||
|
||||
void expect_family(llvm::StringRef name, toolchain::CompilerFamily family) {
|
||||
void EXPECT_FAMILY(llvm::StringRef name, toolchain::CompilerFamily family) {
|
||||
ASSERT_EQ(toolchain::driver_family(name), family);
|
||||
};
|
||||
|
||||
TEST_CASE(Family) {
|
||||
using enum toolchain::CompilerFamily;
|
||||
|
||||
expect_family("gcc", GCC);
|
||||
expect_family("g++", GCC);
|
||||
expect_family("x86_64-linux-gnu-g++-14", GCC);
|
||||
expect_family("arm-none-eabi-gcc", GCC);
|
||||
EXPECT_FAMILY("gcc", GCC);
|
||||
EXPECT_FAMILY("g++", GCC);
|
||||
EXPECT_FAMILY("x86_64-linux-gnu-g++-14", GCC);
|
||||
EXPECT_FAMILY("arm-none-eabi-gcc", GCC);
|
||||
|
||||
expect_family("clang", Clang);
|
||||
expect_family("clang++", Clang);
|
||||
expect_family("clang.exe", Clang);
|
||||
expect_family("clang++.exe", Clang);
|
||||
expect_family("clang-20", Clang);
|
||||
expect_family("clang-20.exe", Clang);
|
||||
expect_family("clang-cl", ClangCL);
|
||||
expect_family("clang-cl-20", ClangCL);
|
||||
expect_family("clang-cl-20.exe", ClangCL);
|
||||
EXPECT_FAMILY("clang", Clang);
|
||||
EXPECT_FAMILY("clang++", Clang);
|
||||
EXPECT_FAMILY("clang.exe", Clang);
|
||||
EXPECT_FAMILY("clang++.exe", Clang);
|
||||
EXPECT_FAMILY("clang-20", Clang);
|
||||
EXPECT_FAMILY("clang-20.exe", Clang);
|
||||
EXPECT_FAMILY("clang-cl", ClangCL);
|
||||
EXPECT_FAMILY("clang-cl-20", ClangCL);
|
||||
EXPECT_FAMILY("clang-cl-20.exe", ClangCL);
|
||||
|
||||
expect_family("cl.exe", MSVC);
|
||||
EXPECT_FAMILY("cl.exe", MSVC);
|
||||
|
||||
expect_family("zig", Zig);
|
||||
expect_family("zig.exe", Zig);
|
||||
EXPECT_FAMILY("zig", Zig);
|
||||
EXPECT_FAMILY("zig.exe", Zig);
|
||||
};
|
||||
|
||||
TEST_CASE(GCC, {.skip = !(CIEnvironment && (Windows || Linux))}) {
|
||||
TEST_CASE(GCC, skip = !(CIEnvironment && (Windows || Linux))) {
|
||||
auto file = fs::createTemporaryFile("clice", "cpp");
|
||||
if(!file) {
|
||||
LOG_ERROR_RET(void(), "{}", file.error());
|
||||
@@ -76,11 +76,11 @@ TEST_CASE(GCC, {.skip = !(CIEnvironment && (Windows || Linux))}) {
|
||||
ASSERT_TRUE(unit.diagnostics().empty());
|
||||
};
|
||||
|
||||
TEST_CASE(MSVC, {.skip = !CIEnvironment}) {
|
||||
TEST_CASE(MSVC, skip = !CIEnvironment) {
|
||||
// TODO: add MSVC toolchain test when CI provides toolchain.
|
||||
}
|
||||
|
||||
TEST_CASE(Clang, {.skip = !CIEnvironment}) {
|
||||
TEST_CASE(Clang, skip = !CIEnvironment) {
|
||||
auto file = fs::createTemporaryFile("clice", "cpp");
|
||||
if(!file) {
|
||||
LOG_ERROR_RET(void(), "{}", file.error());
|
||||
@@ -115,7 +115,7 @@ TEST_CASE(Clang, {.skip = !CIEnvironment}) {
|
||||
ASSERT_TRUE(unit.diagnostics().empty());
|
||||
};
|
||||
|
||||
TEST_CASE(Zig, {.skip = !CIEnvironment}) {
|
||||
TEST_CASE(Zig, skip = !CIEnvironment) {
|
||||
// TODO: add Zig toolchain test when available in CI.
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user