From 9c60c82c63bc462d0875ab338f89ba735a2180f0 Mon Sep 17 00:00:00 2001 From: Costas Basdekis Date: Wed, 4 Nov 2020 23:11:12 +0000 Subject: [PATCH] Target tests with 1-based index --- Makefile | 3 ++- buildroot/tests/run_tests | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 574d351a3f09..2a226b4521ab 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,8 @@ help: @echo " tests, but some of them are broken: use " @echo " tests-all-* instead to run only the ones that " @echo " run on GitHub CI" - @echo " ONLY_TEST Limit tests to only those that contain" + @echo " ONLY_TEST Limit tests to only those that contain this, or + @echo " the index of the test (1-based)" @echo " VERBOSE_PLATFORMIO If you want the full PIO output, set any value" @echo " GIT_RESET_HARD Used by CI: reset all local changes. WARNING:" @echo " THIS WILL UNDO ANY CHANGES YOU'VE MADE!" diff --git a/buildroot/tests/run_tests b/buildroot/tests/run_tests index 869d32ee1dd7..a0eef6a05ff0 100755 --- a/buildroot/tests/run_tests +++ b/buildroot/tests/run_tests @@ -54,7 +54,20 @@ if [[ $2 = "ALL" ]]; then done else exec_test $1 "$2 --target clean" "Setup Build Environment" - $2-tests $1 $2 "$3" + test_name="$3" + # If the test name is 1 or 2 digits, treat it as an index + if [[ "$test_name" =~ ^[0-9][0-9]?$ ]] ; then + # Find the test name that corresponds to that index + test_name="$(cat buildroot/tests/$2-tests | grep -e '^exec_test' | sed -n "$3p" | sed "s/.*\$1 \$2 \"\([^\"]*\).*/\1/g")" + if [[ -z "$test_name" ]] ; then + # Fail if none matches + printf "\033[0;31mCould not find test \033[0m#$3\033[0;31m in \033[0mbuildroot/tests/$2-tests\n" + exit 1 + else + printf "\033[0;32mMatching test \033[0m#$3\033[0;32m: '\033[0m$test_name\033[0;32m'\n" + fi + fi + $2-tests $1 $2 "$test_name" if [[ $GIT_RESET_HARD == "true" ]]; then git reset --hard HEAD else