Allow tests/checks/basic.fish to run without test driver

On request of a team member, this patches `basic.fish` to no longer
depend on being invoked by the test driver and started up in a $PWD that
points to a clean temporary directory.
This commit is contained in:
Mahmoud Al-Qudsi 2021-08-29 12:42:52 -05:00
parent 2157d91a5c
commit 9a071090dc

View File

@ -3,6 +3,10 @@
# Test function, loops, conditionals and some basic elements
#
# The test driver always starts each test in its own temporary directory, but to make it easier to
# run this test directly for whatever reason:
set -g tmpdir (mktemp -d)
# Comments in odd places don't cause problems
for i in 1 2 # Comment on same line as command
# Comment inside loop
@ -42,12 +46,12 @@ end
# Simple function tests
function foo
echo >./fish_foo.txt $argv
echo > $tmpdir/fish_foo.txt $argv
end
foo hello
cat ./fish_foo.txt |read foo
cat $tmpdir/fish_foo.txt |read foo
if test $foo = hello;
echo Test 2 pass
@ -327,10 +331,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 > ./file_truncation_test.txt
cat ./file_truncation_test.txt
echo -n > ./file_truncation_test.txt
cat ./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.