#!/bin/bash -ex

# This is for my own convenience, edit it for your own environment.

PYTHON=python2
"$PYTHON" -V
"$PYTHON" setup.py build
export PYTHONPATH=build/lib.linux-x86_64-2.7
exec "$PYTHON" test_subprocess32.py

PYTHON=python3
rm -r vvv dist
mkdir vvv
# Test this in a virtualenv installed from the sdist tarball becaue of:
#  https://github.com/google/python-subprocess32/issues/44
virtualenv -p "$PYTHON" vvv
PYTHON=vvv/bin/python3
PIP=vvv/bin/pip
"$PYTHON" -V
"$PYTHON" setup.py sdist
"$PIP" install dist/*.tar.gz
# Merely test that it imports.  Under Python 3, setup.py should've installed a
# redirection hack making subprocess32 == subprocess.  We cd as we must not run
# this from the directory subprocess32.py sources live in.
(cd $(dirname "$PYTHON") && \
 ./python3 -c "import subprocess as s, subprocess32 as s32; assert s is s32, (s, s32)")

