mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Add launcher test for list style options
This commit is contained in:
@@ -359,18 +359,18 @@ output_argv(const char *name, int argc, char **argv) {
|
|||||||
static void
|
static void
|
||||||
output_values_for_testing(CLISpec *spec) {
|
output_values_for_testing(CLISpec *spec) {
|
||||||
value_map_for_loop(&spec->value_map) {
|
value_map_for_loop(&spec->value_map) {
|
||||||
printf("%s: ", itr.data->key);
|
|
||||||
CLIValue v = itr.data->val;
|
CLIValue v = itr.data->val;
|
||||||
switch (v.type) {
|
switch (v.type) {
|
||||||
case CLI_VALUE_STRING: case CLI_VALUE_CHOICE:
|
case CLI_VALUE_STRING: case CLI_VALUE_CHOICE:
|
||||||
printf("%s", v.strval ? v.strval : ""); break;
|
printf("%s: %s", itr.data->key, v.strval ? v.strval : ""); break;
|
||||||
case CLI_VALUE_BOOL:
|
case CLI_VALUE_BOOL:
|
||||||
printf("%d", v.boolval); break;
|
printf("%s: %d", itr.data->key, v.boolval); break;
|
||||||
case CLI_VALUE_INT:
|
case CLI_VALUE_INT:
|
||||||
printf("%lld", v.intval); break;
|
printf("%s: %lld", itr.data->key, v.intval); break;
|
||||||
case CLI_VALUE_FLOAT:
|
case CLI_VALUE_FLOAT:
|
||||||
printf("%f", v.floatval); break;
|
printf("%s: %f", itr.data->key, v.floatval); break;
|
||||||
case CLI_VALUE_LIST:
|
case CLI_VALUE_LIST:
|
||||||
|
output_argv(itr.data->key, v.listval.count, (char**)v.listval.items);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ version
|
|||||||
|
|
||||||
def launcher(self):
|
def launcher(self):
|
||||||
kexe = kitty_exe()
|
kexe = kitty_exe()
|
||||||
|
cfgdir = os.path.join(os.environ['XDG_CONFIG_HOME'], 'kitty')
|
||||||
def get_report(cmdline: str, launch_services= False):
|
def get_report(cmdline: str, launch_services= False):
|
||||||
args = list(shlex_split(cmdline))
|
args = list(shlex_split(cmdline))
|
||||||
env = dict(os.environ)
|
env = dict(os.environ)
|
||||||
@@ -141,7 +142,7 @@ def launcher(self):
|
|||||||
key, val = line.split(':')
|
key, val = line.split(':')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise AssertionError(f'Unexpected output from launcher: {line!r}\n{cp.stdout.decode()}')
|
raise AssertionError(f'Unexpected output from launcher: {line!r}\n{cp.stdout.decode()}')
|
||||||
if key in ('argv', 'original_argv', 'open_urls'):
|
if '\x1e' in val:
|
||||||
val = [x for x in val.split('\x1e') if x]
|
val = [x for x in val.split('\x1e') if x]
|
||||||
else:
|
else:
|
||||||
val = val.strip()
|
val = val.strip()
|
||||||
@@ -155,7 +156,7 @@ def launcher(self):
|
|||||||
|
|
||||||
def t(cmdline, **assertions):
|
def t(cmdline, **assertions):
|
||||||
assertions['is_quick_access_terminal'] = '0'
|
assertions['is_quick_access_terminal'] = '0'
|
||||||
assertions['config_dir'] = os.path.join(os.environ['XDG_CONFIG_HOME'], 'kitty')
|
assertions['config_dir'] = cfgdir
|
||||||
assertions.setdefault('launched_by_launch_services', '0')
|
assertions.setdefault('launched_by_launch_services', '0')
|
||||||
test(cmdline, assertions)
|
test(cmdline, assertions)
|
||||||
|
|
||||||
@@ -182,7 +183,8 @@ def launcher(self):
|
|||||||
test(cmdline, assertions)
|
test(cmdline, assertions)
|
||||||
|
|
||||||
t('', original_argv=[kexe], argv=[])
|
t('', original_argv=[kexe], argv=[])
|
||||||
t('--title=xxx cat', title='xxx', original_argv=[kexe, '--title=xxx', 'cat'], argv=['cat'])
|
t('--title=xxx --start-as maximized -c=a -c b cat', title='xxx', start_as='maximized', config=['a', 'b'], original_argv=[
|
||||||
|
kexe, '--title=xxx', '--start-as', 'maximized', '-c=a', '-c', 'b', 'cat'], argv=['cat'])
|
||||||
k('icat abc xyz')
|
k('icat abc xyz')
|
||||||
t('+kitten unwrapped xyz', argv=['+kitten', 'unwrapped', 'xyz'])
|
t('+kitten unwrapped xyz', argv=['+kitten', 'unwrapped', 'xyz'])
|
||||||
t('+ kitten unwrapped xyz', original_argv=[kexe, '+', 'kitten', 'unwrapped', 'xyz'])
|
t('+ kitten unwrapped xyz', original_argv=[kexe, '+', 'kitten', 'unwrapped', 'xyz'])
|
||||||
|
|||||||
Reference in New Issue
Block a user