Skip to content
Snippets Groups Projects
Commit a8ce2352 authored by Rafael Guterres Jeffman's avatar Rafael Guterres Jeffman
Browse files

utils/set_test_modules: Allow to ignore Git differences

To force setting the IPA_ENABLE_* variables to run all tests, source the
script using '-I' or set the environment variable SKIP_GIT_TESTS to
'True'.

This will allow the correct selection of Azure pipelines tests to be
based on a single environment variable, what will reduce the number of
test running templates to a singe file.
parent bdcc8153
No related branches found
No related tags found
No related merge requests found
#!/bin/bash -eu #!/bin/bash -eu
# This file shoud be source'd (. set_test_modules) rather than executed. # This file shoud be source'd (. set_test_modules) rather than executed.
# #
# Set "BASE_BRANCH" to a different branch to compare. # Set SKIP_GIT_TEST="True" or use -a to prevent git modification comparison.
# #
RED="\033[31;1m" RED="\033[31;1m"
...@@ -18,27 +17,45 @@ TOPDIR="$(dirname "${BASH_SOURCE[0]}")/.." ...@@ -18,27 +17,45 @@ TOPDIR="$(dirname "${BASH_SOURCE[0]}")/.."
pushd "${TOPDIR}" >/dev/null 2>&1 || die "Failed to change directory." pushd "${TOPDIR}" >/dev/null 2>&1 || die "Failed to change directory."
SKIP_GIT_TEST=${SKIP_GIT_TEST:-"False"}
while getopts ":a" opt
do
case "${opt}" in
a) SKIP_GIT_TEST="True" ;;
*) ;; # ignore other options
esac
done
files_list=$(mktemp) files_list=$(mktemp)
remote="$(basename $(mktemp -u remote_XXXXXX))" enabled_modules="None"
git remote add ${remote} https://github.com/freeipa/ansible-freeipa enabled_tests="None"
git fetch --prune --no-tags --quiet ${remote}
git diff "${remote}/master" --name-only > "${files_list}"
git remote remove ${remote}
# Get all modules that should have tests executed if [ "${SKIP_GIT_TEST}" != "True" ]
enabled_modules="$(${python} utils/get_test_modules.py $(cat "${files_list}"))" then
[ -z "${enabled_modules}" ] && enabled_modules="None" remote="$(basename "$(mktemp -u remote_XXXXXX)")"
git remote add "${remote}" https://github.com/freeipa/ansible-freeipa
git fetch --prune --no-tags --quiet "${remote}"
git diff "${remote}/master" --name-only > "${files_list}"
git remote remove "${remote}"
# Get individual tests that should be executed # shellcheck disable=SC2046
mapfile -t tests < <(sed -n "s#.*/\(test_[^/]*\).yml#\1#p" "${files_list}" | tr -d " ") enabled_modules="$(${python} utils/get_test_modules.py $(cat "${files_list}"))"
[ ${#tests[@]} -gt 0 ] && enabled_tests=$(IFS=, ; echo "${tests[*]}") [ -z "${enabled_modules}" ] && enabled_modules="None"
[ -z "${enabled_tests}" ] && enabled_tests="None"
[ -n "${enabled_tests}" ] && IPA_ENABLED_TESTS="${enabled_tests},${IPA_ENABLED_TESTS}" # Get individual tests that should be executed
[ -n "${enabled_modules}" ] && IPA_ENABLED_MODULES="${enabled_modules},${IPA_ENABLED_MODULES}" mapfile -t tests < <(sed -n 's#.*/\(test_[^/]*\).yml#\1#p' "${files_list}" | tr -d " ")
[ ${#tests[@]} -gt 0 ] && enabled_tests=$(IFS=, ; echo "${tests[*]}")
[ -z "${enabled_tests}" ] && enabled_tests="None"
rm -f "${files_list}" [ -n "${enabled_tests}" ] && IPA_ENABLED_TESTS="${enabled_tests},${IPA_ENABLED_TESTS}"
[ -n "${enabled_modules}" ] && IPA_ENABLED_MODULES="${enabled_modules},${IPA_ENABLED_MODULES}"
rm -f "${files_list}"
fi
# Get all modules that should have tests executed
export IPA_ENABLED_MODULES export IPA_ENABLED_MODULES
export IPA_ENABLED_TESTS export IPA_ENABLED_TESTS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment