diff options
| author | Stefan Kerkmann <karlk90@pm.me> | 2025-03-21 08:47:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-21 08:47:22 +0100 |
| commit | c9d62ddc78e879053241202b288d0129073b07dc (patch) | |
| tree | 1e58dcea290874bf8af5ea7ca797fe3515885488 /lib/python/qmk/cli | |
| parent | d603fb09139a5a55e1efd910a3989e38f138446f (diff) | |
[Core] use `keycode_string` in unit tests (#25042)
* tests: use keycode_string feature
With a proper keycode to string implementation in qmk there is no need
to use the unit tests only implementation anymore.
Signed-off-by: Stefan Kerkmann <karlk90@pm.me>
* tests: remove keycode_util feature
This feature is no longer used as we switched the tests to the
keycode string implementation.
Signed-off-by: Stefan Kerkmann <karlk90@pm.me>
Diffstat (limited to 'lib/python/qmk/cli')
| -rw-r--r-- | lib/python/qmk/cli/__init__.py | 1 | ||||
| -rw-r--r-- | lib/python/qmk/cli/generate/keycodes_tests.py | 39 |
2 files changed, 0 insertions, 40 deletions
diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py index cb949d9a71..26905ec134 100644 --- a/lib/python/qmk/cli/__init__.py +++ b/lib/python/qmk/cli/__init__.py | |||
| @@ -58,7 +58,6 @@ subcommands = [ | |||
| 58 | 'qmk.cli.generate.keyboard_c', | 58 | 'qmk.cli.generate.keyboard_c', |
| 59 | 'qmk.cli.generate.keyboard_h', | 59 | 'qmk.cli.generate.keyboard_h', |
| 60 | 'qmk.cli.generate.keycodes', | 60 | 'qmk.cli.generate.keycodes', |
| 61 | 'qmk.cli.generate.keycodes_tests', | ||
| 62 | 'qmk.cli.generate.keymap_h', | 61 | 'qmk.cli.generate.keymap_h', |
| 63 | 'qmk.cli.generate.make_dependencies', | 62 | 'qmk.cli.generate.make_dependencies', |
| 64 | 'qmk.cli.generate.rgb_breathe_table', | 63 | 'qmk.cli.generate.rgb_breathe_table', |
diff --git a/lib/python/qmk/cli/generate/keycodes_tests.py b/lib/python/qmk/cli/generate/keycodes_tests.py deleted file mode 100644 index 453b4693a7..0000000000 --- a/lib/python/qmk/cli/generate/keycodes_tests.py +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | """Used by the make system to generate a keycode lookup table from keycodes_{version}.json | ||
| 2 | """ | ||
| 3 | from milc import cli | ||
| 4 | |||
| 5 | from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE | ||
| 6 | from qmk.commands import dump_lines | ||
| 7 | from qmk.path import normpath | ||
| 8 | from qmk.keycodes import load_spec | ||
| 9 | |||
| 10 | |||
| 11 | def _generate_defines(lines, keycodes): | ||
| 12 | lines.append('') | ||
| 13 | lines.append('std::map<uint16_t, std::string> KEYCODE_ID_TABLE = {') | ||
| 14 | for key, value in keycodes["keycodes"].items(): | ||
| 15 | lines.append(f' {{{value.get("key")}, "{value.get("key")}"}},') | ||
| 16 | lines.append('};') | ||
| 17 | |||
| 18 | |||
| 19 | @cli.argument('-v', '--version', arg_only=True, required=True, help='Version of keycodes to generate.') | ||
| 20 | @cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') | ||
| 21 | @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") | ||
| 22 | @cli.subcommand('Used by the make system to generate a keycode lookup table from keycodes_{version}.json', hidden=True) | ||
| 23 | def generate_keycodes_tests(cli): | ||
| 24 | """Generates a keycode to identifier lookup table for unit test output. | ||
| 25 | """ | ||
| 26 | |||
| 27 | # Build the keycodes.h file. | ||
| 28 | keycodes_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '// clang-format off'] | ||
| 29 | keycodes_h_lines.append('extern "C" {\n#include <keycode.h>\n}') | ||
| 30 | keycodes_h_lines.append('#include <map>') | ||
| 31 | keycodes_h_lines.append('#include <string>') | ||
| 32 | keycodes_h_lines.append('#include <cstdint>') | ||
| 33 | |||
| 34 | keycodes = load_spec(cli.args.version) | ||
| 35 | |||
| 36 | _generate_defines(keycodes_h_lines, keycodes) | ||
| 37 | |||
| 38 | # Show the results | ||
| 39 | dump_lines(cli.args.output, keycodes_h_lines, cli.args.quiet) | ||
