Skip to content

Commit

Permalink
fix(compile): remove trailing whitespaces in python-version extracting (
Browse files Browse the repository at this point in the history
  • Loading branch information
marns93 committed Feb 15, 2023
1 parent 98333c6 commit 227ba72
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fi

if [ -z "${PYTHON_RUNTIME_VERSION:-}" ] ; then
log "Read Python version from poetry.lock"
PYTHON_RUNTIME_VERSION="$(sed -n -e '/^\[metadata\]/,/^\[/p' poetry.lock | sed -n -e 's/^python-versions\s*=\s*//p' | tr -d \"\')"
PYTHON_RUNTIME_VERSION="$(sed -n -e '/^\[metadata\]/,/^\[/p' poetry.lock | sed -n -e 's/^python-versions\s*=\s*//p' | tr -d \"'[:space:]'\')"
else
log "Force Python version to $PYTHON_RUNTIME_VERSION, because PYTHON_RUNTIME_VERSION is set!"
fi
Expand Down
Empty file.
13 changes: 13 additions & 0 deletions test/fixtures/compile-trailing_space.stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-----> No Poetry version specified in POETRY_VERSION config var. Defaulting to 1.3.2.
-----> Generate requirements.txt with Poetry
-----> Install Poetry
>>> mocked curl call <<<
-----> Add Poetry to the PATH
-----> Force usage of active Python and disable creation of virtualenvs
>>> mocked poetry call <<<
>>> mocked poetry call <<<
-----> Export requirements.txt from Poetry
>>> mocked poetry call <<<
-----> Export Python version from Poetry to Heroku runtime.txt file
-----> Read Python version from poetry.lock
-----> Write 3.8.3 into runtime.txt
9 changes: 7 additions & 2 deletions test/test-compile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ run_test sanity-2 compile BUILD_DIR CACHE_DIR
cp fixtures/poetry.lock-valid "$INPUT_DIR"/poetry.lock
run_test no_vars_success compile "$INPUT_DIR" CACHE_DIR fixtures/env_dir

cp fixtures/poetry.lock-valid "$INPUT_DIR"/poetry.lock
# add trailing space to python-versions to test if it will be removed
sed -i 's/^python-versions.*/& /g' "$INPUT_DIR"/poetry.lock
run_test trailing_space compile "$INPUT_DIR" CACHE_DIR fixtures/env_dir

cp fixtures/poetry.lock-valid "$INPUT_DIR"/poetry.lock
run_test export_dev compile "$INPUT_DIR" CACHE_DIR fixtures/env_dir-export_dev

Expand All @@ -25,10 +30,10 @@ run_test force_poetry_version compile "$INPUT_DIR" CACHE_DIR fixtures/env_dir-po
echo "test" > "$INPUT_DIR/runtime.txt"
run_test skip_runtime_error compile "$INPUT_DIR" CACHE_DIR fixtures/env_dir-disable_runtime-0

# overiding export param with POETRY_EXPORT_PARAMS env var
# overriding export param with POETRY_EXPORT_PARAMS env var
cp fixtures/poetry.lock-valid "$INPUT_DIR"/poetry.lock
run_test export_params-0 compile "$INPUT_DIR" CACHE_DIR fixtures/env_dir-export_params-0

# overiding export param with POETRY_EXPORT_PARAMS env var and skipping POETRY_EXPORT_DEV_REQUIREMENTS env var
# overriding export param with POETRY_EXPORT_PARAMS env var and skipping POETRY_EXPORT_DEV_REQUIREMENTS env var
cp fixtures/poetry.lock-valid "$INPUT_DIR"/poetry.lock
run_test export_params-1 compile "$INPUT_DIR" CACHE_DIR fixtures/env_dir-export_params-1

0 comments on commit 227ba72

Please sign in to comment.