Add --dry-run option to debug what tests are going to be ran exactly

This commit is contained in:
Alexandre Aubin 2023-07-21 02:56:43 +02:00
parent 0b71d81f91
commit 1ba05dda6d
2 changed files with 17 additions and 1 deletions

View file

@ -57,6 +57,14 @@ run_all_tests() {
read -p "Press a key to start the tests..." < /dev/tty
fi
if [ $dry_run -eq 1 ]; then
for FILE in $(ls $TEST_CONTEXT/tests/*.json)
do
cat $FILE | jq
done
exit
fi
# Launch all tests successively
cat $TEST_CONTEXT/tests/*.json >> /proc/self/fd/3

View file

@ -13,6 +13,7 @@ print_help() {
-a, --arch=ARCH
-d, --dist=DIST
-y, --ynh-branch=BRANCH
-D, --dry-run Show a JSON representing which tests are going to be ran (meant for debugging)
-i, --interactive Wait for the user to continue before each remove
-e, --interactive-on-errors Wait for the user to continue on errors
-s, --force-stop Force the stop of running package_check
@ -35,6 +36,7 @@ exit 0
[ "$#" -eq 0 ] && print_help
gitbranch=""
dry_run=0
interactive=0
interactive_on_errors=0
rebuild=0
@ -54,6 +56,7 @@ function parse_args() {
fi
# For each argument in the array, reduce to short argument for getopts
arguments[$i]=${arguments[$i]//--interactive/-i}
arguments[$i]=${arguments[$i]//--dry-run/-D}
arguments[$i]=${arguments[$i]//--rebuild/-r}
arguments[$i]=${arguments[$i]//--force-stop/-s}
arguments[$i]=${arguments[$i]//--help/-h}
@ -71,7 +74,7 @@ function parse_args() {
# Initialize the index of getopts
OPTIND=1
# Parse with getopts only if the argument begin by -
getopts ":b:iresh" parameter || true
getopts ":b:Diresh" parameter || true
case $parameter in
b)
# --branch=branch-name
@ -83,6 +86,11 @@ function parse_args() {
interactive=1
shift_value=1
;;
D)
# --dry-run
dry_run=1
shift_value=1
;;
e)
# --interactive-on-errors
interactive_on_errors=1