Skip to content

[ Getting started ]

Building and Running Tests and Examples

From the root of the koto repository, configure and build with CMake and Ninja:

Terminal window
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel $(nproc)

To build with AddressSanitizer and UndefinedBehaviorSanitizer as configured in .github/workflows/ci.yml:24-29:

Terminal window
cmake -B build_debug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror -Wpedantic -Wconversion -Wsign-conversion -Wsign-compare -Wshadow -Wold-style-cast -fsanitize=address,undefined -fno-omit-frame-pointer -g"
cmake --build build_debug --parallel $(nproc)

CMakeLists.txt:126-141 compiles every tests/*.cpp with -UNDEBUG (so assert(...) statements remain active even in Release builds) and registers 6 headless test executables with CTest:

Terminal window
ctest --test-dir build --output-on-failure
CTest NameExecutableSource File
headless_widgetstest_headless_widgetstests/test_headless_widgets.cpp (11 widget tests)
headless_layouttest_headless_layouttests/test_headless_layout.cpp (5 layout and C++23 tests)
headless_focus_eventstest_headless_focus_eventstests/test_headless_focus_events.cpp (8 focus and event tests)
headless_render_terminaltest_headless_render_terminaltests/test_headless_render_terminal.cpp (6 color, self-pipe, and TTY tests)
headless_regressionstest_headless_regressionstests/test_headless_regressions.cpp (8 regression and audit test functions)
cjk_emoji_teststest8_text_cjk_emojitests/test8_text_cjk_emoji.cpp (9 UTF-8, CJK, and emoji tests)

You can also run build/test6_headless_test (which runs the 5 test_headless_* binaries sequentially in isolated child processes).

When KOTO_BUILD_EXAMPLES=ON and KOTO_BUILD_TESTS=ON (both ON by default), the build directory also contains interactive terminal demos that must be run inside a real TTY:

BinarySource FileDescription
kotoapptest/main.cppSplit layout with List, Gauge, and Sparkline.
test1_tic_tac_toetests/test1_tic_tac_toe.cpp3x3 grid game with keyboard and mouse input.
test2_key_visualizertests/test2_key_visualizer.cppInspector displaying KeyEvent codepoints and modifiers.
test3_vboxtests/test3_vbox.cppNested Vbox and Hbox layout demo.
test4_text_inputtests/test4_text_input.cppInteractive TextInput showcase.
test5_yazitests/test5_yazi.cpp3-pane file browser layout.
test7_dashboardtests/test7_dashboard.cppSystem dashboard with Gauge, Sparkline, and List.
test9_chess_boardtests/test9_chess_board.cpp8x8 Layout::grid_uniform board with spatial navigation.
test10_cjk_terminaltests/test10_cjk_terminal.cppInteractive CJK and emoji rendering demo.
test11_text_areatests/test11_text_area.cppInteractive TextArea editor demo.
test12_tabstests/test12_tabs.cppInteractive Tabs (Bar, Pill, Underline) demo.
test13_focus_formtests/test13_focus_form.cppMulti-field form using FocusManager.
test14_spatial_2d_navtests/test14_spatial_2d_nav.cpp2D spatial arrow navigation demo.
test15_modal_focus_traptests/test15_modal_focus_trap.cppModal focus trapping and background click shielding demo.
test16_animationtests/test16_animation.cpp60 FPS on_tick animation demo.
test17_solar_systemtests/test17_solar_system.cppInteractive orbital simulation using on_tick(double dt).
test18_3d_enginetests/test18_3d_engine.cppHalf-block 3D software renderer demo.