Files
pipenv/run-tests.sh
T
2018-03-11 10:36:16 -04:00

62 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# NOTE: set TEST_SUITE to be markers you want to run.
set -e
# Set the PYPI vendor URL for pytest-pypi.
PYPI_VENDOR_DIR="$(pwd)/tests/pypi/"
export PYPI_VENDOR_DIR
if [[ ! -z "$TEST_SUITE" ]]; then
echo "Using TEST_SUITE=$TEST_SUITE"
fi
# If running in CI environment…
if [[ ! -z "$CI" ]]; then
echo "Running in a CI environment…"
# Use tap output for tests.
TAP_OUTPUT="1"
export TAP_OUTPUT
echo "Installing Pipenv…"
pip install -e "$(pwd)" --upgrade
pipenv install --deploy --system --dev
# Otherwise, we're on a development machine.
else
# First, try MacOS…
if [[ $(python -c "import sys; print(sys.platform)") == "darwin" ]]; then
echo "Clearing Caches…"
rm -fr ~/Library/Caches/pip
rm -fr ~/Libary/Caches/pipenv
# Otherwise, assume Linux…
else
echo "Clearing Caches…"
rm -fr ~/.cache/pip
rm -fr ~/.cache/pipenv
fi
# If the lockfile hasn't changed, skip installs.
echo "Instaling Pipenv…"
pip install -e "$(pwd)" --upgrade-strategy=only-if-needed
echo "Installing dependencies…"
pipenv install --dev
fi
# Use tap output if in a CI environment, otherwise just run the tests.
if [[ "$TAP_OUTPUT" ]]; then
echo "$ pipenv run time pytest -v -n auto tests -m \"$TEST_SUITE\" --tap-stream | tee report-$PYTHON.tap"
pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" --tap-stream | tee report.tap
else
echo "$ pipenv run time pytest -v -n auto tests -m \"$TEST_SUITE\""
pipenv run time pytest -v -n auto tests -m "$TEST_SUITE"
fi