@@ -33,8 +33,8 @@ function process_option {
3333 -p|--pep8) just_pep8=1;;
3434 -P|--no-pep8) no_pep8=1;;
3535 -c|--coverage) coverage=1;;
36- -* ) noseopts =" $noseopts $1 " ;;
37- * ) noseargs =" $noseargs $1 "
36+ -* ) testropts =" $testropts $1 " ;;
37+ * ) testrargs =" $testrargs $1 "
3838 esac
3939}
4040
@@ -45,34 +45,62 @@ never_venv=0
4545force=0
4646no_site_packages=0
4747installvenvopts=
48- noseargs =
49- noseopts =
48+ testrargs =
49+ testropts =
5050wrapper=" "
5151just_pep8=0
5252no_pep8=0
5353coverage=0
5454
55+ LANG=en_US.UTF-8
56+ LANGUAGE=en_US:en
57+ LC_ALL=C
58+
5559for arg in " $@ " ; do
5660 process_option $arg
5761done
5862
59- # If enabled, tell nose to collect coverage data
60- if [ $coverage -eq 1 ]; then
61- noseopts=" $noseopts --with-coverage --cover-package=openstackclient"
62- fi
63-
6463if [ $no_site_packages -eq 1 ]; then
6564 installvenvopts=" --no-site-packages"
6665fi
6766
67+ function init_testr {
68+ if [ ! -d .testrepository ]; then
69+ ${wrapper} testr init
70+ fi
71+ }
72+
6873function run_tests {
74+ # Cleanup *.pyc
75+ ${wrapper} find . -type f -name " *.pyc" -delete
76+
77+ if [ $coverage -eq 1 ]; then
78+ # Do not test test_coverage_ext when gathering coverage.
79+ if [ " x$testrargs " = " x" ]; then
80+ testrargs = " ^(?!.*test_coverage_ext).*$"
81+ fi
82+ export PYTHON=" ${wrapper} coverage run --source novaclient --parallel-mode"
83+ fi
6984 # Just run the test suites in current environment
70- ${wrapper} $NOSETESTS
71- # If we get some short import error right away, print the error log directly
85+ set +e
86+ TESTRTESTS=" $TESTRTESTS $testrargs "
87+ echo " Running \` ${wrapper} $TESTRTESTS \` "
88+ ${wrapper} $TESTRTESTS
7289 RESULT=$?
90+ set -e
91+
92+ copy_subunit_log
93+
7394 return $RESULT
7495}
7596
97+ function copy_subunit_log {
98+ LOGNAME=` cat .testrepository/next-stream`
99+ LOGNAME=$(( $LOGNAME - 1 ))
100+ LOGNAME=" .testrepository/${LOGNAME} "
101+ cp $LOGNAME subunit.log
102+ }
103+
76104function run_pep8 {
77105 echo " Running pep8 ..."
78106 srcfiles=" openstackclient tests"
@@ -96,7 +124,7 @@ function run_pep8 {
96124 ${wrapper} pep8 ${pep8_opts} ${srcfiles}
97125}
98126
99- NOSETESTS= " nosetests $noseopts $noseargs "
127+ TESTRTESTS= " testr run --parallel $testropts "
100128
101129if [ $never_venv -eq 0 ]
102130then
@@ -134,19 +162,21 @@ if [ $just_pep8 -eq 1 ]; then
134162 exit
135163fi
136164
165+ init_testr
137166run_tests
138167
139168# NOTE(sirp): we only want to run pep8 when we're running the full-test suite,
140169# not when we're running tests individually. To handle this, we need to
141170# distinguish between options (noseopts), which begin with a '-', and
142- # arguments (noseargs ).
143- if [ -z " $noseargs " ]; then
171+ # arguments (testrargs ).
172+ if [ -z " $testrargs " ]; then
144173 if [ $no_pep8 -eq 0 ]; then
145174 run_pep8
146175 fi
147176fi
148177
149178if [ $coverage -eq 1 ]; then
150179 echo " Generating coverage report in covhtml/"
151- ${wrapper} coverage html -d covhtml -i
180+ ${wrapper} cverage combine
181+ ${wrapper} coverage html --include=' novaclient/*' --omit=' novaclient/openstack/common/*' -d covhtml -i
152182fi
0 commit comments