mirror of
https://github.com/kennethreitz/heroku-buildpack-python.git
synced 2026-06-05 23:10:16 +00:00
Tests: Run detect/compile/release in a clean environment (#1016)
To prevent external environment variables from leaking into the tests, which otherwise causes problems trying to write tests for #1011. Several tests which were relying on this leak had to be fixed, so that the env vars they were using are set using `ENV_DIR`, as happens in production. Fixes #1014. Fixes #1015.
This commit is contained in:
+8
-3
@@ -234,13 +234,18 @@ default_process_types_cleanup() {
|
||||
fi
|
||||
}
|
||||
|
||||
run_in_clean_env() {
|
||||
# Prevent stray environment variables from outside the test runner being exposed to tests.
|
||||
env -i HOME="${HOME}" LANG="${LANG}" PATH="${PATH}" STACK="${STACK}" "$@"
|
||||
}
|
||||
|
||||
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
|
||||
capture run_in_clean_env ${bp_dir}/bin/compile ${compile_dir} ${2:-$(mktmpdir)} $3
|
||||
}
|
||||
|
||||
compileDir() {
|
||||
@@ -252,13 +257,13 @@ compileDir() {
|
||||
local env_dir=$3
|
||||
|
||||
cp -a $(pwd)/* ${bp_dir}
|
||||
capture ${bp_dir}/bin/compile ${compile_dir} ${cache_dir} ${env_dir}
|
||||
capture run_in_clean_env ${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
|
||||
capture run_in_clean_env ${bp_dir}/bin/release ${bp_dir}/test/fixtures/$1
|
||||
}
|
||||
|
||||
assertFile() {
|
||||
|
||||
Reference in New Issue
Block a user