#!/bin/bash
#
# This script assumes that the project 'ptyprocess' is
# available in the parent of the project's folder.
set -e
set -o pipefail

here=$(cd `dirname $0`; pwd)
osrel=$(uname -s)

# ensure pip, virtualenv, and tox are up-to-date
pip install --upgrade pip virtualenv tox

# run tests
cd $here/..

_cmd=tox
if [ X"$osrel" == X"Linux" ]; then
	# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=754248
	# cannot create a virtualenv for python2.6 due to use of
	# "{}".format in virtualenv, throws exception
	# ValueError: zero length field name in format.
	_cmd='tox -epy27,py33,py34,pypy'
fi

ret=0
echo ${_cmd}
${_cmd} || 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, publish as build
# artifact in {pexpect_projdir}/build-output
mkdir -p build-output
coverage combine
mv .coverage build-output/.coverage.${osrel}.$RANDOM.$$

#!/bin/bash
#
# This script assumes that the project 'ptyprocess' is
# available in the parent of the project's folder.
set -e
set -o pipefail

here=$(cd `dirname $0`; pwd)
osrel=$(uname -s)

# run tests
cd $here/..

_cmd=tox
if [ X"$osrel" == X"Linux" ]; then
	# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=754248
	# cannot create a virtualenv for python2.6 due to use of
	# "{}".format in virtualenv, throws exception
	# ValueError: zero length field name in format.
	_cmd='tox -epy27,py33,py34,pypy'
fi

ret=0
echo ${_cmd}
${_cmd} || 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, publish as build
# artifact in {pexpect_projdir}/build-output
mkdir -p build-output
coverage combine
mv .coverage build-output/.coverage.${osrel}.$RANDOM.$$

Revert "try fixing pypy tox/virtualenv fail on linux with pip --upgrade"
Revert "try fixing pypy tox/virtualenv fail on linux with pip --upgrade"

This reverts commit 77466f05d730ace9741632a9616f219fa7d3aa03.

(We can't: OSError: [Errno 13] Permission denied: '/usr/bin/pip')
