From 6059ea01c370a9666772040e9c5c1f44e8991bae Mon Sep 17 00:00:00 2001 From: "Qirui(Keery) Nie" Date: Fri, 9 Dec 2022 11:56:49 +0800 Subject: [PATCH] Update scripts/check_spec_files_spelling.sh Co-authored-by: Michael Martin --- scripts/check_spec_files_spelling.sh | 34 +++++++++------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/scripts/check_spec_files_spelling.sh b/scripts/check_spec_files_spelling.sh index 3c0fef3eacb9..556589c7c93e 100755 --- a/scripts/check_spec_files_spelling.sh +++ b/scripts/check_spec_files_spelling.sh @@ -5,34 +5,22 @@ function red() { echo -e "\033[1;31m$*\033[0m" } -NO_SPEC_FILES=$(find spec -type f -name "*.lua" | grep -E 'spec/[0-9]+-.*' | grep -v "_spec.lua") -WHITELIST_PATTERNS=$(grep -v -E '^#' ./spec/on_demand_specs) -RESULT_TMP=$(mktemp) -RET=0 +readarray -t FOUND < \ +<( + git ls-files 'spec/[0-9]**.lua' \ + | grep -vE \ + -e '_spec.lua$' \ + -f spec/on_demand_specs +) -for file in $NO_SPEC_FILES; do - passed=0 - for pattern in $WHITELIST_PATTERNS; do - if grep -q -E "$pattern" <<< "$file"; then - passed=1 - break - fi - done - - if [ $passed -eq 0 ]; then - RET=1 - echo "$file" >> $RESULT_TMP - fi -done - -if [ $RET -eq 1 ]; then +if (( ${#FOUND[@]} > 0 )); then echo red "----------------------------------------------------------------" echo "Found some files in spec directory that do not have the _spec suffix, please check if you're misspelling them. If there is an exception, please add the coressponding files(or their path regexes) into the whitelist spec/on_demand_specs." echo echo "Possible misspelling file list:" - cat $RESULT_TMP + echo + printf "%s\n" "${FOUND[@]}" red "----------------------------------------------------------------" + exit 1 fi - -exit $RET