1 parent
e7186f17f0
commit
f0825fbd1a
13 files changed
+105
-36
No files matched your search
@@ -4,6 +4,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## Build
|
||||
|
||||
Requires CMake 4.0+ and a C++23 compiler (clang++ is the default in the configure command below).
|
||||
|
||||
```bash
|
||||
# Configure (clang++, Ninja, Debug)
|
||||
cmake -B build -S . -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug
|
||||
@@ -29,7 +31,7 @@ VoidLibrary is a C++23 modular shared library. Each module is an independently i
|
||||
|
||||
### Module system
|
||||
|
||||
`cmake/Module.cmake` defines `void_add_module(NAME ...)`. The root `CMakeLists.txt` auto-discovers every subdirectory under `src/` and calls it. A module with only headers becomes an `INTERFACE` library; one with `.cpp` sources becomes a `SHARED` library.
|
||||
`cmake/Module.cmake` defines `void_add_module(NAME ...)`. The root `CMakeLists.txt` auto-discovers every subdirectory under `src/` and calls it. A module with only headers becomes an `INTERFACE` library; one with `.cpp` sources becomes `SHARED` — except `Testing`, which is special-cased to `STATIC`.
|
||||
|
||||
Module layout:
|
||||
- Headers: `include/Void/<ModuleName>/*.hpp`
|
||||
@@ -39,7 +41,10 @@ Module layout:
|
||||
|
||||
To add a new module, create `src/<ModuleName>/` and populate it — the build system picks it up automatically. If a module needs special dependency wiring, drop a `module.cmake` file inside the source directory (see `cmake/module.cmake.template` for the pattern).
|
||||
|
||||
External dependencies are fetched via `cmake/Dependencies.cmake` using `FetchContent`; add new ones there and reference them via `EXTERNAL_DEPS` in `void_add_module`.
|
||||
`void_add_module` accepts three dependency lists:
|
||||
- `INTERNAL_DEPS` — other `Void::*` modules (linked unconditionally).
|
||||
- `EXTERNAL_DEPS` — third-party targets fetched via `cmake/Dependencies.cmake` (`FetchContent`); add new ones there before referencing.
|
||||
- `OPTIONAL_DEPS` — `Void::*` modules linked only if they exist; each present dep additionally defines `VOID_HAS_<UPPERCASE>` for conditional code.
|
||||
|
||||
### Tests
|
||||
|
||||
@@ -52,6 +57,32 @@ External dependencies are fetched via `cmake/Dependencies.cmake` using `FetchCon
|
||||
|
||||
Standalone tests are preferred for testing a single module in isolation.
|
||||
|
||||
#### Writing a test
|
||||
|
||||
Tests are free functions (or methods on a `Void::Testing::Fixture` subclass) returning `Void::Testing::Test` or `Void::Testing::DisabledTest` (both aliases for `void`). **Never write the registration code yourself** — `cmake/VoidTestScanner.cmake` parses each `.cpp` at configure time, generates `*.void_tests.cpp` shims with `Void::Testing::Detail::test_registrar` calls, and rewrites the original source to `HEADER_FILE_ONLY`.
|
||||
|
||||
```cpp
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
Void::Testing::Test addition() { Void::Testing::expect_eq(1 + 1, 2); }
|
||||
|
||||
// @tag integration, database
|
||||
Void::Testing::Test db_query() { Void::Testing::expect(true); }
|
||||
|
||||
// @skip "Feature #42 not implemented"
|
||||
Void::Testing::DisabledTest broken() { Void::Testing::fail("not ready"); }
|
||||
```
|
||||
|
||||
Fixture-based tests work the same way — declare a class derived from `Void::Testing::Fixture`, override `setup()`/`teardown()`, and write methods returning `Test`/`DisabledTest`.
|
||||
|
||||
Comment metadata (immediately preceding the function):
|
||||
- `// @tag a, b, c` — attaches tags.
|
||||
- `// @skip <reason>` — marks the test skipped with a reason; quoted or unquoted strings both work. `DisabledTest` implies `@skip "disabled"` if no explicit reason is given.
|
||||
- Any non-comment, non-empty line resets the accumulated tags/skip — keep the comment block adjacent to the function.
|
||||
|
||||
The sweep in `cmake/VoidTesting.cmake` auto-applies the scan to every executable that transitively links `Void::Testing`. To opt a target out, set the `VOID_TESTING_NO_AUTO_SCAN` property; to opt in explicitly (e.g. for a target that doesn't link `Void::Testing` directly), call `void_add_tests(<target>)`.
|
||||
|
||||
### Logging module
|
||||
|
||||
`Void::Logging::Logger` is an abstract base class. Derive from it to create a sink:
|
||||
|
||||
Reference in new issue
Block a user