Eliminate shared temporary directory for tests

Aside from the fact that the shared state could cause problems, tests
were randomly assuming it would be created where that wasn't the case.
In particular, `redirect.fish` and `basic.fish` were failing on only
macOS because `../test/temp` didn't exist yet - it would be created by
other tests later.
This commit is contained in:
Mahmoud Al-Qudsi
2021-03-23 19:26:16 -05:00
committed by Johannes Altmanninger
parent c35113aef1
commit 9796b95f48
4 changed files with 20 additions and 15 deletions

View File

@@ -42,12 +42,12 @@ end
# Simple function tests
function foo
echo >../test/temp/fish_foo.txt $argv
echo >$TMPDIR/fish_foo.txt $argv
end
foo hello
cat ../test/temp/fish_foo.txt |read foo
cat $TMPDIR/fish_foo.txt |read foo
if test $foo = hello;
echo Test 2 pass
@@ -297,7 +297,7 @@ else if test -n "def"
else if not_a_valid_command but it should be OK because a previous branch was taken
echo "epsilon 5.3"
else if test ! -n "abc"
echo "epsilon 5.4"
echo "epsilon 5.4"
end
#CHECK: epsilon5.2
@@ -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 > ../test/temp/file_truncation_test.txt
cat ../test/temp/file_truncation_test.txt
echo -n > ../test/temp/file_truncation_test.txt
cat ../test/temp/file_truncation_test.txt
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
#CHECK: abc
# Test events.

View File

@@ -67,8 +67,8 @@ rm -Rf $tmpdir
begin
echo output
echo errput 1>&2
end 2>&1 | sort | tee ../test/temp/tee_test.txt
cat ../test/temp/tee_test.txt
end 2>&1 | sort | tee $TMPDIR/tee_test.txt
cat $TMPDIR/tee_test.txt
#CHECK: errput
#CHECK: output
#CHECK: errput

View File

@@ -16,16 +16,15 @@ cd $oldpwd
rm -Rf $dir
# Verify that we can do wildcard expansion when we
# don't have read access to some path components
# Verify that we can do wildcard expansion when we don't have read access to some path components.
# See #2099
set -l where ../test/temp/fish_wildcard_permissions_test/noaccess/yesaccess
set -l where $TMPDIR/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/*
#CHECK: ../test/temp/fish_wildcard_permissions_test/noaccess/yesaccess/__env.fish ../test/temp/fish_wildcard_permissions_test/noaccess/yesaccess/alpha.txt ../test/temp/fish_wildcard_permissions_test/noaccess/yesaccess/beta.txt ../test/temp/fish_wildcard_permissions_test/noaccess/yesaccess/delta.txt
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
chmod 700 (dirname $where) # so we can delete it
rm -rf ../test/temp/fish_wildcard_permissions_test
rm -rf $TMPDIR/fish_wildcard_permissions_test

View File

@@ -54,6 +54,12 @@ XDG_RUNTIME_DIR="$homedir/xdg_runtime_dir"
export XDG_CONFIG_HOME
mkdir -p $XDG_RUNTIME_DIR/fish || die
# Create a temp/scratch directory for tests to use, if they want (tests shouldn't write to a
# shared temp folder).
TMPDIR="$homedir/temp"
mkdir ${TMPDIR}
export TMPDIR
# These are used read-only so it's OK to symlink instead of copy
rm -f "$XDG_CONFIG_HOME/fish/functions"
ln -s "$PWD/test_functions" "$XDG_CONFIG_HOME/fish/functions" || die "Failed to symlink"