From 6c48e214ca3233c23bc7e08c2ec4cfa48b22ea69 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 12 Oct 2025 06:31:28 +0200 Subject: [PATCH] tests/checks/check-completions: fix for embed-data builds --- share/functions/__fish_list_files.fish | 16 ++++++++++++++++ share/functions/__fish_with_file.fish | 10 ++++++++++ tests/checks/check-completions.fish | 4 ++-- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 share/functions/__fish_list_files.fish create mode 100644 share/functions/__fish_with_file.fish diff --git a/share/functions/__fish_list_files.fish b/share/functions/__fish_list_files.fish new file mode 100644 index 000000000..72f5a2c39 --- /dev/null +++ b/share/functions/__fish_list_files.fish @@ -0,0 +1,16 @@ +# localization: skip(private) +function __fish_list_files + set -l dir $argv[1] + if set -q __fish_data_dir[1] + # Construct a directory prefix without trailing slash. + if test -n "$dir" + set dir $__fish_data_dir/$dir + else + set dir $__fish_data_dir + end + set -l files $dir/** + string replace -- $dir/ '' $files + else + status list-files $dir + end +end diff --git a/share/functions/__fish_with_file.fish b/share/functions/__fish_with_file.fish new file mode 100644 index 000000000..81c415748 --- /dev/null +++ b/share/functions/__fish_with_file.fish @@ -0,0 +1,10 @@ +# localization: skip(private) +function __fish_with_file + set -l file $argv[1] + set -l cmd $argv[2..] + if set -q __fish_data_dir[1] + $cmd $__fish_data_dir/$file + else + status get-file $file | $cmd + end +end diff --git a/tests/checks/check-completions.fish b/tests/checks/check-completions.fish index 50c4fa166..2d2da6cb8 100644 --- a/tests/checks/check-completions.fish +++ b/tests/checks/check-completions.fish @@ -4,9 +4,9 @@ # Test all completions where the command exists # No output is good output -for f in $__fish_data_dir/completions/*.fish +for f in (__fish_list_files completions | string match 'completions/*.fish') if type -q (string replace -r '.*/([^/]+).fish' '$1' $f) - set -l out (source $f 2>&1 | string collect) + set -l out (__fish_with_file $f source 2>&1 | string collect) test -n "$out" and echo -- OUTPUT from $f: $out end