Skip to content

Commit

Permalink
Target tests with 1-based index
Browse files Browse the repository at this point in the history
  • Loading branch information
costas-basdekis committed Nov 4, 2020
1 parent 27d58e8 commit 9c60c82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
15 changes: 14 additions & 1 deletion buildroot/tests/run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c60c82

Please sign in to comment.