Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add my validation script so others can use it, too

  • Loading branch information...
commit 9b925d1ce91b7ae2e9f879e1746680163d20e9fd 1 parent 4038a94
Dustin J. Mitchell authored March 08, 2012

Showing 1 changed file with 91 additions and 0 deletions. Show diff stats Hide diff stats

  1. 91  common/validate.sh
91  common/validate.sh
... ...
@@ -0,0 +1,91 @@
  1
+#! /bin/bash
  2
+
  3
+REVRANGE="$1..HEAD"
  4
+TEST='buildbot.test buildslave.test'
  5
+
  6
+# some colors
  7
+# plain
  8
+_ESC=$'\e'
  9
+GREEN="$_ESC[0;32m"
  10
+MAGENTA="$_ESC[0;35m"
  11
+RED="$_ESC[0;31m"
  12
+YELLOW="$_ESC[1;33m"
  13
+NORM="$_ESC[0;0m"
  14
+
  15
+if [ $# -eq 0 ]; then
  16
+    echo "USAGE: common/validate.sh oldrev"
  17
+    echo "  This script will test a set of patches (oldrev..HEAD) for basic acceptability as a patch"
  18
+    echo "  Run it in an activated virtualenv with the current Buildbot installed, as well as"
  19
+    echo "      sphinx, pyflakes, mock, and coverage."
  20
+    echo "To use a different directory for tests, pass TRIALTMP=/path as an env variable"
  21
+    exit 1
  22
+fi
  23
+
  24
+status() {
  25
+    echo ""
  26
+    echo "${YELLOW}-- ${*} --${NORM}"
  27
+}
  28
+
  29
+ok=true
  30
+not_ok() {
  31
+    ok=false
  32
+    echo "${RED}** ${*} **${NORM}"
  33
+}
  34
+
  35
+check_long_lines() {
  36
+    # only check python files
  37
+    local long_lines=false
  38
+    for f in $(git diff --name-only --stat "$REVRANGE" | grep '.py$'); do
  39
+        # don't try to check removed files
  40
+        [ ! -f "$f" ] && continue
  41
+        if [ $(git diff "$REVRANGE" $f | grep -c '+.{80}') != 0 ]; then
  42
+            echo " $f"
  43
+            long_lines=true
  44
+        fi
  45
+    done
  46
+    $long_lines
  47
+}
  48
+
  49
+if ! git diff --no-ext-diff --quiet --exit-code; then
  50
+    not_ok "changed files in working copy"
  51
+    exit 1
  52
+fi
  53
+
  54
+echo "${MAGENTA}Validating the following commits:${NORM}"
  55
+git log "$REVRANGE" --pretty=oneline || exit 1
  56
+
  57
+status "checking formatting"
  58
+git diff "$REVRANGE" | grep -q $'+.*\t' && not_ok "$REVRANGE adds tabs"
  59
+check_long_lines && not_ok "$REVRANGE adds long lines"
  60
+
  61
+status "running tests"
  62
+if [ -n "${TRIALTMP}" ]; then
  63
+    echo rm -rf ${TRIALTMP}
  64
+    TEMP_DIRECTORY_OPT="--temp-directory ${TRIAL_TMP}"
  65
+fi
  66
+
  67
+coverage erase || exit 1
  68
+coverage run --rcfile=.coveragerc \
  69
+    sandbox/bin/trial --reporter summary ${TEMP_DIRECTORY_OPT} ${TEST} \
  70
+    || not_ok "tests failed"
  71
+
  72
+status "running pyflakes"
  73
+make pyflakes || not_ok "failed pyflakes"
  74
+
  75
+status "coverage report"
  76
+coverage report > covreport || exit 1
  77
+head -n2 covreport || exit 1
  78
+tail -n1 covreport || exit 1
  79
+rm covreport || exit 1
  80
+
  81
+status "building docs"
  82
+make -C master/docs VERSION=latest clean html || not_ok "docs failed"
  83
+
  84
+echo ""
  85
+if $ok; then
  86
+    echo "${GREEN}GOOD!${NORM}"
  87
+    exit 0
  88
+else
  89
+    echo "${RED}NO GOOD!${NORM}"
  90
+    exit 1
  91
+fi

0 notes on commit 9b925d1

Please sign in to comment.
Something went wrong with that request. Please try again.