Repository navigation
Testing
Language: English · 简体中文
make checkThis builds build/test_runner and runs it. The test build deliberately uses
different flags than the main build:
-
-DSEEKEY_TEST— gates out the ncurses rendering code insrc/tui.cso the pure helpers can be tested without a terminal. -
-DG_DISABLE_ASSERT— disablesg_assertside effects in production paths. - Links only glib / gobject / gio / json-glib / gtk4 + the vendored Unity framework — no ncurses, no libevdev, no layer-shell, no display needed.
So the whole suite runs headless in CI.
123 unit tests using the vendored
Unity framework (MIT; under
tests/vendor/unity/).
| File | Covers |
|---|---|
test_config.c |
defaults, search order, strict validation, non-regular path rejection, migration/preservation, themes, Matugen resolution and fallback |
test_tui.c |
field value formatting, adjust/reset pure logic, theme choices, bool string_target regression |
test_keynames.c |
key name / icon / shift-pair / modifier-order lookups |
test_runtime_lock.c |
cross-process-style lock exclusion and handoff |
test_preview_session.c |
overlay-state discovery and semantic preview-config comparison |
test_style.c |
generated CSS font escaping and minimum bubble width |
test_window_state.c |
path resolution, save/load roundtrip, malformed/non-regular-file tolerance, clear |
test_main.c |
test runner entry; registers all suites |
test_helpers.c / .h
|
shared test helpers |
TUI rendering (ncurses) and the GTK event loop can't be exercised in a
headless unit test. So the testable logic in src/tui.c is split into pure
functions (tui_field_value, tui_adjust_field, tui_reset_field,
tui_nearest_color_index, tui_current_choice_index) that operate on a
TuiField/SeekeyConfig with no I/O. The ncurses code path is wrapped in
#ifdef SEEKEY_TEST. The same pattern is used in config.c,
keynames.c, and window_state.c, which is why they compile into the test
binary directly.
- Add a
TEST(<group>, <name>) { ... }function in the relevanttests/test_<area>.c. - Register it in that file's
RUN_<GROUP>_TESTS()(or equivalentRUN_TESTblock). - Call the group runner from
test_main.c. -
make check.
| Target | Purpose |
|---|---|
make check |
run unit tests, shell syntax, translation checks, and desktop-entry validation when available |
make format |
clang-format src/ and tests/ (if installed) |
make clean |
remove seekey, objects, build/test_runner, locale/
|
Getting started
Behaviour & compatibility
Looks
For contributors
Reference