summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2020-06-19 04:37:47 +1000
committerDrashna Jael're <drashna@live.com>2020-08-08 21:16:44 -0700
commit43dadc79ff72be3b29b55283808c6be9ce9b7efc (patch)
tree173e0a9def718b00f2af2dc7da87ef4a61670f22
parent4badbca51731bcdb63b3b52ac5e1fcdaf356aac2 (diff)
Parse version better in `qmk doctor` GCC version checks (#9324)
-rwxr-xr-xlib/python/qmk/cli/doctor.py15
-rw-r--r--lib/python/qmk/tests/test_cli_commands.py8
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/python/qmk/cli/doctor.py b/lib/python/qmk/cli/doctor.py
index 011c3dd3c2..4d7ba52181 100755
--- a/lib/python/qmk/cli/doctor.py
+++ b/lib/python/qmk/cli/doctor.py
@@ -3,6 +3,7 @@
Check out the user's QMK environment and make sure it's ready to compile.
"""
import platform
+import re
import shutil
import subprocess
from pathlib import Path
@@ -50,6 +51,16 @@ def _deprecated_udev_rule(vid, pid=None):
return 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="%s", MODE:="0666"' % vid
+def parse_gcc_version(version):
+ m = re.match(r"(\d+)(?:\.(\d+))?(?:\.(\d+))?", version)
+
+ return {
+ 'major': int(m.group(1)),
+ 'minor': int(m.group(2)) if m.group(2) else 0,
+ 'patch': int(m.group(3)) if m.group(3) else 0
+ }
+
+
def check_arm_gcc_version():
"""Returns True if the arm-none-eabi-gcc version is not known to cause problems.
"""
@@ -66,8 +77,8 @@ def check_avr_gcc_version():
if 'output' in ESSENTIAL_BINARIES['avr-gcc']:
version_number = ESSENTIAL_BINARIES['avr-gcc']['output'].strip()
- major, minor, rest = version_number.split('.', 2)
- if int(major) > 8:
+ parsed_version = parse_gcc_version(version_number)
+ if parsed_version['major'] > 8:
cli.log.error('We do not recommend avr-gcc newer than 8. Downgrading to 8.x is recommended.')
return False
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index dce270de83..68f8ed6047 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -115,7 +115,7 @@ def test_list_keymaps_no_keyboard_found():
def test_json2c():
result = check_subcommand('json2c', 'keyboards/handwired/onekey/keymaps/default_json/keymap.json')
check_returncode(result, 0)
- assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT(KC_A)};\n\n'
+ 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'
def test_info():
@@ -132,7 +132,7 @@ def test_info_keyboard_render():
check_returncode(result)
assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout
assert 'Processor: STM32F303' in result.stdout
- assert 'Layout:' in result.stdout
+ assert 'Layouts:' in result.stdout
assert 'k0' in result.stdout
@@ -149,6 +149,6 @@ def test_info_matrix_render():
check_returncode(result)
assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout
assert 'Processor: STM32F303' in result.stdout
- assert 'LAYOUT' in result.stdout
+ assert 'LAYOUT_ortho_1x1' in result.stdout
assert '│0A│' in result.stdout
- assert 'Matrix for "LAYOUT"' in result.stdout
+ assert 'Matrix for "LAYOUT_ortho_1x1"' in result.stdout