[tor-commits] [fallback-scripts/master] test: Add shellcheck tests
teor at torproject.org
teor at torproject.org
Mon Jan 20 05:32:01 UTC 2020
commit 348c36e75c168a20c92ad3e6c17e56d9f9e2b249
Author: teor <teor at torproject.org>
Date: Mon Dec 2 13:34:12 2019 +1000
test: Add shellcheck tests
Part of 28863.
---
.travis.yml | 11 +++++++++++
test.sh | 7 +++++++
2 files changed, 18 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index b7bfc94..a219026 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -38,6 +38,7 @@ matrix:
packages:
## macOS needs pip(2) from homebrew python
- python at 2
+ - shellcheck
## See ticket #30928 for more information. This key should be
## removed at some point to speed up builds.
update: true
@@ -97,6 +98,15 @@ dist: bionic
## Recent is Xcode 11.2 on macOS 10.14 as of October 2019
osx_image: xcode11.2
+## Download our dependencies
+## We don't install shellcheck on macOS, because brew update is slow
+addons:
+ ## (Linux only)
+ apt:
+ packages:
+ ## Optional build dependencies
+ - shellcheck
+
before_install:
## Set pipefail: we use pipes
- set -o pipefail || echo "pipefail failed"
@@ -105,6 +115,7 @@ install:
## List installed package versions
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then dpkg-query --show; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew list --versions; fi
+ - if command -v shellcheck ; then shellcheck --version; fi
- $PYTHON --version
## Are we running python 2?
- if $PYTHON --version 2>&1 | cut -d" " -f2 | grep -q '2[.]'; then PY2=1; else PY2= ; fi
diff --git a/test.sh b/test.sh
index a6bd19a..0dc177a 100755
--- a/test.sh
+++ b/test.sh
@@ -6,6 +6,13 @@ set -e
# Use the default python spelling, if the user hasn't specified one
PYTHON=${PYTHON:-python}
+# Test our shell script code portability and quality (including this script)
+# SC1117 was disabled after 0.5, because it was too pedantic
+EXCLUSIONS="--exclude=SC1117"
+if command -v shellcheck; then
+ find . -name "*.sh" -exec shellcheck "$EXCLUSIONS" {} +
+fi
+
## moria1, Serge, no caches extra info, no dir port, doesn't exist
## TODO: validate output from all 3 commands using grep, grep, and stem?
$PYTHON generateFallbackDirLine.py 9695DFC35FFEB861329B9F1AB04C46397020CE31 BA44A889E64B93FAA2B114E02C2A279A8555C533 001524DD403D729F08F7E5D77813EF12756CFA8D 5AFAC3D00E97D6733112CC9CA2A788691FA87125 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
More information about the tor-commits
mailing list