Merge lp:~canonical-isd-hackers/canonical-identity-provider/test-script-coverage-fix into lp:canonical-identity-provider/release

Proposed by Ricardo Kirkner
Status: Merged
Merged at revision: 6
Proposed branch: lp:~canonical-isd-hackers/canonical-identity-provider/test-script-coverage-fix
Merge into: lp:canonical-identity-provider/release
Diff against target: 98 lines (+20/-32)
1 file modified
scripts/test (+20/-32)
To merge this branch: bzr merge lp:~canonical-isd-hackers/canonical-identity-provider/test-script-coverage-fix
Reviewer Review Type Date Requested Status
Canonical ISD hackers Pending
Review via email: mp+24816@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/test'
2--- scripts/test 2010-04-21 15:29:24 +0000
3+++ scripts/test 2010-05-06 12:26:26 +0000
4@@ -6,15 +6,9 @@
5 # HOWTO
6 # ------
7 #
8-# This script can be run in two ways:
9-#
10-# 1. from within the configuration branch
11-#
12-# config-unified$ /path/to/django-trunk/scripts/test
13-#
14-# 2. from within the code branch
15-#
16-# django-trunk$ CONFIG_DIR=/path/to/config-unified ./scripts/test
17+# This script is to be run like:
18+#
19+# trunk$ ./scripts/test
20 #
21 # For the tests to work, both schemaconfig and django-settings have to be in
22 # the PYTHONPATH
23@@ -46,15 +40,11 @@
24 test_specification="identityprovider"
25 fi
26
27-script_dir=$(readlink -f $(dirname $0))
28-project_dir=$(readlink -f $(dirname $script_dir))
29+CURRENT_DIR=$(readlink -f $(pwd))
30+SCRIPT_DIR=$(readlink -f $(dirname $0))
31+PROJECT_DIR=$(readlink -f $(dirname $SCRIPT_DIR))
32
33-if [ "$CONFIG_DIR" != "" ]; then
34- config_dir=$CONFIG_DIR
35-else
36- config_dir=$(readlink -f $(pwd))
37-fi
38-PYTHONPATH="$PYTHONPATH:$project_dir:$config_dir"
39+PYTHONPATH="$PYTHONPATH:$PROJECT_DIR"
40
41 if [ "$PYTHONPATH" != "" ]; then
42 ENV="$ENV PYTHONPATH=$PYTHONPATH"
43@@ -66,8 +56,17 @@
44 export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
45 fi
46
47+# make sure we are in the project folder
48+if [ "$PROJECT_DIR" != "$CURRENT_DIR" ]; then
49+ echo "This script has to be run from the project root folder."
50+ echo "Please follow these steps:"
51+ echo "cd $PROJECT_DIR"
52+ echo "./scripts/test"
53+ exit 2
54+fi
55
56-#rm .coverage*
57+# get rid of old coverage files to get a clean report
58+find . -name '.coverage*' -exec rm -f {} \;
59
60 if [ "$doctest" = true ]
61 then
62@@ -75,9 +74,6 @@
63 # without any prompting
64 sudo date
65
66- # change to the project folder
67- cd $project_dir
68-
69 sudo $ENV `which python` wsgi_test_server.py &
70 sso_pid=$!
71
72@@ -94,24 +90,16 @@
73 (cd doctests && python runner.py -m stories/api-authentications.txt)
74 (cd doctests && python runner.py -m stories/api-workflows.txt)
75 sudo kill $sso_pid
76-
77- # change back to where we came from
78- cd -
79-
80 fi
81
82 if [ "$unittest" = true ]
83 then
84- # change to the configuration folder
85- cd $config_dir
86 coverage run -p manage.py test $test_specification
87- # change back to where we came from
88- cd -
89 fi
90
91 # Creating nice (HTML) coverage report
92-rm -rf $project_dir/coverage
93+rm -rf $PROJECT_DIR/coverage
94+OMIT="$VIRTUAL_ENV/lib,$VIRTUAL_ENV/src,.config,wsgi_test_server,identityprovider/tests,/usr/lib,settings,manage,urls"
95 coverage combine
96-coverage html -d $project_dir/coverage \
97- --omit=$VIRTUAL_ENV/lib,wsgi_test_server,identityprovider/tests,/usr/lib,settings,manage,urls
98+coverage html -d $PROJECT_DIR/coverage --omit=$OMIT
99