Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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