mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 19:49:15 +08:00
8b67a1b26f
I noticed while fixing issue #2702 that the fish program being tested was sourcing config.fish files outside of the current build. This also happens when Travis CI runs the tests but isn't an issue there because of how Travis is configured to execute the tests. I also noticed that running `make test` was polluting my personal fish history; which will become a bigger problem if and when the fishd universal var file is moved from $XDG_CONFIG_HOME to $XDG_DATA_HOME. This change makes it possible for an individual to run the tests on their local machine secure in the knowledge that only the config.fish and related files from their git repository will be used and doing so won't pollute their personal fish history. Resolves #469
104 lines
1.6 KiB
Fish
104 lines
1.6 KiB
Fish
# Test expansion of variables
|
|
|
|
function show --description 'Prints argument count followed by arguments'
|
|
echo (count $argv) $argv
|
|
end
|
|
|
|
set -l foo
|
|
show "$foo"
|
|
show $foo
|
|
show "prefix$foo"
|
|
show prefix$foo
|
|
|
|
show "$$foo"
|
|
show $$foo
|
|
show "prefix$$foo"
|
|
show prefix$$foo
|
|
|
|
set -l foo ''
|
|
show "$foo"
|
|
show $foo
|
|
show "prefix$foo"
|
|
show prefix$foo
|
|
|
|
show "$$foo"
|
|
show $$foo
|
|
show "prefix$$foo"
|
|
show prefix$$foo
|
|
|
|
set -l foo bar
|
|
set -l bar
|
|
show "$$foo"
|
|
show $$foo
|
|
show "prefix$$foo"
|
|
show prefix$$foo
|
|
|
|
set -l bar baz
|
|
show "$$foo"
|
|
show $$foo
|
|
show "prefix$$foo"
|
|
show prefix$$foo
|
|
|
|
set -l bar baz quux
|
|
show "$$foo"
|
|
show $$foo
|
|
show "prefix$$foo"
|
|
show prefix$$foo
|
|
|
|
set -l foo bar fooer fooest
|
|
set -l fooer
|
|
set -l fooest
|
|
show "$$foo"
|
|
show $$foo
|
|
show "prefix$$foo"
|
|
show prefix$$foo
|
|
|
|
set -l fooer ''
|
|
show $$foo
|
|
show prefix$$foo
|
|
|
|
set -l foo bar '' fooest
|
|
show "$$foo"
|
|
show $$foo
|
|
show "prefix$$foo"
|
|
show prefix$$foo
|
|
|
|
set -l foo
|
|
show "$foo[1]"
|
|
show $foo[1]
|
|
show "$foo[-1]"
|
|
show $foo[-1]
|
|
show "$foo[2]"
|
|
show $foo[2]
|
|
show "$foo[1 2]"
|
|
show $foo[1 2]
|
|
show "$foo[2 1]"
|
|
show $foo[2 1]
|
|
|
|
echo "$foo[d]"
|
|
echo $foo[d]
|
|
|
|
echo ()[1]
|
|
echo ()[d]
|
|
|
|
echo "Catch your breath"
|
|
set paren ')'
|
|
echo $$paren
|
|
|
|
# Test tilde expansion
|
|
# On OS X, /tmp is symlinked to /private/tmp
|
|
# $PWD is our best bet for resolving it
|
|
set -l saved $PWD
|
|
cd (mktemp -d)
|
|
set tmpdir $PWD
|
|
cd $saved
|
|
mkdir $tmpdir/realhome
|
|
ln -s $tmpdir/realhome $tmpdir/linkhome
|
|
set expandedtilde (env HOME=$tmpdir/linkhome ../test/root/bin/fish -c 'echo ~')
|
|
if test $expandedtilde != $tmpdir/realhome
|
|
echo '~ expands to' $expandedtilde ' - expected ' $tmpdir/realhome
|
|
end
|
|
unlink $tmpdir/linkhome
|
|
rmdir $tmpdir/realhome
|
|
rmdir $tmpdir
|