[chirp_devel] [PATCH 2/3] Add cpep8.sh wrapper script (#2355)

Zach Welch
Sat Feb 28 03:03:34 PST 2015


# HG changeset patch
# User Zach Welch <zach at mandolincreekfarm.com>
# Fake Node ID 006e7efdcbbf0438328561d099b1bc44d5b0f478

Add cpep8.sh wrapper script (#2355)

This patch moves the virtualenv setup out of run_all_tests.sh, allowing
cpep8.py to be run on its own with the correct module versions.  This
patch also moves the virtualenv temporary directory into tools/ and
adds it to the .hgignore file.

diff --git a/.hgignore b/.hgignore
index 4ba935a..140091a 100644
--- a/.hgignore
+++ b/.hgignore
@@ -4,4 +4,5 @@
 .*\.rej$
 dist
 build/bdist
-tests/logs/
\ No newline at end of file
+tools/cpep8.venv/
+tests/logs/
diff --git a/run_all_tests.sh b/run_all_tests.sh
index 34a0e42..3a5c67b 100755
--- a/run_all_tests.sh
+++ b/run_all_tests.sh
@@ -1,7 +1,5 @@
 #!/usr/bin/env bash
 
-VENV="${TMPDIR:-/tmp}/venv"
-
 function record_failure() {
     FAILED="$1 $FAILED"
 }
@@ -28,29 +26,9 @@ function style_tests() {
     ./tools/checkpatch.sh
 }
 
-function ensure_test_venv() {
-    virtualenv=$(which virtualenv)
-    if [ ! -x "$virtualenv" ]; then
-	echo 'Please install virtualenv'
-	return 1
-    fi
-    if [ ! -d "$VENV" ]; then
-	virtualenv "$VENV"
-    fi
-    return 0
-}
-
 function pep8() {
-    ensure_test_venv
-    if [ $? -ne 0 ]; then
-	record_failure pep8
-	return
-    fi
-    source ${VENV}/bin/activate
-    pip install pep8==1.4.6 >${VENV}/pep8.log 2>&1
     echo "Checking for PEP8 regressions..."
-    time ./tools/cpep8.py
-    deactivate
+    time ./tools/cpep8.sh
 }
 
 if test -z "${TESTS[*]}"; then
diff --git a/tools/cpep8.sh b/tools/cpep8.sh
new file mode 100755
index 0000000..8522692
--- /dev/null
+++ b/tools/cpep8.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# Runs cpep.py with the proper verion of the pep8 library.
+
+PEP8_VERSION="1.4.6"
+
+TOOLS_DIR="$(dirname $0)"
+VENV="${TMPDIR:-${TOOLS_DIR}}/cpep8.venv"
+
+virtualenv="$(which virtualenv)"
+if [ ! -x "$virtualenv" ]; then
+    echo 'Please install virtualenv'
+    exit 1
+fi
+if [ ! -d "$VENV" ]; then
+    virtualenv "$VENV"
+fi
+
+source ${VENV}/bin/activate
+pip install pep8==${PEP8_VERSION} >${VENV}/pep8.log 2>&1
+./tools/cpep8.py "$@"
+deactivate




More information about the chirp_devel mailing list