debug-test.sh: refactor

This commit is contained in:
brian khuu 2024-05-14 23:18:57 +10:00
parent f274de5386
commit d4239194cb

View file

@ -1,6 +1,4 @@
#!/bin/bash #!/bin/bash
test_suite=${1:-}
test_number=${2:-}
PROG=${0##*/} PROG=${0##*/}
build_dir="build-ci-debug" build_dir="build-ci-debug"
@ -48,12 +46,8 @@ fi
# Parse command-line options # Parse command-line options
gdb_mode=false gdb_mode=false
while getopts "hg" opt; do while getopts "g" opt; do
case $opt in case $opt in
h)
print_full_help >&2
exit 0
;;
g) g)
gdb_mode=true gdb_mode=true
echo "gdb_mode Mode Enabled" echo "gdb_mode Mode Enabled"
@ -61,6 +55,22 @@ while getopts "hg" opt; do
esac esac
done done
# Shift the option parameters
shift $((OPTIND - 1))
# Step 0: Check the args
if [ -z "${1}" ]; then
echo "Usage: $PROG [OPTION]... <test_regex> (test_number)"
echo "Supply one regex to the script to filter tests,"
echo "and optionally a test number to run a specific test."
echo "Use --help flag for full instructions"
exit 1
else
test_suite=${1:-}
fi
test_number=${2:-}
# Function to select and debug a test # Function to select and debug a test
function select_test() { function select_test() {
test_suite=${1:-test} test_suite=${1:-test}
@ -142,15 +152,6 @@ function select_test() {
fi fi
} }
# Step 0: Check the args
if [ -z "$test_suite" ]
then
echo "Usage: $PROG [OPTION]... <test_regex> (test_number)"
echo "Supply one regex to the script to filter tests,"
echo "and optionally a test number to run a specific test."
echo "Use --help flag for full instructions"
exit 1
fi
# Step 1: Reset and Setup folder context # Step 1: Reset and Setup folder context
## Sanity check that we are actually in a git repo ## Sanity check that we are actually in a git repo