From 0dcb996eafbe5a3afd69c742217bda980fd1dabf Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Thu, 9 Jun 2016 14:17:48 -0700 Subject: [PATCH] Add fast8 to quickly test pep8 changes This patch adds the 'fast8' test that Cinder has to os-brick. It's a simple pep8 check against what has changed since HEAD. This allows you to test for pep8 violations in files that you have changed without testing the entire repo. Change-Id: I4e3840d763d08a80c84ba00e2d5e5710a905ecf3 --- tools/fast8.sh | 15 +++++++++++++++ tox.ini | 7 ++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 tools/fast8.sh diff --git a/tools/fast8.sh b/tools/fast8.sh new file mode 100755 index 000000000..2b3e22abd --- /dev/null +++ b/tools/fast8.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +cd $(dirname "$0")/.. +CHANGED=$(git diff --name-only HEAD~1 | tr '\n' ' ') + +# Skip files that don't exist +# (have been git rm'd) +CHECK="" +for FILE in $CHANGED; do + if [ -f "$FILE" ]; then + CHECK="$CHECK $FILE" + fi +done + +diff -u --from-file /dev/null $CHECK | flake8 --diff diff --git a/tox.ini b/tox.ini index d907497f6..7a05dd770 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,12 @@ whitelist_externals = bash passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY [testenv:pep8] -commands = flake8 +commands = flake8 {posargs} + +[testenv:fast8] +envdir = {toxworkdir}/pep8 +commands = + {toxinidir}/tools/fast8.sh [testenv:pylint] deps = -r{toxinidir}/requirements.txt