From 9f387f525cb7f9099c4a90ad42d1195c1901c2a3 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 4 Aug 2024 01:55:02 +1000 Subject: Remove `handwired/pytest/has_template` (#24232) --- lib/python/qmk/tests/test_cli_commands.py | 78 +++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 20 deletions(-) (limited to 'lib/python/qmk/tests/test_cli_commands.py') diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index 8b50d1c340..674bb54be2 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -142,9 +142,34 @@ def test_list_keymaps_no_keyboard_found(): def test_json2c(): - result = check_subcommand('json2c', 'keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json') + result = check_subcommand('json2c', 'keyboards/handwired/pytest/basic/keymaps/default_json/keymap.json') check_returncode(result) - assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n\n' + assert result.stdout == """#include QMK_KEYBOARD_H +#if __has_include("keymap.h") +# include "keymap.h" +#endif + + +/* THIS FILE WAS GENERATED! + * + * This file was generated by qmk json2c. You may or may not want to + * edit it directly. + */ +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +\t[0] = LAYOUT_ortho_1x1(KC_A) +}; + +#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + +}; +#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) + + + + + +""" def test_json2c_macros(): @@ -156,9 +181,34 @@ def test_json2c_macros(): def test_json2c_stdin(): - result = check_subcommand_stdin('keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json', 'json2c', '-') + result = check_subcommand_stdin('keyboards/handwired/pytest/basic/keymaps/default_json/keymap.json', 'json2c', '-') check_returncode(result) - assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n\n' + assert result.stdout == """#include QMK_KEYBOARD_H +#if __has_include("keymap.h") +# include "keymap.h" +#endif + + +/* THIS FILE WAS GENERATED! + * + * This file was generated by qmk json2c. You may or may not want to + * edit it directly. + */ +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +\t[0] = LAYOUT_ortho_1x1(KC_A) +}; + +#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + +}; +#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) + + + + + +""" def test_json2c_wrong_json(): @@ -223,27 +273,15 @@ def test_info_matrix_render(): def test_c2json(): - result = check_subcommand("c2json", "-kb", "handwired/pytest/has_template", "-km", "default", "keyboards/handwired/pytest/has_template/keymaps/default/keymap.c") + result = check_subcommand("c2json", "-kb", "handwired/pytest/basic", "-km", "default", "keyboards/handwired/pytest/basic/keymaps/default/keymap.c") check_returncode(result) - assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}' - - -def test_c2json_nocpp(): - result = check_subcommand("c2json", "--no-cpp", "-kb", "handwired/pytest/has_template", "-km", "default", "keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c") - check_returncode(result) - assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_ENTER"]]}' + assert result.stdout.strip() == '{"keyboard": "handwired/pytest/basic", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}' def test_c2json_stdin(): - result = check_subcommand_stdin("keyboards/handwired/pytest/has_template/keymaps/default/keymap.c", "c2json", "-kb", "handwired/pytest/has_template", "-km", "default", "-") - check_returncode(result) - assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}' - - -def test_c2json_nocpp_stdin(): - result = check_subcommand_stdin("keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c", "c2json", "--no-cpp", "-kb", "handwired/pytest/has_template", "-km", "default", "-") + result = check_subcommand_stdin("keyboards/handwired/pytest/basic/keymaps/default/keymap.c", "c2json", "-kb", "handwired/pytest/basic", "-km", "default", "-") check_returncode(result) - assert result.stdout.strip() == '{"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_ENTER"]]}' + assert result.stdout.strip() == '{"keyboard": "handwired/pytest/basic", "keymap": "default", "layout": "LAYOUT_ortho_1x1", "layers": [["KC_A"]]}' def test_clean(): -- cgit v1.2.3 From 1f942bb17e0f324f81788106a72c7573304d65ff Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 4 Aug 2024 21:28:40 +1000 Subject: Small tweaks to keymap generation (#24240) --- lib/python/qmk/keymap.py | 5 ++--- lib/python/qmk/tests/test_cli_commands.py | 6 ++---- lib/python/qmk/tests/test_qmk_keymap.py | 3 +-- 3 files changed, 5 insertions(+), 9 deletions(-) (limited to 'lib/python/qmk/tests/test_cli_commands.py') diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index ca76f1b288..8c09cc51dc 100644 --- a/lib/python/qmk/keymap.py +++ b/lib/python/qmk/keymap.py @@ -40,7 +40,6 @@ __ENCODER_MAP_GOES_HERE__ #endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) __MACRO_OUTPUT_GOES_HERE__ - """ @@ -51,7 +50,7 @@ def _generate_keymap_table(keymap_json): lines[-1] = lines[-1] + ',' layer = map(_strip_any, layer) layer_keys = ', '.join(layer) - lines.append('\t[%s] = %s(%s)' % (layer_num, keymap_json['layout'], layer_keys)) + lines.append(' [%s] = %s(%s)' % (layer_num, keymap_json['layout'], layer_keys)) return lines @@ -61,7 +60,7 @@ def _generate_encodermap_table(keymap_json): if layer_num != 0: lines[-1] = lines[-1] + ',' encoder_keycode_txt = ', '.join([f'ENCODER_CCW_CW({_strip_any(e["ccw"])}, {_strip_any(e["cw"])})' for e in layer]) - lines.append('\t[%s] = {%s}' % (layer_num, encoder_keycode_txt)) + lines.append(' [%s] = {%s}' % (layer_num, encoder_keycode_txt)) return lines diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index 674bb54be2..2b3d6f4049 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -156,7 +156,7 @@ def test_json2c(): * edit it directly. */ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { -\t[0] = LAYOUT_ortho_1x1(KC_A) + [0] = LAYOUT_ortho_1x1(KC_A) }; #if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) @@ -168,7 +168,6 @@ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { - """ @@ -195,7 +194,7 @@ def test_json2c_stdin(): * edit it directly. */ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { -\t[0] = LAYOUT_ortho_1x1(KC_A) + [0] = LAYOUT_ortho_1x1(KC_A) }; #if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) @@ -207,7 +206,6 @@ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { - """ diff --git a/lib/python/qmk/tests/test_qmk_keymap.py b/lib/python/qmk/tests/test_qmk_keymap.py index b4b8f4bbe0..bec3f4006c 100644 --- a/lib/python/qmk/tests/test_qmk_keymap.py +++ b/lib/python/qmk/tests/test_qmk_keymap.py @@ -31,7 +31,7 @@ def test_generate_c_pytest_basic(): * edit it directly. */ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { -\t[0] = LAYOUT(KC_A) + [0] = LAYOUT(KC_A) }; #if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) @@ -41,7 +41,6 @@ const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { #endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) - """ -- cgit v1.2.3 From 5741eb7b10ecc7da4453424004fd291ed0573e4d Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 26 Aug 2024 09:57:35 +1000 Subject: Fixup python tests for missing `via` keymaps. --- lib/python/qmk/tests/test_cli_commands.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/python/qmk/tests/test_cli_commands.py') diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index 2b3d6f4049..4c322e0c9d 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -118,21 +118,18 @@ def test_list_keymaps_kb_only(): result = check_subcommand('list-keymaps', '-kb', 'contra') check_returncode(result) assert 'default' in result.stdout - assert 'via' in result.stdout def test_list_keymaps_vendor_kb(): result = check_subcommand('list-keymaps', '-kb', 'ai03/lunar') check_returncode(result) assert 'default' in result.stdout - assert 'via' in result.stdout def test_list_keymaps_vendor_kb_rev(): result = check_subcommand('list-keymaps', '-kb', 'kbdfans/kbd67/mkiirgb/v2') check_returncode(result) assert 'default' in result.stdout - assert 'via' in result.stdout def test_list_keymaps_no_keyboard_found(): -- cgit v1.2.3