From cbd0cec4eb9486bc9f6c7a5fb980e6f809a61514 Mon Sep 17 00:00:00 2001 From: Andrey Stepachev Date: Wed, 25 Mar 2015 17:44:06 +0000 Subject: [PATCH] initial --- dev-support/test-patch.properties | 1 - dev-support/test-patch.sh | 77 ++++++++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/dev-support/test-patch.properties b/dev-support/test-patch.properties index 9bf5842..5f5cc32 100644 --- a/dev-support/test-patch.properties +++ b/dev-support/test-patch.properties @@ -19,7 +19,6 @@ MAVEN_OPTS="${MAVEN_OPTS:-"-Xmx3100M"}" # Please update the per-module test-patch.properties if you update this file. OK_RELEASEAUDIT_WARNINGS=0 -OK_FINDBUGS_WARNINGS=95 # Allow two warnings. Javadoc complains about sun.misc.Unsafe use. See HBASE-7457 OK_JAVADOC_WARNINGS=2 diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh index 86f7685..a482c02 100755 --- a/dev-support/test-patch.sh +++ b/dev-support/test-patch.sh @@ -240,6 +240,32 @@ checkoutBranch() { } ############################################################################### +### Collect findbugs reports +collectFindbugsReports() { + name=$1 + basedir=$2 + patch_dir=$3 + for file in $(find $basedir -name findbugsXml.xml) + do + relative_file=${file#$basedir/} # strip leading $basedir prefix + if [ ! $relative_file == "target/findbugsXml.xml" ]; then + module_suffix=${relative_file%/target/findbugsXml.xml} # strip trailing path + module_suffix=`basename ${module_suffix}` + fi + + cp $file $patch_dir/${name}FindbugsWarnings${module_suffix}.xml + $FINDBUGS_HOME/bin/setBugDatabaseInfo -name $name \ + $patch_dir/${name}FindbugsWarnings${module_suffix}.xml \ + $patch_dir/${name}FindbugsWarnings${module_suffix}.xml + done + xml_file=$patch_dir/${name}FindbugsWarnings.xml + html_file=$patch_dir/${name}FindbugsWarnings.html + $FINDBUGS_HOME/bin/unionBugs -withMessages -output $xml_file $patch_dir/${name}FindbugsWarnings*.xml + $FINDBUGS_HOME/bin/convertXmlToText -html $xml_file $html_file + file $xml_file $html_file +} + +############################################################################### setup () { ### Download latest patch file (ignoring .htm and .html) when run from patch process if [[ $JENKINS == "true" ]] ; then @@ -297,10 +323,10 @@ setup () { echo "======================================================================" echo "" echo "" - echo "$MVN clean package checkstyle:checkstyle-aggregate -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/trunkJavacWarnings.txt 2>&1" + echo "$MVN clean package checkstyle:checkstyle-aggregate findbugs:findbugs -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/trunkJavacWarnings.txt 2>&1" export MAVEN_OPTS="${MAVEN_OPTS}" # build core and tests - $MVN clean package checkstyle:checkstyle-aggregate -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/trunkJavacWarnings.txt 2>&1 + $MVN clean package checkstyle:checkstyle-aggregate findbugs:findbugs -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/trunkJavacWarnings.txt 2>&1 if [[ $? != 0 ]] ; then ERR=`$GREP -A 5 'Compilation failure' $PATCH_DIR/trunkJavacWarnings.txt` echo "Trunk compilation is broken? @@ -308,6 +334,7 @@ setup () { cleanupAndExit 1 fi mv target/checkstyle-result.xml $PATCH_DIR/trunkCheckstyle.xml + collectFindbugsReports trunk $BASEDIR $PATCH_DIR } ############################################################################### @@ -705,36 +732,28 @@ checkFindbugsWarnings () { {color:red}-1 findbugs{color}. The patch appears to cause Findbugs (version ${findbugs_version}) to fail." return 1 fi - - findbugsWarnings=0 - for file in $(find $BASEDIR -name findbugsXml.xml) - do - relative_file=${file#$BASEDIR/} # strip leading $BASEDIR prefix - if [ ! $relative_file == "target/findbugsXml.xml" ]; then - module_suffix=${relative_file%/target/findbugsXml.xml} # strip trailing path - module_suffix=`basename ${module_suffix}` - fi - - cp $file $PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml - $FINDBUGS_HOME/bin/setBugDatabaseInfo -timestamp "01/01/2000" \ - $PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml \ - $PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml - newFindbugsWarnings=`$FINDBUGS_HOME/bin/filterBugs -first "01/01/2000" $PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml \ - $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml | $AWK '{print $1}'` - echo "Found $newFindbugsWarnings Findbugs warnings ($file)" - findbugsWarnings=$((findbugsWarnings+newFindbugsWarnings)) - echo "$FINDBUGS_HOME/bin/convertXmlToText -html $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.html" - $FINDBUGS_HOME/bin/convertXmlToText -html $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.html - file $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.html - JIRA_COMMENT_FOOTER="Findbugs warnings: $BUILD_URL/artifact/patchprocess/newPatchFindbugsWarnings${module_suffix}.html + + collectFindbugsReports patch $BASEDIR $PATCH_DIR + #this files are generated by collectFindbugsReports() named with its first argument + patch_xml=$PATCH_DIR/patchFindbugsWarnings.xml + trunk_xml=$PATCH_DIR/trunkFindbugsWarnings.xml + # combine them to one database + combined_xml=$PATCH_DIR/combinedFindbugsWarnings.xml + new_xml=$PATCH_DIR/newFindbugsWarnings.xml + new_html=$PATCH_DIR/newFindbugsWarnings.html + $FINDBUGS_HOME/bin/computeBugHistory -useAnalysisTimes -withMessages \ + -output $combined_xml $trunk_xml $patch_xml + findbugsWarnings=$($FINDBUGS_HOME/bin/filterBugs -first patch $combined_xml $new_xml) + findbugsFixedWarnings=$($FINDBUGS_HOME/bin/filterBugs -fixed patch $combined_xml $new_xml) + $FINDBUGS_HOME/bin/convertXmlToText -html $new_xml $new_html + file $new_xml $new_html + JIRA_COMMENT_FOOTER="Release Findbugs (version ${findbugs_version}) warnings: $BUILD_URL/artifact/patchprocess/newFindbugsWarnings.html $JIRA_COMMENT_FOOTER" - done - - ### if current warnings greater than OK_FINDBUGS_WARNINGS - if [[ $findbugsWarnings -gt $OK_FINDBUGS_WARNINGS ]] ; then + ### if current warnings greater than 0, fail + if [[ $findbugsWarnings -gt 0 ]] ; then JIRA_COMMENT="$JIRA_COMMENT - {color:red}-1 findbugs{color}. The patch appears to introduce `expr $(($findbugsWarnings-$OK_FINDBUGS_WARNINGS))` new Findbugs (version ${findbugs_version}) warnings." + {color:red}-1 findbugs{color}. The patch appears to introduce $findbugsWarnings new Findbugs (version ${findbugs_version}) warnings." return 1 fi JIRA_COMMENT="$JIRA_COMMENT -- 2.3.0