Refactor ci script to choose test based on single cli arg

We prefer just passing a single cli argument that allows the script to
choose the corresponding gradle command from a preset list of
choices. For now, valid options are `packagingtests` or `tests`. The
script defaults to `tests` if no argument is supplied.

Original commit: elastic/x-pack-elasticsearch@f6315b1ad5
This commit is contained in:
Dimitrios Liappis 2016-11-23 13:44:15 +02:00
parent 46055d0430
commit 1fea75cc4f
1 changed files with 17 additions and 19 deletions

View File

@ -11,28 +11,26 @@
# `NVM_DIR` environment variable.
#
# Set the default gradle parameters for running tests
gradleoptstring="--info check -Dtests.network=true -Dtests.badapples=true"
# Turn on semi-strict mode
set -e
set -o pipefail
while [ $# -ge 1 ]
do
# Set default test scenario, equivalent to passing the cli arg `tests`
GRADLE_OPT_STRING="--info check -Dtests.network=true -Dtests.badapples=true"
# Allow the user choose different test through a single cli arg
if [ $# -ge 1 ]
then
key="$1"
case $key in
-g|--gradleoptstring)
gradleoptstring="$2"
shift 2;;
-h|--help)
echo -e "Syntax:\n"
echo -e "$0 [-g|--gradleoptstring] \"override gradle parameters for tests\"\n"
exit 0;;
*)
echo "Unknown argument: $key";
exit 1;;
packagingtests)
GRADLE_OPT_STRING="--info -Pvagrant.boxes=all :x-plugins:qa:vagrant:packagingTest"
break;;
tests)
GRADLE_OPT_STRING="--info check -Dtests.network=true -Dtests.badapples=true"
break;;
esac
done
# Turn on semi-strict mode
set -e pipefail
fi
SCRIPT="$0"
@ -109,6 +107,6 @@ set -xuf
gradle --stacktrace clean
# Actually run the tests
gradle $gradleoptstring
gradle $GRADLE_OPT_STRING
# ~*~ shell-script-mode ~*~