-
Casey Faist authoredCasey Faist authored
run 5.08 KiB
#!/usr/bin/env bash
testAirflow() {
export SLUGIFY_USES_TEXT_UNIDECODE="yes"
compile "airflow"
assertCaptured "apache-airflow==1.10"
assertCapturedSuccess
}
testPipenv() {
compile "pipenv"
assertCapturedSuccess
}
testPipenvLock() {
compile "pipenv-lock"
assertCapturedSuccess
}
testPipenvVersion() {
compile "pipenv-version"
assertCaptured "3.6.6"
assertCapturedSuccess
}
testPipenvFullVersion() {
compile "pipenv-full-version"
assertCaptured "3.6.3"
assertCapturedSuccess
}
testNoRequirements() {
compile "no-requirements"
assertCapturedError
}
testCollectstatic() {
compile "collectstatic"
assertCaptured "collectstatic"
}
testGEOS() {
BUILD_WITH_GEO_LIBRARIES=1 compile "geos"
assertCaptured "geos"
assertCapturedSuccess
}
testNLTK() {
# NOTE: This is a RuntimeWarning emitted by Python 3's runpy.py script
# which is what is used when you call `python -m <module>`. This is due to
# how nltk imports things. It's not actually an error, but it would probably
# be bad to silence in Production.
export PYTHONWARNINGS="ignore::RuntimeWarning"
compile "nltk"
assertCaptured "Downloading NLTK packages: city_database stopwords"
assertCapturedSuccess
}
testSetupPy() {
compile "setup-py"
assertCaptured "maya"
assertCapturedSuccess
}
testStandardRequirements() {
compile "requirements-standard"
assertCaptured "requests"
assertCapturedSuccess
}
testPsycopg2() {
compile "psycopg2"
assertCaptured "psycopg2"
assertCapturedSuccess
}
testCffi() {
compile "cffi"
assertCaptured "cffi"
assertCapturedSuccess
}
testPylibmc() {
compile "pylibmc"
assertCaptured "pylibmc"
assertCapturedSuccess
}
testPython2_warn() {
compile "python2_warn"
if [[ $STACK = "heroku-18" ]]; then
assertCapturedError
else
assertCaptured "python-2.7.14"
assertCaptured "security update!"
assertCapturedSuccess
fi
}
testPython2() {
compile "python2"
assertCaptured "python-2.7.15"
assertCapturedSuccess
}
# This fail
testPython3_4_warn() {
compile "python3_4_warn"
if [[ $STACK = "cedar-14" ]]; then
assertCaptured "python-3.4.0"
assertCapturedSuccess
else
assertCapturedError
fi
}
# This fail
testPython3_4() {
compile "python3_4"
assertCaptured "python-3.4.9"
assertCapturedError
}
# This fail
testPython3_5_warn() {
compile "python3_5_warn"
if [[ $STACK = "cedar-14" ]]; then
assertCaptured "python-3.5.3"
assertCaptured "security update!"
assertCapturedError
else
assertCapturedError
fi
}
# This will fail
testPython3_5() {
compile "python3_5"
assertCaptured "python-3.5.6"
assertCapturedError
}
# This will warn
testPython3_6_warn() {
compile "python3_6_warn"
assertCaptured "python-3.6.5"
assertCaptured "security update!"
assertCapturedSuccess
}
testPython3_6() {
compile "python3_6"
assertCaptured "python-3.6.6"
assertCapturedSuccess
}
# This will fail
testPython3_6_7() {
compile "python3_6_7"
assertCaptured "python-3.6.7"
assertCapturedError
}
testPython3_7() {
compile "python3_7"
if [[ $STACK = "cedar-14" ]]; then
assertCapturedError
else
assertCaptured "python-3.7.0"
assertCapturedSuccess
fi
}
# This will fail
testPython3_7_1() {
compile "python3_7_1"
assertCaptured "python-3.7.1"
assertCapturedError
}
testGitEgg() {
compile "git-egg"
assertCaptured "requests"
assertCapturedSuccess
}
testSmartRequirements() {
local cache_dir="$(mktmpdir)"
compile "requirements-standard" "$cache_dir"
assertFile "requests" ".heroku/python/requirements-declared.txt"
assertCapturedSuccess
compile "psycopg2" "$cache_dir"
assertCaptured "Uninstalling requests"
assertFile "psycopg2" ".heroku/python/requirements-declared.txt"
assertCapturedSuccess
}
testStackChange() {
local cache_dir="$(mktmpdir)"
mkdir -p "${cache_dir}/.heroku"
echo "different-stack" > "${cache_dir}/.heroku/python-stack"
compile "requirements-standard" "$cache_dir"
assertCaptured "clearing cache"
assertFile "$STACK" ".heroku/python-stack"
assertCapturedSuccess
}
pushd $(dirname 0) >/dev/null
popd >/dev/null
source $(pwd)/test/utils
mktmpdir() {
dir=$(mktemp -t testXXXXX)
rm -rf $dir
mkdir $dir
echo $dir
}
detect() {
capture $(pwd)/bin/detect $(pwd)/test/fixtures/$1
}
compile_dir=""
default_process_types_cleanup() {
file="/tmp/default_process_types"
if [ -f "$file" ]; then
rm "$file"
fi
}
compile() {
default_process_types_cleanup
bp_dir=$(mktmpdir)
compile_dir=$(mktmpdir)
cp -a $(pwd)/* ${bp_dir}
cp -a ${bp_dir}/test/fixtures/$1/. ${compile_dir}
capture ${bp_dir}/bin/compile ${compile_dir} ${2:-$(mktmpdir)} $3
}
compileDir() {
default_process_types_cleanup
local bp_dir=$(mktmpdir)
local compile_dir=${1:-$(mktmpdir)}
local cache_dir=${2:-$(mktmpdir)}
local env_dir=$3
cp -a $(pwd)/* ${bp_dir}
capture ${bp_dir}/bin/compile ${compile_dir} ${cache_dir} ${env_dir}
}
release() {
bp_dir=$(mktmpdir)
cp -a $(pwd)/* ${bp_dir}
capture ${bp_dir}/bin/release ${bp_dir}/test/fixtures/$1
}
assertFile() {
assertEquals "$1" "$(cat ${compile_dir}/$2)"
}
source $(pwd)/test/shunit2