summaryrefslogtreecommitdiff
path: root/tools/teamcity-runtests.sh
blob: bcb28f78aa60a44a137832e000c98e62b296e036 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#
# This script assumes that the project 'ptyprocess' is
# available in the parent of the project's folder.
set -e
set -o pipefail

if [ -z $1 ]; then
	echo "$0 (2.6|2.7|3.3|3.4)"
	exit 1
fi

export PYTHONIOENCODING=UTF8
export LANG=en_US.UTF-8

pyversion=$1
shift
here=$(cd `dirname $0`; pwd)
osrel=$(uname -s)
venv=teamcity-pexpect
venv_wrapper=$(which virtualenvwrapper.sh)

if [ -z $venv_wrapper ]; then
	echo "virtualenvwrapper.sh not found in PATH." >&2
	exit 1
fi

. ${venv_wrapper}
rmvirtualenv ${venv} || true
mkvirtualenv -p `which python${pyversion}` ${venv} || true
workon ${venv}

# install ptyprocess
cd $here/../../ptyprocess
pip uninstall --yes ptyprocess || true
python setup.py install

# install all test requirements
pip install --upgrade pytest-cov coverage coveralls pytest-capturelog

# run tests
cd $here/..
ret=0
py.test \
	--cov pexpect \
	--cov-config .coveragerc \
	--junit-xml=results.${osrel}.py${pyversion}.xml \
	--verbose \
	--verbose \
	"$@" || ret=$?

if [ $ret -ne 0 ]; then
	# we always exit 0, preferring instead the jUnit XML
	# results to be the dominate cause of a failed build.
	echo "py.test returned exit code ${ret}." >&2
	echo "the build should detect and report these failing tests." >&2
fi

# combine all coverage to single file, report for this build,
# then move into ./build-output/ as a unique artifact to allow
# the final "Full build" step to combine and report to coveralls.io
`dirname $0`/teamcity-coverage-report.sh
mkdir -p build-output
mv .coverage build-output/.coverage.${osrel}.py{$pyversion}.$RANDOM.$$