mirror of
https://github.com/kennethreitz/heroku-buildpack-python.git
synced 2026-06-05 23:10:16 +00:00
c029e44dc8
* Test that the cache is invalidated when the stack changes * Improve UX when clearing cache due to the stack changing Now outputs a message informing that the cache was cleared, and clears the cache first to avoid a redundant message about removing an old Python version.
147 lines
2.7 KiB
Bash
Executable File
147 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
testPipenv() {
|
|
compile "pipenv"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testPipenvVersion() {
|
|
compile "pipenv-version"
|
|
assertCaptured "3.6.2"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testNoRequirements() {
|
|
compile "no-requirements"
|
|
assertCapturedError
|
|
}
|
|
|
|
testGEOS() {
|
|
BUILD_WITH_GEO_LIBRARIES=1 compile "geos"
|
|
assertCaptured "geos"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testNLTK() {
|
|
compile "nltk"
|
|
assertCaptured "wordnet"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testSetupPy() {
|
|
compile "setup-py"
|
|
assertCaptured "maya"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
|
|
testStandardRequirements() {
|
|
compile "requirements-standard"
|
|
assertCaptured "requests"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testPsycopg2() {
|
|
compile "psycopg2"
|
|
assertCaptured "psycopg2"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testPylibmc() {
|
|
compile "pylibmc"
|
|
assertCaptured "pylibmc"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testPython2() {
|
|
compile "python2"
|
|
assertCaptured "python-2.7.13"
|
|
assertCapturedSuccess
|
|
}
|
|
|
|
testPython3() {
|
|
compile "python3"
|
|
assertCaptured "python-3.6.2"
|
|
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
|