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:
ykiko
2026-03-31 10:29:49 +08:00
committed by GitHub
parent 6d3b6acc82
commit 0a891d8b4a
27 changed files with 1895 additions and 968 deletions

View File

@@ -878,6 +878,27 @@ private:
// Tries to get to the underlying argument by unwrapping implicit nodes and
// std::forward.
const static clang::DeclRefExpr* unwrapForward(const clang::Expr* E) {
auto is_std_forward = [](const clang::FunctionDecl* Callee) {
if(!Callee) {
return false;
}
if(Callee->getBuiltinID() == clang::Builtin::BIforward) {
return true;
}
if(identifier_of(*Callee) != "forward") {
return false;
}
// Walk up through inline namespaces (e.g. std::__1::forward).
for(const clang::DeclContext* DC = Callee->getDeclContext(); DC; DC = DC->getParent()) {
if(const auto* NS = llvm::dyn_cast<clang::NamespaceDecl>(DC)) {
if(identifier_of(*NS) == "std" && NS->getParent()->isTranslationUnit()) {
return true;
}
}
}
return false;
};
E = E->IgnoreImplicitAsWritten();
// There might be an implicit copy/move constructor call on top of the
// forwarded arg.
@@ -886,8 +907,7 @@ private:
if(Const->getConstructor()->isCopyOrMoveConstructor())
E = Const->getArg(0)->IgnoreImplicitAsWritten();
if(const auto* Call = llvm::dyn_cast<clang::CallExpr>(E)) {
const auto Callee = Call->getBuiltinCallee();
if(Callee == clang::Builtin::BIforward) {
if(is_std_forward(Call->getDirectCallee())) {
return llvm::dyn_cast<clang::DeclRefExpr>(
Call->getArg(0)->IgnoreImplicitAsWritten());
}