mirror of
https://github.com/valkey-io/valkey.git
synced 2026-05-06 05:26:42 -04:00
f3e957cee8
This PR adds GoogleTest (gtest) support to Valkey to enable writing modern unit tests,as mentioned in https://github.com/valkey-io/valkey/issues/2878 **Motivation**: GoogleTest provides richer assertions, test fixtures, mocking support, and improved diagnostics, helping improve test coverage and maintainability over time. For more details, see `src/gtest/README.md`. **Changes** This PR integrates the GoogleTest framework and migrates all existing C unit tests to GoogleTest. --------- Signed-off-by: Harry Lin <harrylhl@amazon.com> Signed-off-by: Madelyn Olson <madelyneolson@gmail.com> Signed-off-by: Alina Liu <liusalisa6363@gmail.com> Signed-off-by: Jacob Murphy <jkmurphy@google.com> Signed-off-by: Jim Brunner <brunnerj@amazon.com> Co-authored-by: Harry Lin <harrylhl@amazon.com> Co-authored-by: Jim Brunner <brunnerj@amazon.com> Co-authored-by: Madelyn Olson <madelyneolson@gmail.com> Co-authored-by: Jacob Murphy <jkmurphy@google.com> Co-authored-by: Alina Liu <liusalisa6363@gmail.com>
2.2 KiB
2.2 KiB
applyTo
| applyTo | ||
|---|---|---|
|
Valkey Core Engine Review Standards
Apply these standards to core engine C code. Do NOT apply to deps/ (vendored dependencies).
1. Code Style (from DEVELOPMENT_GUIDE.md)
- Formatting: Follow clang-format (4-space indent, no tabs, braces attached).
- Comments:
- C-style
/* ... */for single or multi-line. - C++
//only for single-line. - Multi-line: align leading
*, final*/on last text line. - Document why code exists, not just what. Document all functions.
- C-style
- Line Length: Keep below 90 characters when reasonable.
- Types: Use the boolean type for true/false values.
- Static: Use
staticfor file-local functions.
2. Naming Conventions
- Variables:
snake_caseor lowercase (e.g.cached_reply,keylen). - Functions:
camelCaseornamespace_camelCase(e.g.createStringObject,IOJobQueue_isFull). - Macros:
UPPER_CASE(e.g.MAKE_CMD). - Structures:
camelCase(e.g.user).
3. Safety & Correctness
- Memory: Strict check for buffer overflows and leaks.
- Strings: Validate
sdsstring handling. - Concurrency: Verify thread safety in threaded I/O paths.
4. Design Guidelines
- Configuration: Avoid new configs if heuristics suffice. Only add for explicit trade-offs (CPU vs memory).
- Metrics: No new metrics on hot paths without zero-overhead proof.
- PR Scope: Separate refactoring from functional changes for easier backporting.
5. Testing & Documentation
- Unit Tests: Required for data structures in
src/unit/. Test files should followtest_*.cppnaming. - Integration Tests: Required for commands in
tests/. - Command Changes: New/modified commands need corresponding updates in
src/commands/*.json. - New C Files: Remind to update
CMakeLists.txtwhen adding new.csource files. - License: New files need BSD-3-Clause header. Material changes (>100 lines) also require it.
- Documentation: User-facing changes need docs at valkey-doc.
6. Critical Escalation
- Trigger: Changes to
cluster*.c,replication.c,rdb.c,aof.c. - Action: Comment mentioning @core-team to request architectural review.