File: run_tests

package info (click to toggle)
virtualenvwrapper 3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,140 kB
  • sloc: sh: 3,801; python: 991; makefile: 27
file content (93 lines) | stat: -rwxr-xr-x 2,429 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh

#set -x

if [ -z "$TOXIC" ]
then
    echo "Only run this via tox" 1>&2
    exit 1
fi

envdir="$1"
shift
scripts="$*"
if [ -z "$scripts" ]
then
    scripts=$(ls tests/test*.sh)
    if [ -z "$scripts" ]
    then
        echo "Could not find any test scripts to run" 1>&2
        exit 1
    fi
fi

# Make sure the test shells exist before proceeding, otherwise tests are
# going to fail later.
missing_shells=""
test_shells=""
for shell in bash ksh zsh
do
    if test_shell=$(which $shell); then
        test_shells="$test_shells $test_shell"
    else
        missing_shells="$missing_shells $shell"
    fi
done
if [ -n "$missing_shells" ]
then
    echo "Couldn't find the following shells: $missing_shells" 1>&2
    exit 1
fi

# Force the tox virtualenv to be active.  
#
# Since this script runs from within a separate shell created by tox,
# the name of the virtualenv (in $VIRTUAL_ENV) is inherited, but the
# shell functions and other settings created by the activate script
# are *not* inherited.
#
source "$envdir/bin/activate"

# Set up virtualenvwrapper.hook_loader to print more details than usual for debugging.
#export HOOK_VERBOSE_OPTION=-vvv
export HOOK_VERBOSE_OPTION="-q"

# Force virtualenvwrapper to use the python interpreter in the
# tox-created virtualenv.
export VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python"

# Clear any user settings for the hook directory or log directory
unset VIRTUALENVWRAPPER_HOOK_DIR
unset VIRTUALENVWRAPPER_LOG_DIR
unset VIRTUALENVWRAPPER_VIRTUALENV
unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS

# Run the test scripts with a little formatting around them to make it
# easier to find where each script output starts.
for test_script in $scripts
do

    for test_shell in $test_shells
    do
        test_shell_opts=
        case /$test_shell in
            */zsh) test_shell_opts="-o shwordsplit" ;;
        esac
        export test_shell

        echo
        echo '********************************************************************************'
        echo "Running $test_script"
        echo "  VIRTUAL_ENV=$VIRTUAL_ENV"
        echo "  VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON"
        echo "    $($VIRTUALENVWRAPPER_PYTHON -V 2>&1)"
        echo "  PYTHONPATH=$PYTHONPATH"
        echo "  SHELL=$test_shell"
        echo
        export SHUNIT_PARENT="$test_script"
        $test_shell $test_shell_opts $test_script || exit 1
        echo
    done
done

exit 0