Skip to content
Browse files

Improvements to test-patch script (tucu)

git-svn-id: https://svn.apache.org/repos/asf/incubator/oozie/trunk@1374443 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 75c5b20 commit 9d1a1ba0505423957869874154076bddcde1066b Alejandro Abdelnur committed Aug 17, 2012
Showing with 186 additions and 6 deletions.
  1. +3 −0 .gitignore
  2. +5 −1 bin/test-patch
  3. +16 −2 bin/test-patch-05-patch-raw-analysis
  4. +108 −0 bin/test-patch-08-rat
  5. +29 −3 bin/test-patch-10-compile
  6. +25 −0 pom.xml
View
3 .gitignore
@@ -1,6 +1,9 @@
# Maven
target
+# test-patch
+test-patch
+
# IntelliJ
*.iml
*.ipr
View
6 bin/test-patch
@@ -21,6 +21,7 @@ SUMMARYFILE=${REPORTDIR}/TEST-SUMMARY.txt
JIRA_URL="https://issues.apache.org"
JIRA_URL_ISSUE_PREFIX="${JIRA_URL}/jira/browse/"
+VERBOSE=""
DEBUG=""
JIRA_ISSUE=""
PATCHFILE=""
@@ -69,7 +70,7 @@ cleanupAndExit() {
}
###############################################################################
printUsage() {
- echo "Usage: $0 (--jira=<JIRA ISSUE> | --patch=<PATCH PATH>) [--debug] [--tasks=<TASK,...>] [--no-cleanup]"
+ echo "Usage: $0 (--jira=<JIRA ISSUE> | --patch=<PATCH PATH>) [--debug] [--verbose] [--tasks=<TASK,...>] [--no-cleanup]"
echo
}
###############################################################################
@@ -92,6 +93,9 @@ parseArgs() {
--debug)
DEBUG="-x"
;;
+ --verbose)
+ VERBOSE="true"
+ ;;
*)
echo "Invalid option"
echo
View
18 bin/test-patch-05-patch-raw-analysis
@@ -111,6 +111,19 @@ checkLinesLength() {
fi
}
###############################################################################
+checkForTestcases() {
+ testcases=`grep -c -i -e '^+++.*/test' ${PATCHFILE}`
+ if [[ ${testcases} == 0 ]] ; then
+ RAW_REPORT+=("-1 the patch does not add/modify any testcase")
+ #reverting for summary +1 calculation
+ testcases=1
+ else
+ RAW_REPORT+=("+1 the patch does adds/modifies ${testcases} testcase(s)")
+ #reverting for summary +1 calculation
+ testcases=0
+ fi
+}
+###############################################################################
parseArgs "$@"
@@ -125,14 +138,15 @@ case $OP in
checkNoTabs
checkNoTrailingSpaces
checkLinesLength
- total=`expr $authorTags + $tabs + $trailingSpaces + $longLines`
+ checkForTestcases
+ total=`expr $authorTags + $tabs + $trailingSpaces + $longLines + $testcases`
if [[ $total == 0 ]] ; then
echo "+1 ${TASKNAME}" >> $SUMMARYFILE
else
echo "-1 ${TASKNAME}" >> $SUMMARYFILE
fi
for line in "${RAW_REPORT[@]}" ; do
- echo " ${line}" >> $SUMMARYFILE
+ echo " ${line}" >> $SUMMARYFILE
done
;;
esac
View
108 bin/test-patch-08-rat
@@ -0,0 +1,108 @@
+#!/bin/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.
+
+BASEDIR=$(pwd)
+TASKNAME="RAT"
+OP=""
+TEMPDIR=""
+REPORTDIR=""
+SUMMARYFILE=""
+
+###############################################################################
+cleanupAndExit() {
+ exit $1
+}
+###############################################################################
+printUsage() {
+ echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>)"
+ echo
+}
+###############################################################################
+parseArgs() {
+ for i in $*
+ do
+ case $i in
+ --taskname)
+ echo ${TASKNAME}
+ exit 0
+ ;;
+ --op=*)
+ OP=${i#*=}
+ ;;
+ --tempdir=*)
+ TEMPDIR=${i#*=}
+ ;;
+ --reportdir=*)
+ REPORTDIR=${i#*=}
+ ;;
+ --summaryfile=*)
+ SUMMARYFILE=${i#*=}
+ ;;
+ esac
+ done
+ if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then
+ echo "Missing options"
+ echo
+ printUsage
+ cleanupAndExit 1
+ fi
+ if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then
+ echo "Invalid operation"
+ echo
+ printUsage
+ cleanupAndExit 1
+ fi
+}
+###############################################################################
+checkForWarnings() {
+ cleanWarns=`grep -c '\!?????' ${TEMPDIR}/${TASKNAME}-ratwarns-clean.txt`
+ patchWarns=`grep -c '\!?????' ${TEMPDIR}/${TASKNAME}-ratwarns-patch.txt`
+ newWarns=`expr $patchWarns - $cleanWarns`
+ if [[ $newWarns -le 0 ]] ; then
+ RAW_REPORT+=("+1 the patch does not seem to introduce new RAT warnings")
+ newWarns=0
+ else
+ RAW_REPORT+=("-1 the patch seems to introduce $newWarns new RAT warning(s)")
+ newWarns=1
+ fi
+ if [[ $cleanWarns != 0 ]] ; then
+ RAW_REPORT+=("WARNING: the current HEAD has $cleanWarns RAT warning(s), they should be addressed ASAP")
+ fi
+}
+###############################################################################
+
+
+parseArgs "$@"
+
+case $OP in
+ pre)
+ mvn apache-rat:check > ${TEMPDIR}/${TASKNAME}-ratwarns-clean.txt`
+ ;;
+ post)
+ mvn apache-rat:check > ${TEMPDIR}/${TASKNAME}-ratwarns-patch.txt`
+ ;;
+ report)
+ checkForWarnings
+ if [[ $newWarns == 0 ]] ; then
+ echo "+1 ${TASKNAME}" >> $SUMMARYFILE
+ else
+ echo "-1 ${TASKNAME}" >> $SUMMARYFILE
+ fi
+ for line in "${RAW_REPORT[@]}" ; do
+ echo " ${line}" >> $SUMMARYFILE
+ done
+ ;;
+esac
+
+exit 0
View
32 bin/test-patch-10-compile
@@ -65,20 +65,46 @@ parseArgs() {
fi
}
###############################################################################
+checkForWarnings() {
+ grep '\[WARNING\]' ${REPORTDIR}/${TASKNAME}-clean.txt > ${TEMPDIR}/${TASKNAME}-javacwarns-clean.txt
+ grep '\[WARNING\]' ${REPORTDIR}/${TASKNAME}-patch.txt > ${TEMPDIR}/${TASKNAME}-javacwarns-patch.txt
+ cleanWarns=`cat ${TEMPDIR}/${TASKNAME}-javacwarns-clean.txt | awk 'BEGIN {total = 0} {total += 1} END {print total}'`
+ patchWarns=`cat ${TEMPDIR}/${TASKNAME}-javacwarns-patch.txt | awk 'BEGIN {total = 0} {total += 1} END {print total}'`
+ newWarns=`expr $patchWarns - $cleanWarns`
+ if [[ $newWarns -le 0 ]] ; then
+ RAW_REPORT+=("+1 the patch does not seem to introduce new javac warnings")
+ newWarns=0
+ else
+ RAW_REPORT+=("-1 the patch seems to introduce $newWarns new javac warning(s)")
+ newWarns=1
+ fi
+}
+###############################################################################
+
parseArgs "$@"
case $OP in
pre)
- mvn clean test -DskipTests > ${REPORTDIR}/${TASKNAME}-clean.txt
+ mvn clean test -PtestPatchCompile -DskipTests > ${REPORTDIR}/${TASKNAME}-clean.txt
exit $?
;;
post)
- mvn clean test -DskipTests > ${REPORTDIR}/${TASKNAME}-patch.txt
+ mvn clean test -PtestPatchCompile -DskipTests > ${REPORTDIR}/${TASKNAME}-patch.txt
exit $?
;;
report)
- echo "+1 ${TASKNAME}" >> $SUMMARYFILE
+ RAW_REPORT=("+1 the patch compiles")
+ checkForWarnings
+ total=`expr 0 + $newWarns`
+ if [[ $total == 0 ]] ; then
+ echo "+1 ${TASKNAME}" >> $SUMMARYFILE
+ else
+ echo "-1 ${TASKNAME}" >> $SUMMARYFILE
+ fi
+ for line in "${RAW_REPORT[@]}" ; do
+ echo " ${line}" >> $SUMMARYFILE
+ done
;;
esac
View
25 pom.xml
@@ -848,6 +848,8 @@
<exclude>webapp/src/main/resources/.gitignore</exclude>
<exclude>**/target/**</exclude>
<exclude>**/build/**</exclude>
+ <exclude>.git/**</exclude>
+ <exclude>test-patch/**</exclude>
</excludes>
</configuration>
</plugin>
@@ -868,6 +870,29 @@
<oozie.test.forkMode>always</oozie.test.forkMode>
</properties>
</profile>
+ <profile>
+ <id>testPatchCompile</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <fork>true</fork>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArguments>
+ <Xlint/>
+ <Xmaxwarns>9999</Xmaxwarns>
+ </compilerArguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>

0 comments on commit 9d1a1ba

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