Exemplo n.º 1
0
def test_path():
    '''
    Calls --path argument
    '''
    args = ['--path']
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 2
0
def test_layout_cache_path():
    '''
    Calls --layout-cache-path argument
    '''
    args = ['--layout-cache-path']
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 3
0
def test_version():
    '''
    Calls --version argument
    '''
    args = ['--version']
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 4
0
def test_help():
    '''
    Calls --help argument
    '''
    args = ['--help']
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 5
0
def test_help():
    '''
    Calls --help argument
    '''
    args = ['--help']
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 6
0
def test_version():
    '''
    Calls --version argument
    '''
    args = ['--version']
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 7
0
def test_path():
    '''
    Calls --path argument
    '''
    args = ['--path']
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 8
0
def test_layout_cache_path():
    '''
    Calls --layout-cache-path argument
    '''
    args = ['--layout-cache-path']
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 9
0
def test_regen(input_file):
    '''
    Runs regen test on each of the specified files
    '''
    # Prepare tmp directory
    sanitized_input_file = input_file.replace('/', '-')
    tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
    os.makedirs(tmp_dir, exist_ok=True)
    target_dir = tempfile.mkdtemp(suffix='-{}'.format(sanitized_input_file), prefix='regen-', dir=tmp_dir)

    # Determine cmp and new files
    cmp_filename = '{}_final.kll'.format(os.path.splitext(os.path.basename(input_file))[0])
    cmp_file = os.path.join('tests', 'cmp_regen', cmp_filename)
    new_file = os.path.join(target_dir, 'final.kll')

    # Run test
    args = ['--emitter', 'kll', '--output-debug', input_file, '--target-dir', target_dir]
    header_test('{} {} {}'.format(input_file, target_dir, cmp_file), args)
    ret = kll_run(args)
    assert ret == 0

    # Check if files are different
    if not filecmp.cmp(cmp_file, new_file):
        # Run diff as both files are different
        with open(cmp_file, 'r') as cmpfile:
            with open(new_file, 'r') as newfile:
                # Run diff and fail the test
                diff = difflib.ndiff(cmpfile.readlines(), newfile.readlines())
                print(''.join(diff), end="")
                assert False
