Remove the sanity checker, it is unused and out of date
This commit is contained in:
		
							
								
								
									
										12
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								Makefile
									
									
									
									
									
								
							@@ -55,17 +55,7 @@ powerwash: clean
 | 
			
		||||
	@echo "===> Removing pipenv-managed virtual environment"
 | 
			
		||||
	@$(PIPENV) --rm || true
 | 
			
		||||
 | 
			
		||||
test: lint micropython-build-unix
 | 
			
		||||
	@echo "===> Testing keymap_sanity_check.py script"
 | 
			
		||||
	@echo "    --> Known good layout should pass..."
 | 
			
		||||
	@MICROPYPATH=tests/test_data:./ ./bin/micropython.sh bin/keymap_sanity_check.py keymaps/known_good.py
 | 
			
		||||
	@echo "    --> Layer with ghosted MO should fail..."
 | 
			
		||||
	@MICROPYPATH=tests/test_data:./ ./bin/micropython.sh bin/keymap_sanity_check.py keymaps/ghosted_layer_mo.py 2>/dev/null && exit 1 || exit 0
 | 
			
		||||
	@echo "    --> Sharing a pin between rows/cols should fail..."
 | 
			
		||||
	@MICROPYPATH=tests/test_data:./ ./bin/micropython.sh bin/keymap_sanity_check.py keymaps/duplicated_pins_between_row_col.py 2>/dev/null && exit 1 || exit 0
 | 
			
		||||
	@echo "    --> Sharing a pin between two rows should fail..."
 | 
			
		||||
	@MICROPYPATH=tests/test_data:./ ./bin/micropython.sh bin/keymap_sanity_check.py keymaps/duplicate_row_pins.py 2>/dev/null && exit 1 || exit 0
 | 
			
		||||
	@echo "===> The sanity checker is sane, unlike klardotsh"
 | 
			
		||||
test: lint
 | 
			
		||||
 | 
			
		||||
.submodules: .gitmodules submodules.toml
 | 
			
		||||
	@echo "===> Pulling dependencies, this may take several minutes"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,68 +0,0 @@
 | 
			
		||||
#!/usr/bin/env micropython
 | 
			
		||||
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
import uos
 | 
			
		||||
 | 
			
		||||
from kmk.keycodes import Keycodes, RawKeycodes
 | 
			
		||||
 | 
			
		||||
if len(sys.argv) < 2:
 | 
			
		||||
    print('Must provide a keymap to test as first argument', file=sys.stderr)
 | 
			
		||||
    sys.exit(200)
 | 
			
		||||
 | 
			
		||||
user_keymap_file = sys.argv[1]
 | 
			
		||||
 | 
			
		||||
if user_keymap_file.endswith('.py'):
 | 
			
		||||
    user_keymap_file = user_keymap_file[:-3]
 | 
			
		||||
 | 
			
		||||
# Before we can import the user's keymap, we need to wrangle sys.path to
 | 
			
		||||
# add our stub modules. Before we can do THAT, we have to figure out where
 | 
			
		||||
# we actually are, and that's not the most trivial thing in MicroPython!
 | 
			
		||||
#
 | 
			
		||||
# The hack here is to see if we can find ourselves in whatever uPy thinks
 | 
			
		||||
# the current directory is. If we can, we need to head up a level. Obviously,
 | 
			
		||||
# if the layout of the KMK repo ever changes, this script will need updated
 | 
			
		||||
# or all hell will break loose.
 | 
			
		||||
 | 
			
		||||
# First, hack around https://github.com/micropython/micropython/issues/2322,
 | 
			
		||||
# where frozen modules aren't available if MicroPython is running a script
 | 
			
		||||
# rather than via REPL
 | 
			
		||||
sys.path.insert(0, '')
 | 
			
		||||
 | 
			
		||||
if any(fname == 'keymap_sanity_check.py' for fname, _, _ in uos.ilistdir()):
 | 
			
		||||
    sys.path.extend(('../', '../upy-unix-stubs/'))
 | 
			
		||||
else:
 | 
			
		||||
    sys.path.extend(('./', './upy-unix-stubs'))
 | 
			
		||||
 | 
			
		||||
user_keymap = __import__(user_keymap_file)
 | 
			
		||||
 | 
			
		||||
if hasattr(user_keymap, 'cols') or hasattr(user_keymap, 'rows'):
 | 
			
		||||
    assert hasattr(user_keymap, 'cols'), 'Handwired keyboards must have both rows and cols defined'
 | 
			
		||||
    assert hasattr(user_keymap, 'rows'), 'Handwired keyboards must have both rows and cols defined'
 | 
			
		||||
 | 
			
		||||
    # Ensure that no pins are duplicated in a handwire config
 | 
			
		||||
    # This is the same check done in the MatrixScanners, relying
 | 
			
		||||
    # on the __repr__ of the objects to be unique (because generally,
 | 
			
		||||
    # Pin objects themselves are not hashable)
 | 
			
		||||
    assert len(user_keymap.cols) == len({p for p in user_keymap.cols}), \
 | 
			
		||||
        'Cannot use a single pin for multiple columns'
 | 
			
		||||
    assert len(user_keymap.rows) == len({p for p in user_keymap.rows}), \
 | 
			
		||||
        'Cannot use a single pin for multiple rows'
 | 
			
		||||
 | 
			
		||||
    unique_pins = {repr(c) for c in user_keymap.cols} | {repr(r) for r in user_keymap.rows}
 | 
			
		||||
    assert len(unique_pins) == len(user_keymap.cols) + len(user_keymap.rows), \
 | 
			
		||||
        'Cannot use a pin as both a column and row'
 | 
			
		||||
 | 
			
		||||
assert hasattr(user_keymap, 'keymap'), 'Must define a keymap array'
 | 
			
		||||
assert len(user_keymap.keymap), 'Keymap must contain at least one layer'
 | 
			
		||||
 | 
			
		||||
for lidx, layer in enumerate(user_keymap.keymap):
 | 
			
		||||
    assert len(layer), 'Layer {} must contain at least one row'.format(lidx)
 | 
			
		||||
    assert all(len(row) for row in layer), 'Layer {} must not contain empty rows'.format(lidx)
 | 
			
		||||
 | 
			
		||||
    for ridx, row in enumerate(layer):
 | 
			
		||||
        for cidx, key in enumerate(row):
 | 
			
		||||
            if key.code == RawKeycodes.KC_MO:
 | 
			
		||||
                assert user_keymap.keymap[key.layer][ridx][cidx] == Keycodes.KMK.KC_TRNS, \
 | 
			
		||||
                    ('The physical key used for MO layer switching must be KC_TRNS on the '
 | 
			
		||||
                     'target layer or you will get stuck on that layer.')
 | 
			
		||||
		Reference in New Issue
	
	Block a user