Author: sijie
Date: Sat Jul 20 18:16:37 2013
New Revision: 1505179
URL: http://svn.apache.org/r1505179
Log:
BOOKKEEPER-635: jenkins build should highlight which lines of the patch cause raw analysis
errors (ivank via sijie)
Added:
zookeeper/bookkeeper/trunk/bin/raw-check-patch
Modified:
zookeeper/bookkeeper/trunk/CHANGES.txt
zookeeper/bookkeeper/trunk/bin/test-patch-05-patch-raw-analysis
Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1505179&r1=1505178&r2=1505179&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Sat Jul 20 18:16:37 2013
@@ -42,6 +42,8 @@ Trunk (unreleased changes)
BOOKKEEPER-636: Latest txn logs might be deleted in a race condition which is not recoverable
if BK goes down before next txn log created. (vinay via ivank)
+ BOOKKEEPER-635: jenkins build should highlight which lines of the patch cause raw analysis
errors (ivank via sijie)
+
bookkeeper-server:
BOOKKEEPER-567: ReadOnlyBookieTest hangs on shutdown (sijie via ivank)
Added: zookeeper/bookkeeper/trunk/bin/raw-check-patch
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bin/raw-check-patch?rev=1505179&view=auto
==============================================================================
--- zookeeper/bookkeeper/trunk/bin/raw-check-patch (added)
+++ zookeeper/bookkeeper/trunk/bin/raw-check-patch Sat Jul 20 18:16:37 2013
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+printTrailingSpaces() {
+ PATCH=$1
+ cat $PATCH | awk '/^+/ { if (/ $/) { print "\tL" NR ":" $0} }'
+}
+
+printTabs() {
+ PATCH=$1
+ cat $PATCH | awk '/^+/ { if (/\t/) { print "\tL" NR ":" $0 } }'
+}
+
+printAuthors() {
+ PATCH=$1
+ cat $PATCH | awk '/^+/ { L=tolower($0); if (L ~ /.*\*.* @author/) { print "\tL" NR ":"
$0 } }'
+}
+
+printLongLines() {
+ PATCH=$1
+ cat $PATCH | awk '/^+/ { if ( length > 121 ) { print "\tL" NR ":" $0 } }'
+}
+
+if [[ "X$(basename -- "$0")" = "Xraw-check-patch" ]]; then
+ echo Trailing spaces
+ printTrailingSpaces $1
+ echo
+ echo Tabs
+ printTabs $1
+ echo
+ echo Authors
+ printAuthors $1
+ echo
+ echo Long lines
+ printLongLines $1
+fi
Modified: zookeeper/bookkeeper/trunk/bin/test-patch-05-patch-raw-analysis
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bin/test-patch-05-patch-raw-analysis?rev=1505179&r1=1505178&r2=1505179&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bin/test-patch-05-patch-raw-analysis (original)
+++ zookeeper/bookkeeper/trunk/bin/test-patch-05-patch-raw-analysis Sat Jul 20 18:16:37 2013
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+source $(dirname "$0")/raw-check-patch
if [ "${TESTPATCHDEBUG}" == "true" ] ; then
set -x
@@ -74,37 +75,48 @@ parseArgs() {
}
###############################################################################
checkNoAuthors() {
- authorTags=`grep "^+ " ${PATCHFILE} | grep -c -i -e ".*\*.* @author"`
+ TMPFILE=$TEMPDIR/$TASKNAME-authors.txt
+ printAuthors $PATCHFILE > $TMPFILE
+ authorTags=$(wc -l $TMPFILE | awk '{print $1}')
if [[ ${authorTags} != 0 ]] ; then
REPORT+=("{color:red}-1{color} the patch seems to contain ${authorTags} line(s) with
@author tags")
+ REPORT+=("$(cat $TMPFILE)")
else
REPORT+=("{color:green}+1{color} the patch does not introduce any @author tags")
fi
}
###############################################################################
checkNoTabs() {
- tabs=`grep "^+ " ${PATCHFILE} | grep -c -P "\t"`
+ TMPFILE=$TEMPDIR/$TASKNAME-tabs.txt
+ printTabs $PATCHFILE > $TMPFILE
+ tabs=$(wc -l $TMPFILE | awk '{print $1}')
if [[ ${tabs} != 0 ]] ; then
REPORT+=("{color:red}-1{color} the patch contains ${tabs} line(s) with tabs")
+ REPORT+=("$(cat $TMPFILE)")
else
REPORT+=("{color:green}+1{color} the patch does not introduce any tabs")
fi
}
###############################################################################
checkNoTrailingSpaces() {
- trailingSpaces=`grep "^+ " ${PATCHFILE} | grep -c -e " $"`
+ TMPFILE=$TEMPDIR/$TASKNAME-trailingspaces.txt
+ printTrailingSpaces $PATCHFILE > $TMPFILE
+ trailingSpaces=$(wc -l $TMPFILE | awk '{print $1}')
if [[ ${trailingSpaces} != 0 ]] ; then
REPORT+=("{color:red}-1{color} the patch contains ${trailingSpaces} line(s) with
trailing spaces")
+ REPORT+=("$(cat $TMPFILE)")
else
REPORT+=("{color:green}+1{color} the patch does not introduce any trailing spaces")
fi
}
###############################################################################
checkLinesLength() {
- # We check for > 120 to account for the "+" sign
- longLines=`grep "^+ " ${PATCHFILE} | awk 'BEGIN{count=0}{if ( length > 121 ) { count=count+1}
}END{ print count}'`
+ TMPFILE=$TEMPDIR/$TASKNAME-trailingspaces.txt
+ printLongLines $PATCHFILE > $TMPFILE
+ longLines=$(wc -l $TMPFILE | awk '{print $1}')
if [[ ${longLines} != 0 ]] ; then
REPORT+=("{color:red}-1{color} the patch contains ${longLines} line(s) longer than
120 characters")
+ REPORT+=("$(cat $TMPFILE)")
else
REPORT+=("{color:green}+1{color} the patch does not introduce any line longer than
120")
fi
|