Skip to content

Commit afd6875

Browse files
committed
add tests for the generate commands
1 parent 8df2c74 commit afd6875

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"maintainer": "qmk",
3+
"layouts": {
4+
"LAYOUT_custom": {
5+
"layout": [
6+
{ "label": "KC_Q", "matrix": [0, 0], "w": 1, "x": 0, "y": 0 }
7+
]
8+
}
9+
}
10+
}

lib/python/qmk/cli/generate/config_h.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ def direct_pins(direct_pins):
2424

2525
return """
2626
#ifndef MATRIX_COLS
27-
# define MATRIX_COLS %s
27+
# define MATRIX_COLS %s
2828
#endif // MATRIX_COLS
2929
3030
#ifndef MATRIX_ROWS
31-
# define MATRIX_ROWS %s
31+
# define MATRIX_ROWS %s
3232
#endif // MATRIX_ROWS
3333
3434
#ifndef DIRECT_PINS
35-
# define DIRECT_PINS {%s}
35+
# define DIRECT_PINS {%s}
3636
#endif // DIRECT_PINS
3737
""" % (col_count, row_count, ','.join(rows))
3838

@@ -45,11 +45,11 @@ def pin_array(define, pins):
4545

4646
return f"""
4747
#ifndef {define}S
48-
# define {define}S {pin_num}
48+
# define {define}S {pin_num}
4949
#endif // {define}S
5050
5151
#ifndef {define}_PINS
52-
# define {define}_PINS {{ {pin_array} }}
52+
# define {define}_PINS {{ {pin_array} }}
5353
#endif // {define}_PINS
5454
"""
5555

lib/python/qmk/tests/test_cli_commands.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,32 @@ def test_generate_rgb_breathe_table():
230230
check_returncode(result)
231231
assert 'Breathing center: 1.2' in result.stdout
232232
assert 'Breathing max: 127' in result.stdout
233+
234+
235+
def test_generate_config_h():
236+
result = check_subcommand('generate-config-h', '-kb', 'handwired/pytest/basic')
237+
check_returncode(result)
238+
assert '# define DEVICE_VER 0x0001' in result.stdout
239+
assert '# define DESCRIPTION handwired/pytest/basic' in result.stdout
240+
assert '# define DIODE_DIRECTION COL2ROW' in result.stdout
241+
assert '# define MANUFACTURER none' in result.stdout
242+
assert '# define PRODUCT handwired/pytest/basic' in result.stdout
243+
assert '# define PRODUCT_ID 0x6465' in result.stdout
244+
assert '# define VENDOR_ID 0xFEED' in result.stdout
245+
assert '# define MATRIX_COLS 1' in result.stdout
246+
assert '# define MATRIX_COL_PINS { F4 }' in result.stdout
247+
assert '# define MATRIX_ROWS 1' in result.stdout
248+
assert '# define MATRIX_ROW_PINS { F5 }' in result.stdout
249+
250+
251+
def test_generate_rules_mk():
252+
result = check_subcommand('generate-rules-mk', '-kb', 'handwired/pytest/basic')
253+
check_returncode(result)
254+
assert 'BOOTLOADER ?= atmel-dfu' in result.stdout
255+
assert 'MCU ?= atmega32u4' in result.stdout
256+
257+
258+
def test_generate_layouts():
259+
result = check_subcommand('generate-layouts', '-kb', 'handwired/pytest/basic')
260+
check_returncode(result)
261+
assert '#define LAYOUT_custom(k0A) {' in result.stdout

0 commit comments

Comments
 (0)