Add launcher test for list style options

This commit is contained in:
Kovid Goyal
2025-04-28 13:55:36 +05:30
parent ead724ee28
commit 909b8747d3
2 changed files with 10 additions and 8 deletions

View File

@@ -359,18 +359,18 @@ output_argv(const char *name, int argc, char **argv) {
static void
output_values_for_testing(CLISpec *spec) {
value_map_for_loop(&spec->value_map) {
printf("%s: ", itr.data->key);
CLIValue v = itr.data->val;
switch (v.type) {
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:
printf("%d", v.boolval); break;
printf("%s: %d", itr.data->key, v.boolval); break;
case CLI_VALUE_INT:
printf("%lld", v.intval); break;
printf("%s: %lld", itr.data->key, v.intval); break;
case CLI_VALUE_FLOAT:
printf("%f", v.floatval); break;
printf("%s: %f", itr.data->key, v.floatval); break;
case CLI_VALUE_LIST:
output_argv(itr.data->key, v.listval.count, (char**)v.listval.items);
break;
}
printf("\n");

View File

@@ -126,6 +126,7 @@ version
def launcher(self):
kexe = kitty_exe()
cfgdir = os.path.join(os.environ['XDG_CONFIG_HOME'], 'kitty')
def get_report(cmdline: str, launch_services= False):
args = list(shlex_split(cmdline))
env = dict(os.environ)
@@ -141,7 +142,7 @@ def launcher(self):
key, val = line.split(':')
except ValueError:
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]
else:
val = val.strip()
@@ -155,7 +156,7 @@ def launcher(self):
def t(cmdline, **assertions):
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')
test(cmdline, assertions)
@@ -182,7 +183,8 @@ def launcher(self):
test(cmdline, assertions)
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')
t('+kitten unwrapped xyz', argv=['+kitten', 'unwrapped', 'xyz'])
t('+ kitten unwrapped xyz', original_argv=[kexe, '+', 'kitten', 'unwrapped', 'xyz'])