make testing on local servers hermetic

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
This commit is contained in:
Kurtis Rader
2016-02-06 18:08:22 -08:00
parent c79ade9627
commit 8b67a1b26f
15 changed files with 155 additions and 142 deletions

15
tests/interactive.fish Executable file → Normal file
View File

@@ -1,6 +1,8 @@
#!/usr/local/bin/fish
#
# Interactive tests using `expect`
#
# There is no shebang line because you shouldn't be running this by hand. You
# should be running it via `make test` to ensure the environment is properly
# setup.
# Change to directory containing this script
cd (dirname (status -f))
@@ -13,6 +15,7 @@ else
end
source test_util.fish (status -f) $argv; or exit
cat interactive.config >> $XDG_CONFIG_HOME/fish/config.fish
say -o cyan "Testing interactive functionality"
if not type -q expect
@@ -21,17 +24,9 @@ if not type -q expect
end
function test_file
rm -Rf tmp.interactive.config; or die "Couldn't remove tmp.interactive.config"
mkdir -p tmp.interactive.config/fish; or die "Couldn't create tmp.interactive.config/fish"
cat $XDG_CONFIG_HOME/fish/config.fish interactive.config > tmp.interactive.config/fish/config.fish
or die "Couldn't create tmp.interactive.config/fish/config.fish"
set -l file $argv[1]
echo -n "Testing file $file ... "
begin
set -lx XDG_CONFIG_HOME $PWD/tmp.interactive.config
set -lx TERM dumb
expect -n -c 'source interactive.expect.rc' -f $file >$file.tmp.out ^$file.tmp.err
end