Exemplo n.º 10
0
def test_kiibohd_klltest2(kiibohd_controller_repo):
    '''
    Kiibohd test using klltest.kll
    '''
    # Prepare tmp directory
    tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
    os.makedirs(tmp_dir, exist_ok=True)
    target_dir = tempfile.mkdtemp(suffix='-klltest2', prefix='kiibohd-', dir=tmp_dir)

    # Controller git repo
    controller = kiibohd_controller_repo

    # Run test
    args = [
        '--config',
        os.path.join(controller, 'Scan/Devices/MatrixARMPeriodic/capabilities.kll'),
        os.path.join(controller, 'Macro/PartialMap/capabilities.kll'),
        os.path.join(controller, 'Output/USB/capabilities.kll'),
        '--base',
        os.path.join(controller, 'Scan/Infinity_60/scancode_map.kll'),
        '--default',
        'kll/layouts/klltest.kll',
        '--emitter', 'kiibohd',
        '--def-output', os.path.join(target_dir, 'kll_defs.h'),
        '--map-output', os.path.join(target_dir, 'generatedKeymap.h'),
        '--hid-output', os.path.join(target_dir, 'usb_hid.h'),
        '--pixel-output', os.path.join(target_dir, 'generatedPixelmap.c'),
        '--json-output', os.path.join(target_dir, 'kll.json'),
    ]
    header_test('{}'.format(target_dir), args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 11
0
def test_layout_cache_refresh():
    '''
    Calls --layout-cache-refresh argument
    '''
    args = ['--layout-cache-refresh']
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 12
0
def test_syntax(input_file):
    '''
    Runs syntax test on each of the specified files
    '''
    args = ['--emitter', 'none', '--data-finalization-display', input_file]
    header_test(input_file, args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 13
0
def test_syntax_fail_debug(input_file):
    '''
    Runs syntax test on each of the specified files, including failure debug options
    '''
    args = ['--emitter', 'none', '--token-debug', '--parser-token-debug', '--operation-organization-display', '--data-organization-display', '--data-finalization-display', input_file]
    header_test(input_file, args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 14
0
def test_syntax(input_file):
    '''
    Runs syntax test on each of the specified files
    '''
    args = ['--emitter', 'none', '--data-finalization-display', input_file]
    header_test(input_file, args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 15
0
def test_kiibohd_interconnect(kiibohd_controller_repo):
    '''
    Interconnect test (Infinity Ergodox)
    '''
    # Prepare tmp directory
    tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
    os.makedirs(tmp_dir, exist_ok=True)
    target_dir = tempfile.mkdtemp(suffix='-interconnect',
                                  prefix='kiibohd-',
                                  dir=tmp_dir)

    # Controller git repo
    controller = kiibohd_controller_repo

    # Run test
    args = [
        '--config',
        os.path.join(controller, 'Scan/Devices/ISSILed/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/MatrixARM/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/STLcd/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/UARTConnect/capabilities.kll'),
        os.path.join(controller, 'Macro/PartialMap/capabilities.kll'),
        os.path.join(controller, 'Macro/PixelMap/capabilities.kll'),
        os.path.join(controller, 'Output/HID-IO/capabilities.kll'),
        os.path.join(controller, 'Output/USB/capabilities.kll'),
        '--base',
        os.path.join(controller, 'Scan/Infinity_Ergodox/scancode_map.kll'),
        os.path.join(controller, 'Scan/Infinity_Ergodox/leftHand.kll'),
        os.path.join(controller, 'Scan/Infinity_Ergodox/slave1.kll'),
        os.path.join(controller, 'Scan/Infinity_Ergodox/rightHand.kll'),
        'kll/examples/nonetest.kll',
        '--default',
        'kll/layouts/infinity_ergodox/mdergo1Overlay.kll',
        'kll/layouts/infinity_ergodox/lcdFuncMap.kll',
        '--partial',
        'kll/layouts/infinity_ergodox/iced_func.kll',
        'kll/layouts/infinity_ergodox/mdergo1Overlay.kll',
        'kll/layouts/infinity_ergodox/lcdFuncMap.kll',
        '--partial',
        'kll/layouts/infinity_ergodox/iced_numpad.kll',
        '--emitter',
        'kiibohd',
        '--def-output',
        os.path.join(target_dir, 'kll_defs.h'),
        '--map-output',
        os.path.join(target_dir, 'generatedKeymap.h'),
        '--hid-output',
        os.path.join(target_dir, 'usb_hid.h'),
        '--pixel-output',
        os.path.join(target_dir, 'generatedPixelmap.c'),
        '--json-output',
        os.path.join(target_dir, 'kll.json'),
    ]
    header_test('{}'.format(target_dir), args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 16
0
def test_syntax_operation_debug(input_file):
    '''
    Runs syntax test on each of the specified files, including --operation-organization-display
    '''
    args = [
        '--emitter', 'none', '--data-finalization-display',
        '--operation-organization-display', input_file
    ]
    header_test(input_file, args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 17
0
def test_kiibohd_add(kiibohd_controller_repo):
    '''
    Add test (K-Type)
    '''
    # Prepare tmp directory
    tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
    os.makedirs(tmp_dir, exist_ok=True)
    target_dir = tempfile.mkdtemp(suffix='-add',
                                  prefix='kiibohd-',
                                  dir=tmp_dir)

    # Controller git repo
    controller = kiibohd_controller_repo

    # Run test
    args = [
        '--config',
        os.path.join(controller, 'Scan/Devices/ISSILed/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/MatrixARM/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/PortSwap/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/UARTConnect/capabilities.kll'),
        os.path.join(controller, 'Macro/PartialMap/capabilities.kll'),
        os.path.join(controller, 'Macro/PixelMap/capabilities.kll'),
        os.path.join(controller, 'Output/HID-IO/capabilities.kll'),
        os.path.join(controller, 'Output/USB/capabilities.kll'),
        '--base',
        os.path.join(controller, 'Scan/K-Type/scancode_map.kll'),
        os.path.join(controller, 'Scan/WhiteFox/scancode_map.truefox.kll'),
        '--default',
        'kll/layouts/animation_test.kll',
        'kll/layouts/stdFuncMap.kll',
        '--partial',
        'kll/layouts/k-type/unset_v1.kll',
        'kll/layouts/k-type/rainbow_wipe.kll',
        '--partial',
        'kll/layouts/k-type/unset_v1.kll',
        'kll/layouts/k-type/color_painter.kll',
        '--emitter',
        'kiibohd',
        '--def-output',
        os.path.join(target_dir, 'kll_defs.h'),
        '--map-output',
        os.path.join(target_dir, 'generatedKeymap.h'),
        '--hid-output',
        os.path.join(target_dir, 'usb_hid.h'),
        '--pixel-output',
        os.path.join(target_dir, 'generatedPixelmap.c'),
        '--json-output',
        os.path.join(target_dir, 'kll.json'),
    ]
    header_test('{}'.format(target_dir), args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 18
0
def test_locale(input_files):
    '''
    Runs locale test on each of the specified file sets
    '''
    # Prepare tmp directory
    sanitized_input_file = "_".join(input_files).replace('/', '-')
    tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
    os.makedirs(tmp_dir, exist_ok=True)
    target_dir = tempfile.mkdtemp(suffix='-{}'.format(sanitized_input_file), prefix='locale-', dir=tmp_dir)

    # Run test
    args = ['--emitter', 'kll', '--output-debug', '--target-dir', target_dir] + input_files
    header_test('{} {}'.format(" ".join(input_files), target_dir), args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 19
0
def test_kiibohd_func1(kiibohd_controller_repo):
    '''
    Multiple Function1 test (WhiteFox)
    '''
    # Prepare tmp directory
    tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
    os.makedirs(tmp_dir, exist_ok=True)
    target_dir = tempfile.mkdtemp(suffix='-func1',
                                  prefix='kiibohd-',
                                  dir=tmp_dir)

    # Controller git repo
    controller = kiibohd_controller_repo

    # Run test
    args = [
        '--config',
        os.path.join(controller, 'Scan/Devices/ISSILed/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/MatrixARM/capabilities.kll'),
        os.path.join(controller, 'Macro/PartialMap/capabilities.kll'),
        os.path.join(controller, 'Macro/PixelMap/capabilities.kll'),
        os.path.join(controller, 'Output/HID-IO/capabilities.kll'),
        os.path.join(controller, 'Output/USB/capabilities.kll'),
        '--base',
        os.path.join(controller, 'Scan/WhiteFox/scancode_map.kll'),
        os.path.join(controller, 'Scan/WhiteFox/scancode_map.truefox.kll'),
        '--default',
        'kll/layouts/tab_function.kll',
        'kll/layouts/stdFuncMap.kll',
        '--partial',
        'kll/layouts/whitefox/whitefox.kll',
        'kll/layouts/stdFuncMap.kll',
        '--emitter',
        'kiibohd',
        '--def-output',
        os.path.join(target_dir, 'kll_defs.h'),
        '--map-output',
        os.path.join(target_dir, 'generatedKeymap.h'),
        '--hid-output',
        os.path.join(target_dir, 'usb_hid.h'),
        '--pixel-output',
        os.path.join(target_dir, 'generatedPixelmap.c'),
        '--json-output',
        os.path.join(target_dir, 'kll.json'),
    ]
    header_test('{}'.format(target_dir), args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 20
0
def test_kiibohd_interconnect(kiibohd_controller_repo):
    '''
    Interconnect test (Infinity Ergodox)
    '''
    # Prepare tmp directory
    tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
    os.makedirs(tmp_dir, exist_ok=True)
    target_dir = tempfile.mkdtemp(suffix='-interconnect', prefix='kiibohd-', dir=tmp_dir)

    # Controller git repo
    controller = kiibohd_controller_repo

    # Run test
    args = [
        '--config',
        os.path.join(controller, 'Scan/Devices/ISSILed/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/MatrixARMPeriodic/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/STLcd/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/UARTConnect/capabilities.kll'),
        os.path.join(controller, 'Macro/PartialMap/capabilities.kll'),
        os.path.join(controller, 'Macro/PixelMap/capabilities.kll'),
        os.path.join(controller, 'Output/HID-IO/capabilities.kll'),
        os.path.join(controller, 'Output/USB/capabilities.kll'),
        '--base',
        os.path.join(controller, 'Scan/Infinity_Ergodox/scancode_map.kll'),
        os.path.join(controller, 'Scan/Infinity_Ergodox/leftHand.kll'),
        os.path.join(controller, 'Scan/Infinity_Ergodox/slave1.kll'),
        os.path.join(controller, 'Scan/Infinity_Ergodox/rightHand.kll'),
        'kll/examples/nonetest.kll',
        '--default',
        'kll/layouts/infinity_ergodox/mdergo1Overlay.kll',
        'kll/layouts/infinity_ergodox/lcdFuncMap.kll',
        '--partial',
        'kll/layouts/infinity_ergodox/iced_func.kll',
        'kll/layouts/infinity_ergodox/mdergo1Overlay.kll',
        'kll/layouts/infinity_ergodox/lcdFuncMap.kll',
        '--partial',
        'kll/layouts/infinity_ergodox/iced_numpad.kll',
        '--emitter', 'kiibohd',
        '--def-output', os.path.join(target_dir, 'kll_defs.h'),
        '--map-output', os.path.join(target_dir, 'generatedKeymap.h'),
        '--hid-output', os.path.join(target_dir, 'usb_hid.h'),
        '--pixel-output', os.path.join(target_dir, 'generatedPixelmap.c'),
        '--json-output', os.path.join(target_dir, 'kll.json'),
    ]
    header_test('{}'.format(target_dir), args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 21
0
def test_kiibohd_add(kiibohd_controller_repo):
    '''
    Add test (K-Type)
    '''
    # Prepare tmp directory
    tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
    os.makedirs(tmp_dir, exist_ok=True)
    target_dir = tempfile.mkdtemp(suffix='-add', prefix='kiibohd-', dir=tmp_dir)

    # Controller git repo
    controller = kiibohd_controller_repo

    # Run test
    args = [
        '--config',
        os.path.join(controller, 'Scan/Devices/ISSILed/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/MatrixARMPeriodic/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/PortSwap/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/UARTConnect/capabilities.kll'),
        os.path.join(controller, 'Macro/PartialMap/capabilities.kll'),
        os.path.join(controller, 'Macro/PixelMap/capabilities.kll'),
        os.path.join(controller, 'Output/HID-IO/capabilities.kll'),
        os.path.join(controller, 'Output/USB/capabilities.kll'),
        '--base',
        os.path.join(controller, 'Scan/K-Type/scancode_map.kll'),
        os.path.join(controller, 'Scan/WhiteFox/scancode_map.truefox.kll'),
        '--default',
        'kll/layouts/animation_test.kll',
        'kll/layouts/stdFuncMap.kll',
        '--partial',
        'kll/layouts/k-type/unset_v1.kll',
        'kll/layouts/k-type/rainbow_wipe.kll',
        '--partial',
        'kll/layouts/k-type/unset_v1.kll',
        'kll/layouts/k-type/color_painter.kll',
        '--emitter', 'kiibohd',
        '--def-output', os.path.join(target_dir, 'kll_defs.h'),
        '--map-output', os.path.join(target_dir, 'generatedKeymap.h'),
        '--hid-output', os.path.join(target_dir, 'usb_hid.h'),
        '--pixel-output', os.path.join(target_dir, 'generatedPixelmap.c'),
        '--json-output', os.path.join(target_dir, 'kll.json'),
    ]
    header_test('{}'.format(target_dir), args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 22
0
def test_locale(input_files):
    '''
    Runs locale test on each of the specified file sets
    '''
    # Prepare tmp directory
    sanitized_input_file = "_".join(input_files).replace('/', '-')
    tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
    os.makedirs(tmp_dir, exist_ok=True)
    target_dir = tempfile.mkdtemp(suffix='-{}'.format(sanitized_input_file),
                                  prefix='locale-',
                                  dir=tmp_dir)

    # Run test
    args = ['--emitter', 'kll', '--output-debug', '--target-dir', target_dir
            ] + input_files
    header_test('{} {}'.format(" ".join(input_files), target_dir), args)
    ret = kll_run(args)
    assert ret == 0
Exemplo n.º 23
0
def test_kiibohd_func1(kiibohd_controller_repo):
    '''
    Multiple Function1 test (WhiteFox)
    '''
    # Prepare tmp directory
    tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
    os.makedirs(tmp_dir, exist_ok=True)
    target_dir = tempfile.mkdtemp(suffix='-func1', prefix='kiibohd-', dir=tmp_dir)

    # Controller git repo
    controller = kiibohd_controller_repo

    # Run test
    args = [
        '--config',
        os.path.join(controller, 'Scan/Devices/ISSILed/capabilities.kll'),
        os.path.join(controller, 'Scan/Devices/MatrixARMPeriodic/capabilities.kll'),
        os.path.join(controller, 'Macro/PartialMap/capabilities.kll'),
        os.path.join(controller, 'Macro/PixelMap/capabilities.kll'),
        os.path.join(controller, 'Output/HID-IO/capabilities.kll'),
        os.path.join(controller, 'Output/USB/capabilities.kll'),
        '--base',
        os.path.join(controller, 'Scan/WhiteFox/scancode_map.kll'),
        os.path.join(controller, 'Scan/WhiteFox/scancode_map.truefox.kll'),
        '--default',
        'kll/layouts/tab_function.kll',
        'kll/layouts/stdFuncMap.kll',
        '--partial',
        'kll/layouts/whitefox/whitefox.kll',
        'kll/layouts/stdFuncMap.kll',
        '--emitter', 'kiibohd',
        '--def-output', os.path.join(target_dir, 'kll_defs.h'),
        '--map-output', os.path.join(target_dir, 'generatedKeymap.h'),
        '--hid-output', os.path.join(target_dir, 'usb_hid.h'),
        '--pixel-output', os.path.join(target_dir, 'generatedPixelmap.c'),
        '--json-output', os.path.join(target_dir, 'kll.json'),
    ]
    header_test('{}'.format(target_dir), args)
    ret = kll_run(args)
    assert ret == 0