spiegel-keyman/core/tests/unit/kmx/README.md
Marc Durdin c18ef54029 refactor(common): move core baseline tests into common
Decided to use the name `baseline` for this set of tests. They can be
used by any project in the repo now. Tests will be treated as shared,
and not modified (except in the case of a buggy test).

* Moves .kmn files, add `&NAME` line (don't use meson templating for
  these files)
* Generates reference .kmx files using kmcomp for use as a baseline with
  kmcmplib (kmc) tests, and for linux tests
* Updates references in core, kmcmplib, and linux builds
* Renames all the .kmn / .kmx to use a standardized, clean name format
  (this was needed for building packages in the core tests)
2023-03-28 05:20:45 +07:00

1.9 KiB

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.

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_038___punctkeys.kmn' '../common/test/keyboards/baseline/k_038___punctkeys.kmx'

or shorter:

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