~nataliabidart/software-center/winged-migration

« back to all changes in this revision

Viewing changes to run-tests.sh

  • Committer: Natalia B. Bidart
  • Date: 2012-05-30 18:39:55 UTC
  • mto: This revision was merged to the branch mainline in revision 3030.
  • Revision ID: natalia.bidart@canonical.com-20120530183955-zbnjczayktmmg5tv
- Initial test cleanup:
  - Renamed test/ dir to tests/.
  - Isolated test code into tests/ directory, including moving all the
    get_test_window_foo from the gtk3 production modules to
    tests/gtk3/windows.py module.
  - Removed all the calls to Gtk.main() in gtk3 tests since that blocks the
    execution of the suite.
  - Pep8 and pyflakes fixes in the files already modified in this branch.
  - Minor bug fix in the softwarecenter/log.py module when trying to create a
    log dir with proper perms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
set -e
4
4
 
 
5
TESTS_DIR="./tests"
 
6
 
5
7
if [ ! -x /usr/bin/python-coverage ]; then
6
8
    echo "please install python-coverage"
7
9
    exit 1
39
41
 
40
42
 
41
43
# clear coverage data
42
 
# coverage erase will not erase the files from --parallel-mode 
43
 
rm -f .coverage*
 
44
# coverage erase will not erase the files from --parallel-mode
 
45
rm -f $TESTS_DIR/.coverage*
44
46
 
45
47
# run with xvfb and coverage
46
 
PYTHON="python-coverage run --parallel-mode"
47
 
#PYTHON="xvfb-run $PYTHON"
 
48
 
 
49
XVFB_CMDLINE=""
 
50
XVFB=$(which xvfb-run)
 
51
if [ $XVFB ]; then
 
52
    XVFB_CMDLINE="$XVFB -a"
 
53
fi
 
54
 
 
55
COVERAGE_CMDLINE=""
 
56
COVERAGE=$(which python-coverage)
 
57
if [ $COVERAGE ]; then
 
58
    # If you are measuring coverage in a multi-process program, or across a
 
59
    # number of machines, you’ll want the --parallel-mode switch to keep the
 
60
    # data separate during measurement. See Combining data files below.
 
61
#    COVERAGE_CMDLINE="$COVERAGE run --parallel-mode"
 
62
    echo "No coverage for now."
 
63
fi
 
64
 
 
65
PYTHON="$XVFB_CMDLINE $COVERAGE_CMDLINE python -m unittest"
48
66
 
49
67
# and record failures here
50
 
OUTPUT="./output"
 
68
OUTPUT=$TESTS_DIR"/output"
51
69
rm -rf $OUTPUT
52
70
 
53
 
FAILED=""
54
 
FILES=$(find . -name 'test_*.py')
55
 
for file in $FILES; do 
56
 
    if [ -f $file ]; then
57
 
        echo -n "Testing $file"
58
 
        mkdir -p ${OUTPUT}/$(dirname $file)
59
 
        if ! $PYTHON $file  >output/$file.out 2>&1 ; then
60
 
            FAILED="$FAILED $file"
61
 
            echo " FAIL"
62
 
        else 
63
 
            echo " success"
64
 
            rm -f ${OUTPUT}/$file.out; 
65
 
        fi 
66
 
    fi 
67
 
done; 
 
71
# run the requested tests if arguments were given,
 
72
# otherwise run the whole suite
 
73
# example of custom params (discover all the tests under the tests/gtk3 dir):
 
74
 
 
75
# ./run-tests.sh discover -v -s tests/gtk3/
 
76
 
 
77
# See http://docs.python.org/library/unittest.html#test-discovery
 
78
# for more info.
 
79
if [ $# ]; then
 
80
    RUN_TESTS="$PYTHON $@"
 
81
else
 
82
    RUN_TESTS="$PYTHON discover -v -c -b"
 
83
fi
 
84
 
 
85
echo "Running the command: $RUN_TESTS"
 
86
$RUN_TESTS
68
87
 
69
88
# gather the coverage data
70
 
./gen-coverage-report.sh
71
 
 
72
 
if [ -n "$FAILED" ]; then 
73
 
    echo "FAILED: $FAILED"; 
74
 
    echo "Check ${OUTPUT}/ directory for the details"; 
75
 
    exit 1; 
76
 
fi
77
 
 
 
89
#./gen-coverage-report.sh