Attila Fazekas | 5abb253 | 2012-12-04 11:30:49 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 2 | |
| 3 | function usage { |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 4 | echo "Usage: $0 [OPTION]..." |
| 5 | echo "Run Tempest test suite" |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 6 | echo "" |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 7 | echo " -V, --virtual-env Always use virtualenv. Install automatically if not present" |
| 8 | echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment" |
| 9 | echo " -s, --no-site-packages Isolate the virtualenv from the global Python environment" |
| 10 | echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 11 | echo " -s, --smoke Only run smoke tests" |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 12 | echo " -w, --whitebox Only run whitebox tests" |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 13 | echo " -p, --pep8 Just run pep8" |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 14 | echo " -h, --help Print this usage message" |
Sean Dague | 14a6015 | 2012-12-13 15:59:40 -0500 | [diff] [blame] | 15 | echo " -d, --debug Debug this script -- set -o xtrace" |
| 16 | echo " -S, --stdout Don't capture stdout" |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 17 | exit |
| 18 | } |
| 19 | |
| 20 | function process_option { |
| 21 | case "$1" in |
| 22 | -h|--help) usage;; |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 23 | -V|--virtual-env) always_venv=1; never_venv=0;; |
| 24 | -N|--no-virtual-env) always_venv=0; never_venv=1;; |
| 25 | -s|--no-site-packages) no_site_packages=1;; |
| 26 | -f|--force) force=1;; |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 27 | -d|--debug) set -o xtrace;; |
| 28 | -p|--pep8) let just_pep8=1;; |
| 29 | -s|--smoke) noseargs="$noseargs --attr=type=smoke";; |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 30 | -w|--whitebox) noseargs="$noseargs --attr=type=whitebox";; |
Sean Dague | 14a6015 | 2012-12-13 15:59:40 -0500 | [diff] [blame] | 31 | -S|--stdout) noseargs="$noseargs -s";; |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 32 | *) noseargs="$noseargs $1" |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 33 | esac |
| 34 | } |
| 35 | |
Sean Dague | 422af97 | 2012-11-16 07:30:43 -0500 | [diff] [blame] | 36 | noseargs="" |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 37 | just_pep8=0 |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 38 | venv=.venv |
| 39 | with_venv=tools/with_venv.sh |
| 40 | always_venv=0 |
| 41 | never_venv=0 |
| 42 | no_site_packages=0 |
| 43 | force=0 |
| 44 | wrapper="" |
| 45 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 46 | |
| 47 | export NOSE_WITH_OPENSTACK=1 |
| 48 | export NOSE_OPENSTACK_COLOR=1 |
| 49 | export NOSE_OPENSTACK_RED=15.00 |
| 50 | export NOSE_OPENSTACK_YELLOW=3.00 |
| 51 | export NOSE_OPENSTACK_SHOW_ELAPSED=1 |
| 52 | export NOSE_OPENSTACK_STDOUT=1 |
| 53 | |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 54 | for arg in "$@"; do |
| 55 | process_option $arg |
| 56 | done |
| 57 | |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 58 | if [ $no_site_packages -eq 1 ]; then |
| 59 | installvenvopts="--no-site-packages" |
| 60 | fi |
Sean Dague | 422af97 | 2012-11-16 07:30:43 -0500 | [diff] [blame] | 61 | |
| 62 | # only add tempest default if we don't specify a test |
| 63 | if [[ "x$noseargs" =~ "tempest" ]]; then |
| 64 | noseargs="$noseargs" |
| 65 | else |
| 66 | noseargs="$noseargs tempest" |
| 67 | fi |
| 68 | |
| 69 | |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 70 | function run_tests { |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 71 | ${wrapper} $NOSETESTS |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 72 | } |
| 73 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 74 | function run_pep8 { |
| 75 | echo "Running pep8 ..." |
Matthew Treinish | 8b37289 | 2012-12-07 17:13:16 -0500 | [diff] [blame] | 76 | srcfiles="`find tempest -type f -name "*.py"`" |
| 77 | srcfiles+=" `find tools -type f -name "*.py"`" |
| 78 | srcfiles+=" setup.py" |
| 79 | |
| 80 | ignore='--ignore=N4,E121,E122,E125,E126' |
Sean Dague | 14a6015 | 2012-12-13 15:59:40 -0500 | [diff] [blame] | 81 | |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 82 | ${wrapper} python tools/hacking.py ${ignore} ${srcfiles} |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | NOSETESTS="nosetests $noseargs" |
| 86 | |
| 87 | if [ $just_pep8 -eq 1 ]; then |
| 88 | run_pep8 |
| 89 | exit |
| 90 | fi |
| 91 | |
Matthew Treinish | 8e937d7 | 2012-12-14 11:11:41 -0500 | [diff] [blame] | 92 | if [ $never_venv -eq 0 ] |
| 93 | then |
| 94 | # Remove the virtual environment if --force used |
| 95 | if [ $force -eq 1 ]; then |
| 96 | echo "Cleaning virtualenv..." |
| 97 | rm -rf ${venv} |
| 98 | fi |
| 99 | if [ -e ${venv} ]; then |
| 100 | wrapper="${with_venv}" |
| 101 | else |
| 102 | if [ $always_venv -eq 1 ]; then |
| 103 | # Automatically install the virtualenv |
| 104 | python tools/install_venv.py $installvenvopts |
| 105 | wrapper="${with_venv}" |
| 106 | else |
| 107 | echo -e "No virtual environment found...create one? (Y/n) \c" |
| 108 | read use_ve |
| 109 | if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then |
| 110 | # Install the virtualenv and run the test suite in it |
| 111 | python tools/install_venv.py $installvenvopts |
| 112 | wrapper=${with_venv} |
| 113 | fi |
| 114 | fi |
| 115 | fi |
| 116 | fi |
| 117 | |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 118 | run_tests || exit |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 119 | |
| 120 | if [ -z "$noseargs" ]; then |
| 121 | run_pep8 |
| 122 | fi |