BATS: require `shellcheck` on test files

BATS: add `*.bats` to `.gitattributes`
pull/2033/head
John D Pell 2022-01-12 00:02:52 -08:00 committed by John D Pell
parent 3a778072db
commit bf811cd38e
3 changed files with 4 additions and 4 deletions

1
.gitattributes vendored
View File

@ -1,5 +1,6 @@
*.sh text eol=lf *.sh text eol=lf
*.bash text eol=lf *.bash text eol=lf
*.bats text eol=lf
# Docs allow trailing whitespaces # Docs allow trailing whitespaces
*.md whitespace=-blank-at-eol *.md whitespace=-blank-at-eol

View File

@ -19,7 +19,6 @@ repos:
hooks: hooks:
- id: git-check # Configure in .gitattributes - id: git-check # Configure in .gitattributes
- id: shellcheck - id: shellcheck
exclude: ".bats$"
- id: shfmt - id: shfmt
exclude: ".bats$" exclude: ".bats$"
- repo: https://github.com/Lucas-C/pre-commit-hooks - repo: https://github.com/Lucas-C/pre-commit-hooks
@ -38,10 +37,9 @@ repos:
types: [file] types: [file]
- id: dot-bash - id: dot-bash
name: Check .bash files against bash-it requirements name: Check .bash files against bash-it requirements
exclude: "test/test_helper.bash"
entry: ./hooks/dot-bash.sh entry: ./hooks/dot-bash.sh
language: system language: system
files: "\\.bash$" files: "\\.ba[ts][sh]$"
types: [file] types: [file]
- id: clean-files-txt - id: clean-files-txt
name: Check that clean_files.txt is sorted alphabetically. name: Check that clean_files.txt is sorted alphabetically.

View File

@ -12,7 +12,8 @@ for file in "$@"; do
# Confirm expected schellcheck header # Confirm expected schellcheck header
# #
LINE1="$(head -n 1 "${file}")" LINE1="$(head -n 1 "${file}")"
if [[ "${LINE1}" != "# shellcheck shell=bash" ]]; then SCSH="${file##*.}"
if [[ "${LINE1}" != "# shellcheck shell=${SCSH}" ]]; then
echo "Bash include file \`${file}\` has bad/missing shellcheck header" echo "Bash include file \`${file}\` has bad/missing shellcheck header"
exit_code=1 exit_code=1
fi fi