From f51134deef75c6eeafba41cb0a9870274579a3f3 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Aug 2014 16:01:03 +0400 Subject: [PATCH] Run shell tests in an isolated environment --- tests/test_shells/input.tcsh | 4 +-- tests/test_shells/test.sh | 58 ++++++++++++++++++++++++++++++-- tests/test_shells/zsh.daemon.ok | Bin 11878 -> 12453 bytes 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/tests/test_shells/input.tcsh b/tests/test_shells/input.tcsh index 0bc6b78a..3b5b1eb0 100644 --- a/tests/test_shells/input.tcsh +++ b/tests/test_shells/input.tcsh @@ -1,10 +1,10 @@ source powerline/bindings/tcsh/powerline.tcsh -setenv POWERLINE_COMMAND "$POWERLINE_COMMAND -p "$PWD:q/powerline/config_files" -t default_leftonly.segment_data.hostname.args.only_if_ssh=false -c ext.shell.theme=default_leftonly" +set POWERLINE_COMMAND=$POWERLINE_COMMAND:q" -p "$PWD:q/powerline/config_files" -t default_leftonly.segment_data.hostname.args.only_if_ssh=false -c ext.shell.theme=default_leftonly" unsetenv VIRTUAL_ENV cd tests/shell/3rd cd .git cd .. -setenv VIRTUAL_ENV $HOME:q"/.virtenvs/some-virtual-environment" +setenv VIRTUAL_ENV "/home/foo/.virtenvs/some-virtual-environment" unsetenv VIRTUAL_ENV bash -c 'echo $$>pid ; while true ; do sleep 0.1s ; done' & false # Warning: currently tcsh bindings do not support job count diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index a5e8f26e..4aff414e 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -17,6 +17,25 @@ check_screen_log() { fi } +run() { + local local_path="$PWD/tests/shell/path:$PWD/scripts" + if test "x$SH" = "xfish" ; then + local_path="${local_path}:/usr/bin:/bin" + fi + env -i \ + PATH="$local_path" \ + TERM="${TERM}" \ + COLUMNS="${COLUMNS}" \ + LINES="${LINES}" \ + TEST_TYPE="${TEST_TYPE}" \ + SH="${SH}" \ + DIR1="${DIR1}" \ + DIR2="${DIR2}" \ + XDG_CONFIG_HOME="$PWD/tests/shell/fish_home" \ + IPYTHONDIR="$PWD/tests/shell/ipython_home" \ + "$@" +} + run_test() { TEST_TYPE="$1" shift @@ -41,7 +60,7 @@ run_test() { export TEST_TYPE export SH - screen -L -c tests/test_shells/screenrc -d -m -S "$SESNAME" \ + run screen -L -c tests/test_shells/screenrc -d -m -S "$SESNAME" \ env LANG=en_US.UTF-8 BINDFILE="$BINDFILE" "${ARGS[@]}" screen -S "$SESNAME" -X readreg a tests/test_shells/input.$SH # Wait for screen to initialize @@ -121,8 +140,41 @@ mkdir tests/shell/3rd/'`echo`' mkdir tests/shell/fish_home cp -r tests/test_shells/ipython_home tests/shell -export XDG_CONFIG_HOME="$PWD/tests/shell/fish_home" -export IPYTHONDIR="$PWD/tests/shell/ipython_home" + +mkdir tests/shell/path +ln -s "$(which "${PYTHON:-python}")" tests/shell/path/python +ln -s "$(which screen)" tests/shell/path +ln -s "$(which env)" tests/shell/path +ln -s "$(which sleep)" tests/shell/path +ln -s "$(which cat)" tests/shell/path +ln -s "$(which false)" tests/shell/path +ln -s "$(which true)" tests/shell/path +ln -s "$(which kill)" tests/shell/path +ln -s "$(which echo)" tests/shell/path +ln -s "$(which which)" tests/shell/path +ln -s "$(which dirname)" tests/shell/path +ln -s "$(which wc)" tests/shell/path +ln -s "$(which stty)" tests/shell/path +ln -s "$(which cut)" tests/shell/path +ln -s "$(which bc)" tests/shell/path +ln -s "$(which expr)" tests/shell/path +ln -s "$(which mktemp)" tests/shell/path +for pexe in powerline powerline-config ; do + if test -e scripts/$pexe ; then + ln -s "$PWD/scripts/$pexe" tests/shell/path + elif which $pexe ; then + ln -s "$(which $pexe)" tests/shell/path + else + echo "Executable $pexe was not found" + exit 1 + fi +done + +for exe in bash zsh bb busybox fish tcsh mksh dash ipython ; do + if which $exe >/dev/null ; then + ln -s "$(which $exe)" tests/shell/path + fi +done unset ENV diff --git a/tests/test_shells/zsh.daemon.ok b/tests/test_shells/zsh.daemon.ok index 7469e23b61ee6790cceceee1aa8a298fed046535..3582bc706c3cb143b0a69653a315f1300642a859 100644 GIT binary patch delta 467 zcmaDBvovvop@NdNiG{VPwIPr+%ssTg(=XUHDCE!r>1YFMW2nSrU2cuZ8`+~LcPW3F z+^Z-pY7Eh1WNZl5*q4rP+VlPF}D&(<>oGBK}HfxCRIJyCErywNw5N}rAA$e zR4uQj2V;dw7*O~r6@gl0cR$dU9T()7e{8lR?~!wuhmcju{Yak8#7K` zu4OWLwhS-Rp#_^4s`D^T&d{=-T&QC(@iq@oXmTRYk;xl$>n1zsl>)IWqr&7TddVOb cmjVbR6{RL-PyVPE1{9K?%w`ZdxzNA_0LUCZE&u=k