Skip to content

Commit 703384d

Browse files
Gergrobdimsdale
authored andcommitted
Don't install python for unit tests
- Unit tests are run in non-standard environments - Avoid polluting unit test environment with excess pythons - Add override environment variable to prevent python installation
1 parent ecd717c commit 703384d

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

bin/detect

+6-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ if [ "$CF_STACK" != "cflinuxfs3" ]; then
3232
fi
3333

3434
# To avoid having to support both python 2 & 3 and to avoid using the ancient
35-
# python included in cflinuxfs3, always install python
36-
PYTHON_DIR="/tmp/php-buildpack/python"
37-
mkdir -p "${PYTHON_DIR}"
38-
source "$BP/bin/install-python" "$PYTHON_DIR" "$BP" &> /dev/null
35+
# python included in cflinuxfs3, always install python, unless running unit tests
36+
if [ -z "${USE_SYSTEM_PYTHON}" ]; then
37+
PYTHON_DIR="/tmp/php-buildpack/python"
38+
mkdir -p "${PYTHON_DIR}"
39+
source "$BP/bin/install-python" "$PYTHON_DIR" "$BP" &> /dev/null
40+
fi
3941

4042
export PYTHONPATH=$BP/lib
4143
VERSION="$(cat "$BP"/VERSION)"

bin/finalize

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ PROFILE_DIR=${5:-}
3232
# Generally stacks do not have ruby or python installed, with the exception of cflinuxfs3, so we install them here
3333
#
3434
# We skip re-installing ruby on the cflinuxfs3 stack to avoid compatibility issues
35-
if [ "$CF_STACK" != "cflinuxfs3" ] && [ -z "${USE_SYSTEM_RUBY_PYTHON}" ]; then
35+
if [ "$CF_STACK" != "cflinuxfs3" ]; then
3636
source "$BP/bin/install-ruby" "$DEPS_DIR/$DEPS_IDX" "$BP"
3737
fi
3838

3939
# To avoid having to support both python 2 & 3 and to avoid using the ancient
4040
# python included in cflinuxfs3, always install python
41-
source "$BP/bin/install-python" "$DEPS_DIR/$DEPS_IDX" "$BP"
41+
if [ -z "${USE_SYSTEM_PYTHON}" ]; then
42+
source "$BP/bin/install-python" "$DEPS_DIR/$DEPS_IDX" "$BP"
43+
fi
4244

4345
BUILDPACK_PATH=$BP
4446
export BUILDPACK_PATH

bin/release

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ if [ "$CF_STACK" != "cflinuxfs3" ]; then
3333
fi
3434

3535
# To avoid having to support both python 2 & 3 and to avoid using the ancient
36-
# python included in cflinuxfs3, always install python
37-
PYTHON_DIR="/tmp/php-buildpack/python"
38-
mkdir -p "${PYTHON_DIR}"
39-
source "$BP/bin/install-python" "$PYTHON_DIR" "$BP" &> /dev/null
36+
# python included in cflinuxfs3, always install python, unless running unit tests
37+
if [ -z "${USE_SYSTEM_PYTHON}" ]; then
38+
PYTHON_DIR="/tmp/php-buildpack/python"
39+
mkdir -p "${PYTHON_DIR}"
40+
source "$BP/bin/install-python" "$PYTHON_DIR" "$BP" &> /dev/null
41+
fi
4042

4143
export PYTHONPATH=$BP/lib
4244

run_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
set -e
1010
for TEST in ./tests/*.py; do
1111
echo "Running test [$TEST]..."
12-
nosetests --verbose --detailed-errors --nocapture "$@" "$TEST"
12+
USE_SYSTEM_PYTHON=1 nosetests --verbose --detailed-errors --nocapture "$@" "$TEST"
1313
echo
1414
done

src/php/unit/compile_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var _ = Describe("Compile", func() {
2020
Expect(err).NotTo(HaveOccurred())
2121

2222
if IsDockerAvailable() {
23-
cmd = exec.Command("docker", "run", "--rm", "-e", "'CF_STACK=unsupported'", "-v", bpDir+":/buildpack:ro", "-w", "/buildpack", "cloudfoundry/cflinuxfs3", "./bin/compile", "/tmp/abcd", "/tmp/efgh")
23+
cmd = exec.Command("docker", "run", "--rm", "-e", "'CF_STACK=unsupported'", "-e", "USE_SYSTEM_PYTHON=1", "-v", bpDir+":/buildpack:ro", "-w", "/buildpack", "cloudfoundry/cflinuxfs3", "./bin/compile", "/tmp/abcd", "/tmp/efgh")
2424
} else {
2525
cmd = exec.Command("./bin/compile", "/tmp/abcd", "/tmp/efgh")
2626
cmd.Env = append(os.Environ(), "CF_STACK=unsupported")

0 commit comments

Comments
 (0)