This commit is contained in:
Pierre Tardy
2013-11-07 10:18:31 +01:00
parent 4835b3b822
commit 592ac96a77
2 changed files with 28 additions and 10 deletions

View File

@@ -1 +1 @@
git diff --name-only HEAD^ | common/style_check_and_fix.sh common/validate.sh HEAD~ --quick

View File

@@ -13,18 +13,22 @@ YELLOW="$_ESC[1;33m"
NORM="$_ESC[0;0m" NORM="$_ESC[0;0m"
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
echo "USAGE: common/validate.sh oldrev" echo "USAGE: common/validate.sh oldrev [--quick]"
echo " This script will test a set of patches (oldrev..HEAD) for basic acceptability as a patch" echo " This script will test a set of patches (oldrev..HEAD) for basic acceptability as a patch"
echo " Run it in an activated virtualenv with the current Buildbot installed, as well as" echo " Run it in an activated virtualenv with the current Buildbot installed, as well as"
echo " sphinx, pyflakes, mock, and so on" echo " sphinx, pyflakes, mock, and so on"
echo "To use a different directory for tests, pass TRIALTMP=/path as an env variable" echo "To use a different directory for tests, pass TRIALTMP=/path as an env variable"
echo "if --quick is passed validate will skip unit tests and concentrate on coding style"
exit 1 exit 1
fi fi
status() { status() {
echo "${LTCYAN}-- ${*} --${NORM}" echo "${LTCYAN}-- ${*} --${NORM}"
} }
slow=true
if [[ $2 == '--quick' ]]; then
slow=false
fi
ok=true ok=true
problem_summary="" problem_summary=""
not_ok() { not_ok() {
@@ -60,7 +64,9 @@ run_tests() {
if ! git diff --no-ext-diff --quiet --exit-code; then if ! git diff --no-ext-diff --quiet --exit-code; then
not_ok "changed files in working copy" not_ok "changed files in working copy"
exit 1 if $slow; then
exit 1
fi
fi fi
# get a list of changed files, used below; this uses a tempfile to work around # get a list of changed files, used below; this uses a tempfile to work around
@@ -76,8 +82,10 @@ done < ${tempfile}
echo "${MAGENTA}Validating the following commits:${NORM}" echo "${MAGENTA}Validating the following commits:${NORM}"
git log "$REVRANGE" --pretty=oneline || exit 1 git log "$REVRANGE" --pretty=oneline || exit 1
status "running tests" if $slow; then
run_tests || not_ok "tests failed" status "running tests"
run_tests || not_ok "tests failed"
fi
status "checking formatting" status "checking formatting"
check_tabs && not_ok "$REVRANGE adds tabs" check_tabs && not_ok "$REVRANGE adds tabs"
@@ -85,9 +93,6 @@ check_tabs && not_ok "$REVRANGE adds tabs"
status "checking for release notes" status "checking for release notes"
check_relnotes || warning "$REVRANGE does not add release notes" check_relnotes || warning "$REVRANGE does not add release notes"
status "running pyflakes"
pyflakes master/buildbot slave/buildslave || not_ok "failed pyflakes"
status "checking import module convention in modified files" status "checking import module convention in modified files"
RES=true RES=true
for filename in ${py_files[@]}; do for filename in ${py_files[@]}; do
@@ -98,7 +103,6 @@ for filename in ${py_files[@]}; do
done done
$RES || warning "some import fixes failed -- not enforcing for now" $RES || warning "some import fixes failed -- not enforcing for now"
set -x
status "running autopep8" status "running autopep8"
if [[ -z `which autopep8` ]]; then if [[ -z `which autopep8` ]]; then
warning "autopep8 is not installed" warning "autopep8 is not installed"
@@ -139,6 +143,20 @@ else
$pep8_ok || not_ok "pep8 failed" $pep8_ok || not_ok "pep8 failed"
fi fi
status "running pyflakes"
if [[ -z `which pyflakes` ]]; then
warning "pyflakes is not installed"
else
pyflakes_ok=true
for filename in ${py_files[@]}; do
if ! pyflakes "$filename"; then
pyflakes_ok=false
fi
done
$pyflakes_ok || not_ok "pyflakes failed"
fi
status "running pylint" status "running pylint"
if [[ -z `which pylint` ]]; then if [[ -z `which pylint` ]]; then
warning "pylint is not installed" warning "pylint is not installed"