From d4239194cb3a89545e4740ae43a309524dda6c88 Mon Sep 17 00:00:00 2001 From: brian khuu Date: Tue, 14 May 2024 23:18:57 +1000 Subject: [PATCH] debug-test.sh: refactor --- scripts/debug-test.sh | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/scripts/debug-test.sh b/scripts/debug-test.sh index 497e44e57..20c2f43a6 100755 --- a/scripts/debug-test.sh +++ b/scripts/debug-test.sh @@ -1,6 +1,4 @@ #!/bin/bash -test_suite=${1:-} -test_number=${2:-} PROG=${0##*/} build_dir="build-ci-debug" @@ -48,12 +46,8 @@ fi # Parse command-line options gdb_mode=false -while getopts "hg" opt; do +while getopts "g" opt; do case $opt in - h) - print_full_help >&2 - exit 0 - ;; g) gdb_mode=true echo "gdb_mode Mode Enabled" @@ -61,6 +55,22 @@ while getopts "hg" opt; do esac done +# Shift the option parameters +shift $((OPTIND - 1)) + +# Step 0: Check the args +if [ -z "${1}" ]; then + echo "Usage: $PROG [OPTION]... (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 select_test() { test_suite=${1:-test} @@ -142,15 +152,6 @@ function select_test() { fi } -# Step 0: Check the args -if [ -z "$test_suite" ] -then - echo "Usage: $PROG [OPTION]... (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 ## Sanity check that we are actually in a git repo