Skip to content

Commit

Permalink
Update scripts/check_spec_files_spelling.sh
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Martin <flrgh@protonmail.com>
  • Loading branch information
windmgc and flrgh committed Dec 13, 2022
1 parent 8680aa1 commit 6059ea0
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions scripts/check_spec_files_spelling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6059ea0

Please sign in to comment.