Skip to content

Commit

Permalink
Ensure helper.py script can be called (#44)
Browse files Browse the repository at this point in the history
Specify absolute path to `helper.py` in `entrypoint.sh`.

Fix BATS tests concerning helper.py script:
Search and replace the `/helper.py` statements with `helper.py`
in the actually used `entrypoint.sh` for BATS tests.
  • Loading branch information
CasperWA authored Sep 28, 2020
1 parent 648bc69 commit 072fa8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ else
fi

# Check optimade-python-tools version is >0.10
PACKAGE_VERSION=($(python helper.py package-version))
PACKAGE_VERSION=($(python /helper.py package-version))

if [ ${PACKAGE_VERSION[0]} -eq 0 ] && [ ${PACKAGE_VERSION[1]} -lt 10 ]; then
echo "Incompatible validator version requested ${INPUT_VALIDATOR_VERSION}, please use >=0.10."
Expand Down Expand Up @@ -124,7 +124,7 @@ if [ "${INPUT_PATH}" = "/" ]; then
else
filler="/v"
fi
API_VERSION=($(python helper.py api-versions))
API_VERSION=($(python /helper.py api-versions))
case ${INPUT_ALL_VERSIONED_PATHS} in
y | Y | yes | Yes | YES | true | True | TRUE | on | On | ON)
for version in "${API_VERSION[@]}"; do
Expand Down Expand Up @@ -157,7 +157,7 @@ esac
EXIT_CODE=${PIPESTATUS[0]}

# Create output 'results'
RESULTS=$(python helper.py results)
RESULTS=$(python /helper.py results)
echo "::set-output name=results::${RESULTS}"

exit ${EXIT_CODE}
6 changes: 5 additions & 1 deletion tests/test_fixtures.bash
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ function setup_file() {
rm -f ${DOCKER_BATS_WORKDIR}/tests/.entrypoint-run_validator.txt
rm -f ${ENTRYPOINT_SH}

# Comment out "set -e" from entrypoint.sh in a new test entrypoint.sh
# Create BATS test entrypoint.sh at ${ENTRYPOINT_SH}
while IFS="" read -r line || [ -n "${line}" ]; do
if [[ "${line}" =~ ^set[[:blank:]]-e$ ]]; then
# Comment out "set -e" from entrypoint.sh in a new test entrypoint.sh
line="# ${line}"
fi
if [[ "${line}" =~ ^.*helper\.py.*$ ]]; then
line="${line/\/helper\.py/helper.py}"
fi
printf "%s\n" "${line}" >> ${ENTRYPOINT_SH}
done < ${REAL_ENTRYPOINT_SH}
chmod +x ${ENTRYPOINT_SH}
Expand Down

0 comments on commit 072fa8d

Please # to comment.