diff options
Diffstat (limited to 'eclass/tests/gradle.sh')
-rwxr-xr-x | eclass/tests/gradle.sh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/eclass/tests/gradle.sh b/eclass/tests/gradle.sh new file mode 100755 index 00000000..dac9c9cc --- /dev/null +++ b/eclass/tests/gradle.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# Copyright 2022-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +source tests-common.sh || exit + +inherit gradle + +# TODO: hack because tests-common don't implement ver_cut +EAPI=6 inherit eapi7-ver + +test_set_EGRADLE() { + local expected_EGRADLE="${1}" + + shift + + local tmpdir + tmpdir=$(mktemp -d || die) + for pseudo_gradle in "${@}"; do + local pseudo_gradle_path="${tmpdir}/${pseudo_gradle}" + touch "${pseudo_gradle_path}" + chmod 755 "${pseudo_gradle_path}" + done + + local saved_PATH="${PATH}" + PATH="${tmpdir}" + + local test_desc=( + test_set_EGRADLE + ) + [[ -v EGRADLE_MIN ]] && test_desc+=( "EGRADLE_MIN=${EGRADLE_MIN}" ) + [[ -v EGRADLE_MAX_EXCLUSIVE ]] && test_desc+=( "EGRADLE_MAX_EXCLUSIVE=${EGRADLE_MAX_EXCLUSIVE}" ) + test_desc+=( $@ ) + + tbegin "${test_desc[@]}" + gradle-set_EGRADLE + + local saved_EGRADLE="${EGRADLE}" + unset EGRADLE + + PATH="${saved_PATH}" + rm -rf "${tmpdir}" + + [[ "${saved_EGRADLE}" == "${expected_EGRADLE}" ]] + tend $? + + if (( $? > 0 )); then + >&2 echo -e "\t expected=${expected_EGRADLE} actual=${saved_EGRADLE}" + fi +} + +test_set_EGRADLE gradle-2.0 gradle-1.0 gradle-2.0 +EGRADLE_MIN=2.0 test_set_EGRADLE gradle-2.2.3 gradle-1.0 gradle-2.0 gradle-2.2.3 +EGRADLE_MAX_EXCLUSIVE=2.2 test_set_EGRADLE gradle-2.0 gradle-1.0 gradle-2.0 gradle-2.2.3 + + +texit |