diff --git a/keyboards/handwired/pytest/has_template/keymaps/default/keymap.c b/keyboards/handwired/pytest/has_template/keymaps/default/keymap.c deleted file mode 100644 index a5782f7a13..0000000000 --- a/keyboards/handwired/pytest/has_template/keymaps/default/keymap.c +++ /dev/null @@ -1,5 +0,0 @@ -#include QMK_KEYBOARD_H - -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - LAYOUT_ortho_1x1(KC_A) -}; diff --git a/keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json b/keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json deleted file mode 100644 index cbdce6db32..0000000000 --- a/keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "keyboard": "handwired/pytest/has_template", - "keymap": "default_json", - "layout": "LAYOUT_ortho_1x1", - "layers": [["KC_A"]], - "author": "qmk", - "notes": "This file is a keymap.json file for handwired/pytest/has_template", - "version": 1 -} diff --git a/keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c b/keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c deleted file mode 100644 index 65cd4cebea..0000000000 --- a/keyboards/handwired/pytest/has_template/keymaps/nocpp/keymap.c +++ /dev/null @@ -1,23 +0,0 @@ -#include QMK_KEYBOARD_H -#include "audio.h" - -/* THIS FILE WAS GENERATED AND IS EXPERIMENTAL! - * - * This file was generated by qmk-compile-json. You may or may not want to - * edit it directly. - */ - -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [0] = LAYOUT(KC_ENTER) -}; - -bool encoder_update_user(uint8_t index, bool clockwise) { - if (index == 0) { - if (clockwise) { - tap_code(KC_UP); - } else { - tap_code(KC_DOWN); - } - } - return true; -}; diff --git a/keyboards/handwired/pytest/has_template/readme.md b/keyboards/handwired/pytest/has_template/readme.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/keyboards/handwired/pytest/has_template/rules.mk b/keyboards/handwired/pytest/has_template/rules.mk deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/keyboards/handwired/pytest/has_template/templates/keymap.c b/keyboards/handwired/pytest/has_template/templates/keymap.c deleted file mode 100644 index 6cb25d5226..0000000000 --- a/keyboards/handwired/pytest/has_template/templates/keymap.c +++ /dev/null @@ -1,2 +0,0 @@ -#include QMK_KEYBOARD_H -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {__KEYMAP_GOES_HERE__}; diff --git a/keyboards/handwired/pytest/has_template/templates/keymap.json b/keyboards/handwired/pytest/has_template/templates/keymap.json deleted file mode 100644 index 04928564e9..0000000000 --- a/keyboards/handwired/pytest/has_template/templates/keymap.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "documentation": "This file is a keymap.json file for handwired/pytest/has_template" -} 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", "-") + 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_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", "-") - 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(): diff --git a/lib/python/qmk/tests/test_qmk_keymap.py b/lib/python/qmk/tests/test_qmk_keymap.py index 5e2efc1232..b4b8f4bbe0 100644 --- a/lib/python/qmk/tests/test_qmk_keymap.py +++ b/lib/python/qmk/tests/test_qmk_keymap.py @@ -11,30 +11,43 @@ def test_template_json_pytest_basic(): assert templ == {'keyboard': 'handwired/pytest/basic'} -def test_template_c_pytest_has_template(): - templ = qmk.keymap.template_c('handwired/pytest/has_template') - assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {__KEYMAP_GOES_HERE__};\n' - - -def test_template_json_pytest_has_template(): - templ = qmk.keymap.template_json('handwired/pytest/has_template') - assert templ == {'keyboard': 'handwired/pytest/has_template', "documentation": "This file is a keymap.json file for handwired/pytest/has_template"} - - -def test_generate_c_pytest_has_template(): +def test_generate_c_pytest_basic(): keymap_json = { - 'keyboard': 'handwired/pytest/has_template', + 'keyboard': 'handwired/pytest/basic', 'layout': 'LAYOUT', 'layers': [['KC_A']], 'macros': None, } templ = qmk.keymap.generate_c(keymap_json) - assert templ == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT(KC_A)};\n' + assert templ == """#include QMK_KEYBOARD_H +#if __has_include("keymap.h") +# include "keymap.h" +#endif -def test_generate_json_pytest_has_template(): - templ = qmk.keymap.generate_json('default', 'handwired/pytest/has_template', 'LAYOUT', [['KC_A']]) - assert templ == {"keyboard": "handwired/pytest/has_template", "documentation": "This file is a keymap.json file for handwired/pytest/has_template", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_A"]]} +/* 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(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_generate_json_pytest_basic(): + templ = qmk.keymap.generate_json('default', 'handwired/pytest/basic', 'LAYOUT', [['KC_A']]) + assert templ == {"keyboard": "handwired/pytest/basic", "keymap": "default", "layout": "LAYOUT", "layers": [["KC_A"]]} def test_parse_keymap_c():