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:
@@ -11,7 +11,7 @@ TEST_SUITE(ArgumentParser) {
|
||||
|
||||
using option = clang::driver::options::ID;
|
||||
|
||||
void expect_id(llvm::StringRef command, option opt) {
|
||||
void EXPECT_ID(llvm::StringRef command, option opt) {
|
||||
auto id = get_option_id(command);
|
||||
ASSERT_TRUE(id.has_value());
|
||||
ASSERT_EQ(*id, int(opt));
|
||||
@@ -19,47 +19,47 @@ void expect_id(llvm::StringRef command, option opt) {
|
||||
|
||||
TEST_CASE(GetOptionID) {
|
||||
/// GroupClass
|
||||
expect_id("-g", option::OPT_g_Flag);
|
||||
EXPECT_ID("-g", option::OPT_g_Flag);
|
||||
|
||||
/// InputClass
|
||||
expect_id("main.cpp", option::OPT_INPUT);
|
||||
EXPECT_ID("main.cpp", option::OPT_INPUT);
|
||||
|
||||
/// UnknownClass
|
||||
expect_id("--clice", option::OPT_UNKNOWN);
|
||||
EXPECT_ID("--clice", option::OPT_UNKNOWN);
|
||||
|
||||
/// FlagClass
|
||||
expect_id("-v", option::OPT_v);
|
||||
expect_id("-c", option::OPT_c);
|
||||
expect_id("-pedantic", option::OPT_pedantic);
|
||||
expect_id("--pedantic", option::OPT_pedantic);
|
||||
EXPECT_ID("-v", option::OPT_v);
|
||||
EXPECT_ID("-c", option::OPT_c);
|
||||
EXPECT_ID("-pedantic", option::OPT_pedantic);
|
||||
EXPECT_ID("--pedantic", option::OPT_pedantic);
|
||||
|
||||
/// JoinedClass
|
||||
expect_id("-Wno-unused-variable", option::OPT_W_Joined);
|
||||
expect_id("-W*", option::OPT_W_Joined);
|
||||
expect_id("-W", option::OPT_W_Joined);
|
||||
EXPECT_ID("-Wno-unused-variable", option::OPT_W_Joined);
|
||||
EXPECT_ID("-W*", option::OPT_W_Joined);
|
||||
EXPECT_ID("-W", option::OPT_W_Joined);
|
||||
|
||||
/// ValuesClass
|
||||
|
||||
/// SeparateClass
|
||||
expect_id("-Xclang", option::OPT_Xclang);
|
||||
/// expect_id(GET_ID("-Xclang -ast-dump") , option::OPT_Xclang);
|
||||
EXPECT_ID("-Xclang", option::OPT_Xclang);
|
||||
/// EXPECT_ID(GET_ID("-Xclang -ast-dump") , option::OPT_Xclang);
|
||||
|
||||
/// RemainingArgsClass
|
||||
|
||||
/// RemainingArgsJoinedClass
|
||||
|
||||
/// CommaJoinedClass
|
||||
expect_id("-Wl,", option::OPT_Wl_COMMA);
|
||||
EXPECT_ID("-Wl,", option::OPT_Wl_COMMA);
|
||||
|
||||
/// MultiArgClass
|
||||
|
||||
/// JoinedOrSeparateClass
|
||||
expect_id("-o", option::OPT_o);
|
||||
expect_id("-omain.o", option::OPT_o);
|
||||
expect_id("-I", option::OPT_I);
|
||||
expect_id("--include-directory=", option::OPT_I);
|
||||
expect_id("-x", option::OPT_x);
|
||||
expect_id("--language=", option::OPT_x);
|
||||
EXPECT_ID("-o", option::OPT_o);
|
||||
EXPECT_ID("-omain.o", option::OPT_o);
|
||||
EXPECT_ID("-I", option::OPT_I);
|
||||
EXPECT_ID("--include-directory=", option::OPT_I);
|
||||
EXPECT_ID("-x", option::OPT_x);
|
||||
EXPECT_ID("--language=", option::OPT_x);
|
||||
|
||||
/// JoinedAndSeparateClass
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user