From f508bd538dd672ac6927deeb32b435bda1230c09 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Tue, 11 Aug 2020 19:15:16 +0100 Subject: [PATCH] Fix the security update version check message for PyPy (#1040) Previously if an app was using an older version of PyPy, the buildpack would show a confusing "Could not find that version" message (even though the version was found), when it really meant to warn about there being a newer release available. It looks like the version check messages were perhaps copied and pasted from something else, but the message wording not updated at the time. I've also added tests since there were none for this feature. Fixes #1004. Closes @W-7918745@. --- CHANGELOG.md | 1 + bin/steps/python | 5 +++-- test/fixtures/pypy2_7/runtime.txt | 2 +- test/fixtures/pypy2_7_warn/requirements.txt | 0 test/fixtures/pypy2_7_warn/runtime.txt | 1 + test/fixtures/pypy3_6/runtime.txt | 2 +- test/fixtures/pypy3_6_warn/requirements.txt | 0 test/fixtures/pypy3_6_warn/runtime.txt | 1 + test/run-versions | 22 +++++++++++++++++++-- 9 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 test/fixtures/pypy2_7_warn/requirements.txt create mode 100644 test/fixtures/pypy2_7_warn/runtime.txt create mode 100644 test/fixtures/pypy3_6_warn/requirements.txt create mode 100644 test/fixtures/pypy3_6_warn/runtime.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 18af544..e400cd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Fix the security update version check message for apps using PyPy (#1040). ## v175 (2020-08-05) diff --git a/bin/steps/python b/bin/steps/python index e95b7fc..748bf75 100755 --- a/bin/steps/python +++ b/bin/steps/python @@ -8,6 +8,7 @@ PYTHON_VERSION=$(cat runtime.txt) VENDORED_PYTHON="${VENDOR_URL}/runtimes/$PYTHON_VERSION.tar.gz" SECURITY_UPDATE="Python has released a security update! Please consider upgrading to" +SECURITY_UPDATE_PYPY="The PyPy project has released a security update! Please consider upgrading to" ONLY_SUPPORTED_2_VERSION="Only the latest version of Python 2 is supported on the platform. Please consider upgrading to" @@ -64,14 +65,14 @@ if curl --output /dev/null --silent --head --fail "$VENDORED_PYTHON"; then if [[ "$PYTHON_VERSION" == $PYPY27* ]]; then # security update note if [ "$PYTHON_VERSION" != "$PYPY_27" ]; then - puts-warn "Could not find that Pypy version. Did you mean" "${PYPY_27}?" + puts-warn "$SECURITY_UPDATE_PYPY" "$PYPY_27" echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi if [[ "$PYTHON_VERSION" == $PYPY36* ]]; then # security update note if [ "$PYTHON_VERSION" != "$PYPY_36" ]; then - puts-warn "Could not find that Pypy version. Did you mean" "${PYPY_36}?" + puts-warn "$SECURITY_UPDATE_PYPY" "$PYPY_36" echo " Learn More: https://devcenter.heroku.com/articles/python-runtimes" fi fi diff --git a/test/fixtures/pypy2_7/runtime.txt b/test/fixtures/pypy2_7/runtime.txt index c502b68..e3d29d3 100644 --- a/test/fixtures/pypy2_7/runtime.txt +++ b/test/fixtures/pypy2_7/runtime.txt @@ -1 +1 @@ -pypy2.7-7.2.0 +pypy2.7-7.3.1 diff --git a/test/fixtures/pypy2_7_warn/requirements.txt b/test/fixtures/pypy2_7_warn/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/pypy2_7_warn/runtime.txt b/test/fixtures/pypy2_7_warn/runtime.txt new file mode 100644 index 0000000..c502b68 --- /dev/null +++ b/test/fixtures/pypy2_7_warn/runtime.txt @@ -0,0 +1 @@ +pypy2.7-7.2.0 diff --git a/test/fixtures/pypy3_6/runtime.txt b/test/fixtures/pypy3_6/runtime.txt index e1af38f..af949aa 100644 --- a/test/fixtures/pypy3_6/runtime.txt +++ b/test/fixtures/pypy3_6/runtime.txt @@ -1 +1 @@ -pypy3.6-7.2.0 +pypy3.6-7.3.1 diff --git a/test/fixtures/pypy3_6_warn/requirements.txt b/test/fixtures/pypy3_6_warn/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/pypy3_6_warn/runtime.txt b/test/fixtures/pypy3_6_warn/runtime.txt new file mode 100644 index 0000000..e1af38f --- /dev/null +++ b/test/fixtures/pypy3_6_warn/runtime.txt @@ -0,0 +1 @@ +pypy3.6-7.2.0 diff --git a/test/run-versions b/test/run-versions index c491748..0f76a87 100755 --- a/test/run-versions +++ b/test/run-versions @@ -197,24 +197,42 @@ testPython3_8_fail() { testPypy3_6() { compile "pypy3_6" + assertCaptured "Installing pypy" + assertNotCaptured "security update" + assertCaptured "$PYPY_36" + assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2" + assertCapturedSuccess +} + +testPypy3_6_warn() { + compile "pypy3_6_warn" if [[ $STACK = "cedar-14" ]]; then assertCapturedError else assertCaptured "Installing pypy" + assertCaptured "security update!" assertCaptured "$PYPY_36" - assertCaptured "Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2" assertCapturedSuccess fi } testPypy2_7() { compile "pypy2_7" + assertCaptured "Installing pypy" + assertNotCaptured "security update" + assertCaptured "$PYPY_27" + assertCaptured "Installing pip 20.1.1, setuptools 44.1.1 and wheel 0.34.2" + assertCapturedSuccess +} + +testPypy2_7_warn() { + compile "pypy2_7_warn" if [[ $STACK = "cedar-14" ]]; then assertCapturedError else assertCaptured "Installing pypy" + assertCaptured "security update!" assertCaptured "$PYPY_27" - assertCaptured "Installing pip 20.1.1, setuptools 44.1.1 and wheel 0.34.2" assertCapturedSuccess fi }