Remove TMPDIR dependency from tests/

Tests are now executed in a test-specific temporary directory, so test
output on failure should be reproducible/reusable as-is without needing
to have TMPDIR defined (as it only exists by default under macOS).
This commit is contained in:
Mahmoud Al-Qudsi 2021-07-30 19:21:36 -05:00 committed by Johannes Altmanninger
parent 6fc8038b4e
commit e96b6e157c
5 changed files with 23 additions and 20 deletions

View file

@ -42,12 +42,12 @@ end
# Simple function tests
function foo
echo >$TMPDIR/fish_foo.txt $argv
echo >./fish_foo.txt $argv
end
foo hello
cat $TMPDIR/fish_foo.txt |read foo
cat ./fish_foo.txt |read foo
if test $foo = hello;
echo Test 2 pass
@ -327,10 +327,10 @@ type -q -f fish_test_type_zzz ; echo $status
# ensure that builtins that produce no output can still truncate files
# (bug PCA almost reintroduced!)
echo abc > $TMPDIR/file_truncation_test.txt
cat $TMPDIR/file_truncation_test.txt
echo -n > $TMPDIR/file_truncation_test.txt
cat $TMPDIR/file_truncation_test.txt
echo abc > ./file_truncation_test.txt
cat ./file_truncation_test.txt
echo -n > ./file_truncation_test.txt
cat ./file_truncation_test.txt
#CHECK: abc
# Test events.

View file

@ -60,15 +60,16 @@ foo $tmpdir/bar
cat $tmpdir/bar
# CHECK: foo
rm -Rf $tmpdir
# Verify that we can turn stderr into stdout and then pipe it
# Note that the order here has historically been unspecified - 'errput' could conceivably appear before 'output'.
begin
echo output
echo errput 1>&2
end 2>&1 | sort | tee $TMPDIR/tee_test.txt
cat $TMPDIR/tee_test.txt
end 2>&1 | sort | tee $tmpdir/tee_test.txt
cat $tmpdir/tee_test.txt
rm -Rf $tmpdir
#CHECK: errput
#CHECK: output
#CHECK: errput

View file

@ -6,9 +6,9 @@ set fish (builtin realpath $fish)
# Isolated tmux. tmux can't handle session sockets in paths that are too long, and macOS has a very
# long $TMPDIR, so use a relative path - except macOS doesn't have `realpath --relative-to`...
# We have a unique TMPDIR assigned by the test driver, so this will work so long as `tmux` is only
# invoked from the same PWD.
set tmpdir (command mktemp -d $TMPDIR/tmp.XXXXXXXX)
# We are cd'd into a unique temp dir created/assigned by the test driver, so this will work so long
# as `tmux` is only invoked from the same PWD.
set tmpdir (command mktemp -d ./tmp.XXXXXXXX)
cd $tmpdir
set -g tmux tmux -S ./.tmux-socket -f /dev/null

View file

@ -18,13 +18,13 @@ rm -Rf $dir
# Verify that we can do wildcard expansion when we don't have read access to some path components.
# See #2099
set -l where $TMPDIR/fish_wildcard_permissions_test/noaccess/yesaccess
set -l where ./fish_wildcard_permissions_test/noaccess/yesaccess
mkdir -p $where
chmod 300 (dirname $where) # no read permissions
mkdir -p $where
# "__env.fish" here to confirm ordering - #6593.
touch $where/alpha.txt $where/beta.txt $where/delta.txt $where/__env.fish
echo $where/* | string replace -a $TMPDIR '$TMPDIR'
#CHECK: $TMPDIR/fish_wildcard_permissions_test/noaccess/yesaccess/__env.fish $TMPDIR/fish_wildcard_permissions_test/noaccess/yesaccess/alpha.txt $TMPDIR/fish_wildcard_permissions_test/noaccess/yesaccess/beta.txt $TMPDIR/fish_wildcard_permissions_test/noaccess/yesaccess/delta.txt
echo $where/*
#CHECK: ./fish_wildcard_permissions_test/noaccess/yesaccess/__env.fish ./fish_wildcard_permissions_test/noaccess/yesaccess/alpha.txt ./fish_wildcard_permissions_test/noaccess/yesaccess/beta.txt ./fish_wildcard_permissions_test/noaccess/yesaccess/delta.txt
chmod 700 (dirname $where) # so we can delete it
rm -rf $TMPDIR/fish_wildcard_permissions_test
rm -rf ./fish_wildcard_permissions_test

View file

@ -112,10 +112,12 @@ export suppress_color
# Source test util functions at startup
fish_init_cmd="${fish_init_cmd} && source ${TESTS_ROOT}/test_util.fish";
# Run the test script, but don't exec so we can do cleanup after it succeeds/fails
env HOME="$homedir" "${BUILD_ROOT}/test/root/bin/fish" \
# Run the test script, but don't exec so we can do cleanup after it succeeds/fails. Each test is
# launched directly within its TMPDIR, so that the fish tests themselves do not need to refer to
# TMPDIR (to ensure their output as displayed in case of failure by littlecheck is reproducible).
(cd $TMPDIR; env HOME="$homedir" "${BUILD_ROOT}/test/root/bin/fish" \
--init-command "${fish_init_cmd}" \
"$fish_script" "$script_args"
"$fish_script" "$script_args")
test_status="$?"
rm -rf "$homedir"