Skip to content
Permalink
Browse files

tests/shell-checks: merge tests/whitespace-check, add tab check

  • Loading branch information
austin987 committed Nov 23, 2019
1 parent e45bc61 commit c701dbec273dc394c90e2fbbf26a405ebb57842b
Showing with 16 additions and 41 deletions.
  1. +0 −3 .travis.yml
  2. +16 −0 tests/shell-checks
  3. +0 −38 tests/whitespace-check
@@ -82,9 +82,6 @@ script:
# shell-checks is quick and works, no display or compiles needed
- time sh ./tests/shell-checks

# Also check for trailing whitespace. Not doing in shell-checks because it depends on a clean tree (uses git diff):
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then time sh ./tests/whitespace-check; fi

# Keep updates working
- time sh ./tests/self-update-test

@@ -125,6 +125,21 @@ _EOF
fi
}

# check formatting, (no trailing whitespace, no tabs)
test_formatting() {
# check for trailing spaces
# git diff misses some stuff? (2.18.0 / 2.22.0)
#w_try git diff --check --exit-code "${shellscript}"
if grep -n -r '[[:blank:]]$' "${shellscript}"; then
w_die "${shellscript} contains trailing spaces, remove them."
fi

# check for tabs
if grep -n "$(printf '\t')" "${shellscript}"; then
w_die "${shellscript} contains tabs, please use spaces instead."
fi
}

# tests using shellcheck
test_shellcheck() {
if [ ! -x "$(command -v shellcheck 2>/dev/null)" ] && [ "$TRAVIS_OS_NAME" = "osx" ]; then
@@ -196,6 +211,7 @@ main() {

# Generic shellscript checks:
for shellscript in $files_to_check; do
test_formatting
test_bashate
test_checkbashisms
test_shellcheck

This file was deleted.

0 comments on commit c701dbe

Please sign in to comment.
You can’t perform that action at this time.