converting apex ip_utils unit tests to nose
[apex.git] / ci / test.sh
1 #!/bin/sh
2 ##############################################################################
3 # Copyright (c) 2016 Dan Radez (Red Hat)
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 set -e
12
13 # Make sure python is installed
14 if ! rpm -q python34-devel > /dev/null; then
15     sudo yum install -y epel-release
16     if ! sudo yum install -y python34-devel; then
17         echo "Failed to install python34-devel package..."
18         exit 1
19     fi
20 fi
21
22 # Make sure coverage is installed
23 if ! python3 -c "import coverage" &> /dev/null; then sudo easy_install-3.4 coverage; fi
24
25 make python-tests
26 pushd ../tests/ > /dev/null
27 percent=$(coverage3 report --include '*lib/python/*' -m | grep TOTAL | tr -s ' ' | awk '{ print $4 }' | cut -d % -f 1)
28 if [[ percent -lt 80 ]]; then
29     echo "Python Coverage: $percent"
30     echo "Does not meet 80% requirement"
31     exit 1
32 fi
33 popd > /dev/nul