tempest/tools/format.sh
Masayuki Igawa de1153b361
Introduce bashate
This commit introduces bashate[0] which is a code style checker for bash
scripts. We already have some bash scripts in Tempest repo. So, it might
be good to check the style automatically.

Some scripts under the tools directory are also fixed due to the bashate
violation.

Change-Id: I07820f10387552f93a9d8891b58a8c7fcdb83046
2019-07-30 18:02:07 +09:00

31 lines
664 B
Bash
Executable File

#!/bin/bash
cd $(dirname "$(readlink -f "$0")")
AUTOPEP8=`which autopep8 2>/dev/null`
if [[ -z "$AUTOPEP8" ]]; then
AUTOPEP8=`which autopep8-3`
fi
if [[ -z "$AUTOPEP8" ]]; then
echo "Unable to locate autopep8" >&2
exit 2
fi
# isort is not compatible with the default flake8 (H306), maybe flake8-isort
# isort -rc -sl -fss ../tempest ../setup.py
$AUTOPEP8 --exit-code --max-line-length=79 --experimental --in-place \
-r ../tempest ../setup.py
ERROR=$?
if [[ $ERROR -eq 0 ]]; then
echo "Formatting was not needed." >&2
exit 0
elif [[ $ERROR -eq 1 ]]; then
echo "Formatting failed.." >&2
exit 1
else
echo "done" >&2
fi