spiegel-keyman/core/tests/unit/kmx
Eberhard Beilharz a329ef967d
Update core/tests/unit/kmx/README.md
Co-authored-by: Marc Durdin <marc@durdin.net>
2026-01-15 12:05:25 +01:00
..
fixtures chore(core): remove meson warnings for wasm builds 2024-12-12 19:48:13 +01:00
template chore(core): use kmc to build .kmn files 2023-03-23 14:03:37 +07:00
cat.bat chore(common): cleanup meson deprecations and warnings 2024-05-24 08:46:52 +07:00
keyboards.kpj.in maint(core): batch build kmx in tests for performance 2025-04-30 06:02:59 +07:00
kmp.json.in chore(common): move common/core/desktop/ to core/ 2022-05-18 07:22:10 +10:00
kmx.cpp chore(core): Merge branch 'master' into fix/core/12619-disable-assertions-vcwin-release-build 2024-12-01 16:17:21 +07:00
kmx_external_event.tests.cpp chore(core): Merge branch 'master' into fix/core/12619-disable-assertions-vcwin-release-build 2024-12-01 16:17:21 +07:00
kmx_imsample.kmn chore(common): move common/core/desktop/ to core/ 2022-05-18 07:22:10 +10:00
kmx_imx.tests.cpp chore(core): Merge branch 'master' into fix/core/12619-disable-assertions-vcwin-release-build 2024-12-01 16:17:21 +07:00
kmx_key_list.kmn chore: rename km_kbp_ to km_core_ 2023-10-09 14:53:13 +07:00
kmx_key_list.tests.cpp chore(core): Merge branch 'master' into fix/core/12619-disable-assertions-vcwin-release-build 2024-12-01 16:17:21 +07:00
meson.build Merge branch 'epic/web-core' into test/web/problem 2026-01-07 11:37:49 +01:00
README.md Update core/tests/unit/kmx/README.md 2026-01-15 12:05:25 +01:00

KMX unit tests

This directory contains unit tests that test the KMX processing.

The driver (kmx.cpp) loads and executes the tests. Each test consist of a Keyman keyboard source file (0*.kmn) and the compiled KMX keyboard. The source file contains rules and defines the setup, input and expected results.

Defining tests in the .kmn file

The top of the file contains comments that define the setup, input and expected results. Following the comments are the normal rules of a Keyman keyboard.

Setup

  • description: this is just for commenting what we test here
c Description: Tests Caps Lock env set
  • option: allows to put the system in a defined state. The example below sets the platform:
c option: &platform=linux
  • capsLock: allows to set the caps lock state. The example below turns caps-lock on at the start of the test. [K_CAPS] in the keys comment allows toggling of caps lock.
c capsLock: 1
  • context: allows to setup a string which serves as context
c context:

Input

  • keys: defines one or more virtual keys that will be processed one after the other
c keys: [K_1][K_CAPS][K_2][SHIFT K_3][K_4][K_CAPS][K_5][K_CAPS][K_6]

Expected Result

  • expected: the resulting string of processing the input keys. In the example below each key press is expected to output the string 'pass.'.
c expected: pass.pass.pass.pass.pass.pass.

Expected Options

  • expected option: the resulting key/value pairs for the in-memory options.
c expected option: foo=0
  • saved option: the resulting key/value pairs of persisted options.
c saved option: foo=0

Running the tests

All tests can be run at once with ./build.sh --debug tests.

Alternatively it's possible to run a single test with:

cd core
build/arch/debug/tests/unit/kmx/kmx '../common/test/keyboards/baseline/k_0107___punctkeys.kmn' '../common/test/keyboards/baseline/k_0107___punctkeys.kmx'

or shorter:

cd core
build/arch/debug/tests/unit/kmx/kmx '../common/test/keyboards/baseline/k_0107___punctkeys'.km{n,x}