aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/test_util.fish
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_util.fish')
-rw-r--r--tests/test_util.fish36
1 files changed, 12 insertions, 24 deletions
diff --git a/tests/test_util.fish b/tests/test_util.fish
index 22744b34..7e8f1fd6 100644
--- a/tests/test_util.fish
+++ b/tests/test_util.fish
@@ -19,8 +19,8 @@ function die
exit 1
end
-# check if we're running in the test environment
-# if not, set it up and rerun fish with exec.
+# Check if we're running in the test environment.
+# If not, set it up and rerun fish with exec.
# The test is whether the special var __fish_is_running_tests
# exists and contains the same value as XDG_CONFIG_HOME. It checks
# the value and not just the presence because we're going to delete
@@ -37,19 +37,21 @@ if not set -q __fish_is_running_tests
end
set -l IFS # clear IFS so cmd substitution doesn't split
cd (dirname $script); or die
- set -xl XDG_CONFIG_HOME (printf '%s/tmp.config/%s' $PWD %self); or die
- if test -d $XDG_CONFIG_HOME
- # if the dir already exists, we've reused a pid
- # this would be surprising to reuse a fish pid that failed in the past,
- # but clear it anyway
- rm -r $XDG_CONFIG_HOME; or die
- end
+
+ set -lx XDG_DATA_HOME ../test/data
+ rm -rf $XDG_DATA_HOME/fish
+ mkdir -p $XDG_DATA_HOME/fish; or die
+
+ set -lx XDG_CONFIG_HOME ../test/home
+ rm -rf $XDG_CONFIG_HOME/fish
mkdir -p $XDG_CONFIG_HOME/fish; or die
ln -s $PWD/test_functions $XDG_CONFIG_HOME/fish/functions; or die
+
set -l escaped_parent (dirname $PWD | sed -e 's/[\'\\\\]/\\\\&/g'); or die
set -l escaped_config (printf '%s/fish' $XDG_CONFIG_HOME | sed -e 's/[\'\\\\]/\\\\&/g'); or die
printf 'set fish_function_path \'%s/functions\' \'%s/share/functions\'\n' $escaped_config $escaped_parent > $XDG_CONFIG_HOME/fish/config.fish; or die
set -xl __fish_is_running_tests $XDG_CONFIG_HOME
+
# set locale information to be consistent
set -lx LANG C
set -lx LC_ALL ''
@@ -57,27 +59,13 @@ if not set -q __fish_is_running_tests
set -lx LC_$var ''
end
set -lx LC_CTYPE en_US.UTF-8
- exec ../fish $script $args_for_test_script
+ exec ../test/root/bin/fish $script $args_for_test_script
die 'exec failed'
else if test "$__fish_is_running_tests" != "$XDG_CONFIG_HOME"
echo 'Something went wrong with the test runner.' >&2
echo "__fish_is_running_tests: $__fish_is_running_tests" >&2
echo "XDG_CONFIG_HOME: $XDG_CONFIG_HOME" >&2
exit 10
-else
- # we're running tests with a temporary config directory
- function test_util_on_exit --on-process-exit %self -V __fish_is_running_tests
- if not set -q __fish_test_keep_tmp_config
- # remove the temporary config directory
- # unfortunately if this fails we can't alter the exit status of fish
- if not rm -r "$__fish_is_running_tests"
- echo "error: Couldn't remove temporary config directory '$__fish_is_running_tests'" >&2
- end
- end
- end
- # unset __fish_is_running_tests so any children that source
- # test_util.fish will set up a new test environment.
- set -e __fish_is_running_tests
end
set -l suppress_color