source: software-center/trunk/fuentes/run-tests.sh @ 408

Last change on this file since 408 was 401, checked in by mabarracus, 5 years ago

Added 16.01+16.04.20160119 sources

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1#!/bin/bash
2
3set -e
4
5TESTS_DIR="tests"
6
7dpkg-checkbuilddeps -d 'xvfb, python-mock, python-unittest2,
8                       python3-aptdaemon.test, python-lxml, python-qt4'
9
10if [ ! -e /var/lib/apt-xapian-index/index ]; then
11    echo "please run sudo update-apt-xapian-index"
12    exit 1
13fi
14
15# check if basic http access works
16HTTP_URL=http://software-center.ubuntu.com
17if ! curl -s $HTTP_URL >/dev/null; then
18    echo "NEED curl and http access to $HTTP_URL"
19    exit 1
20fi
21
22./setup.py build
23# run with xvfb
24
25XVFB_CMDLINE=""
26
27# mvo 2012-11-05: disabled as this causes hangs in raring
28#XVFB=$(which xvfb-run)
29XVFB=""
30
31if [ $XVFB ]; then
32    XVFB_CMDLINE="$XVFB -a"
33fi
34
35PYTHON="$XVFB_CMDLINE python -m unittest"
36
37# and record failures here
38OUTPUT=$TESTS_DIR"/output"
39
40FAILED=""
41run_tests_for_dir() {
42    for i in $(find $1 -maxdepth 1 -name 'test_*.py'); do
43        TEST_NAME=$(basename $i | cut -d '.' -f 1)
44        TEST_PREFIX=$(echo `dirname $i` | sed -e s'/\//./g')
45        printf '%-50s' "Testing $TEST_NAME..."
46        if ! $PYTHON -v -c -b $TEST_PREFIX.$TEST_NAME > $OUTPUT/$TEST_NAME.out 2>&1; then
47            FAILED="$FAILED $TEST_NAME"
48            echo "[ FAIL ]"
49            # add .FAIL symlink to make finding the broken ones trivial
50            (cd $OUTPUT ; ln -s $TEST_NAME.out $TEST_NAME.out.FAIL)
51        else
52            echo "[  OK  ]"
53            rm -f ${OUTPUT}/$file.out;
54        fi
55    done
56}
57
58if [ "$1" = "--sso-gtk" ]; then
59    # Run the SSO GTK+ suite
60    $PYTHON discover -s softwarecenter/sso/
61elif [ $# -gt 0 ]; then
62    # run the requested tests if arguments were given,
63    # otherwise run the whole suite
64    # example of custom params (discover all the tests under the tests/gtk3 dir):
65
66    # ./run-tests.sh discover -v -s tests/gtk3/
67
68    # See http://docs.python.org/library/unittest.html#test-discovery
69    # for more info.
70    RUN_TESTS="$PYTHON $@"
71    echo "Running the command: $RUN_TESTS"
72    $RUN_TESTS
73else
74    # 2012-05-30, nessita: Ideally, we should be able to run the whole suite
75    # using discovery, but there is too much interference between tests in
76    # order to do so, so we need a new python process per test file.
77    ##RUN_TESTS="$PYTHON discover -v -c -b"
78    rm -rf $OUTPUT
79    mkdir $OUTPUT
80    run_tests_for_dir "$TESTS_DIR/gtk3"
81    run_tests_for_dir $TESTS_DIR
82
83    # gather the coverage data
84    ##./gen-coverage-report.sh
85
86    if [ -n "$FAILED" ]; then
87        echo "FAILED: $FAILED"
88        echo "Check ${OUTPUT}/ directory for the details"
89        exit 1
90    else
91        echo "All OK!"
92    fi
93fi
94./setup.py clean
Note: See TracBrowser for help on using the repository browser.