Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 92 lines (83 sloc) 2.572 kb
fb382c8 Adapts the run_tests.sh script to allow interactive or automated creatio...
jaypipes@gmail.com authored
1 #!/bin/bash
2
3 function usage {
4 echo "Usage: $0 [OPTION]..."
5 echo "Run Nova's test suite(s)"
6 echo ""
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"
7c8c2f5 Adds --force option to run_tests.sh to clear virtualenv. Useful when dep...
jaypipes@gmail.com authored
9 echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
fb382c8 Adapts the run_tests.sh script to allow interactive or automated creatio...
jaypipes@gmail.com authored
10 echo " -h, --help Print this usage message"
11 echo ""
12 echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
13 echo " If no virtualenv is found, the script will ask if you would like to create one. If you "
14 echo " prefer to run tests NOT in a virtual environment, simply pass the -N option."
15 exit
16 }
17
18 function process_option {
7c8c2f5 Adds --force option to run_tests.sh to clear virtualenv. Useful when dep...
jaypipes@gmail.com authored
19 case "$1" in
3d15adb Merge case statement options
jaypipes@gmail.com authored
20 -h|--help) usage;;
21 -V|--virtual-env) let always_venv=1; let never_venv=0;;
22 -N|--no-virtual-env) let always_venv=0; let never_venv=1;;
7c8c2f5 Adds --force option to run_tests.sh to clear virtualenv. Useful when dep...
jaypipes@gmail.com authored
23 -f|--force) let force=1;;
821fc6b @ewanmellor Bug #694890: run_tests.sh sometimes doesn't pass arguments to nosetest
ewanmellor authored
24 *) noseargs="$noseargs $1"
fb382c8 Adapts the run_tests.sh script to allow interactive or automated creatio...
jaypipes@gmail.com authored
25 esac
26 }
849a406 @emonty Changed Makefile to shell script. The Makefile approach completely broke
emonty authored
27
28 venv=.nova-venv
29 with_venv=tools/with_venv.sh
fb382c8 Adapts the run_tests.sh script to allow interactive or automated creatio...
jaypipes@gmail.com authored
30 always_venv=0
31 never_venv=0
7c8c2f5 Adds --force option to run_tests.sh to clear virtualenv. Useful when dep...
jaypipes@gmail.com authored
32 force=0
821fc6b @ewanmellor Bug #694890: run_tests.sh sometimes doesn't pass arguments to nosetest
ewanmellor authored
33 noseargs=
50ec058 @sorenh Refactor run_tests.sh to allow us to run an extra command after the test...
sorenh authored
34 wrapper=""
7e46969 Output of run_tests.sh to be closer to trial
termie authored
35
7c8c2f5 Adds --force option to run_tests.sh to clear virtualenv. Useful when dep...
jaypipes@gmail.com authored
36 for arg in "$@"; do
37 process_option $arg
38 done
fb382c8 Adapts the run_tests.sh script to allow interactive or automated creatio...
jaypipes@gmail.com authored
39
50ec058 @sorenh Refactor run_tests.sh to allow us to run an extra command after the test...
sorenh authored
40 function run_tests {
fb382c8 Adapts the run_tests.sh script to allow interactive or automated creatio...
jaypipes@gmail.com authored
41 # Just run the test suites in current environment
5e2f82b @vishvananda revert logfile redirection and make colors work by temporarily switching...
vishvananda authored
42 ${wrapper} $NOSETESTS 2> run_tests.log
2bbbfc5 @termie dump error output directly on short import errors
termie authored
43 # If we get some short import error right away, print the error log directly
44 RESULT=$?
45 if [ "$RESULT" -ne "0" ];
46 then
5e2f82b @vishvananda revert logfile redirection and make colors work by temporarily switching...
vishvananda authored
47 ERRSIZE=`wc -l run_tests.log | awk '{print \$1}'`
2bbbfc5 @termie dump error output directly on short import errors
termie authored
48 if [ "$ERRSIZE" -lt "40" ];
49 then
3aa0183 @vishvananda fix missed err.log
vishvananda authored
50 cat run_tests.log
2bbbfc5 @termie dump error output directly on short import errors
termie authored
51 fi
52 fi
53 return $RESULT
50ec058 @sorenh Refactor run_tests.sh to allow us to run an extra command after the test...
sorenh authored
54 }
849a406 @emonty Changed Makefile to shell script. The Makefile approach completely broke
emonty authored
55
50ec058 @sorenh Refactor run_tests.sh to allow us to run an extra command after the test...
sorenh authored
56 NOSETESTS="python run_tests.py $noseargs"
7c8c2f5 Adds --force option to run_tests.sh to clear virtualenv. Useful when dep...
jaypipes@gmail.com authored
57
50ec058 @sorenh Refactor run_tests.sh to allow us to run an extra command after the test...
sorenh authored
58 if [ $never_venv -eq 0 ]
59 then
60 # Remove the virtual environment if --force used
61 if [ $force -eq 1 ]; then
62 echo "Cleaning virtualenv..."
63 rm -rf ${venv}
64 fi
65 if [ -e ${venv} ]; then
66 wrapper="${with_venv}"
fb382c8 Adapts the run_tests.sh script to allow interactive or automated creatio...
jaypipes@gmail.com authored
67 else
50ec058 @sorenh Refactor run_tests.sh to allow us to run an extra command after the test...
sorenh authored
68 if [ $always_venv -eq 1 ]; then
69 # Automatically install the virtualenv
fb382c8 Adapts the run_tests.sh script to allow interactive or automated creatio...
jaypipes@gmail.com authored
70 python tools/install_venv.py
50ec058 @sorenh Refactor run_tests.sh to allow us to run an extra command after the test...
sorenh authored
71 wrapper="${with_venv}"
fb382c8 Adapts the run_tests.sh script to allow interactive or automated creatio...
jaypipes@gmail.com authored
72 else
50ec058 @sorenh Refactor run_tests.sh to allow us to run an extra command after the test...
sorenh authored
73 echo -e "No virtual environment found...create one? (Y/n) \c"
74 read use_ve
75 if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
76 # Install the virtualenv and run the test suite in it
77 python tools/install_venv.py
86b96d3 @termie Only run pep8 after tests if running all the tests
termie authored
78 wrapper=${with_venv}
50ec058 @sorenh Refactor run_tests.sh to allow us to run an extra command after the test...
sorenh authored
79 fi
fb382c8 Adapts the run_tests.sh script to allow interactive or automated creatio...
jaypipes@gmail.com authored
80 fi
81 fi
849a406 @emonty Changed Makefile to shell script. The Makefile approach completely broke
emonty authored
82 fi
50ec058 @sorenh Refactor run_tests.sh to allow us to run an extra command after the test...
sorenh authored
83
86b96d3 @termie Only run pep8 after tests if running all the tests
termie authored
84 if [ -z "$noseargs" ];
85 then
9a7213b @justinsb Initial support for per-instance metadata, though the OpenStack API. Key...
justinsb authored
86 srcfiles=`find bin -type f ! -name "nova.conf*"`
87 srcfiles+=" nova setup.py"
88 run_tests && pep8 --repeat --show-pep8 --show-source --exclude=vcsversion.py ${srcfiles} || exit 1
86b96d3 @termie Only run pep8 after tests if running all the tests
termie authored
89 else
90 run_tests
91 fi
Something went wrong with that request. Please try again.