You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by tu...@apache.org on 2012/08/17 18:37:19 UTC

svn commit: r1374348 - in /incubator/oozie/trunk/bin: test-patch test-patch-05-no-authors test-patch-05-patch-raw-analysis

Author: tucu
Date: Fri Aug 17 16:37:19 2012
New Revision: 1374348

URL: http://svn.apache.org/viewvc?rev=1374348&view=rev
Log:
Improvements to test-patch script (tucu)

Added:
    incubator/oozie/trunk/bin/test-patch-05-patch-raw-analysis
Removed:
    incubator/oozie/trunk/bin/test-patch-05-no-authors
Modified:
    incubator/oozie/trunk/bin/test-patch

Modified: incubator/oozie/trunk/bin/test-patch
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/bin/test-patch?rev=1374348&r1=1374347&r2=1374348&view=diff
==============================================================================
--- incubator/oozie/trunk/bin/test-patch (original)
+++ incubator/oozie/trunk/bin/test-patch Fri Aug 17 16:37:19 2012
@@ -155,7 +155,7 @@ run() {
       outputFile="`basename $1`-$2.out"
       bash ${DEBUG} $1 --op=$2 --tempdir=${TEMPDIR} --reportdir=${REPORTDIR} --summaryfile=${SUMMARYFILE} --patchfile=${PATCHFILE} &> ${TEMPDIR}/${outputFile}
       if [[ $? != 0 ]] ; then
-        echo "  Failure, check for details ${TEMPDIR}/${task}-$2.out"
+        echo "  Failure, check for details ${TEMPDIR}/${outputFile}"
         echo
         cleanupAndExit 1
       fi

Added: incubator/oozie/trunk/bin/test-patch-05-patch-raw-analysis
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/bin/test-patch-05-patch-raw-analysis?rev=1374348&view=auto
==============================================================================
--- incubator/oozie/trunk/bin/test-patch-05-patch-raw-analysis (added)
+++ incubator/oozie/trunk/bin/test-patch-05-patch-raw-analysis Fri Aug 17 16:37:19 2012
@@ -0,0 +1,140 @@
+#!/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="RAW_PATCH_ANALYSIS"
+OP=""
+TEMPDIR=""
+REPORTDIR=""
+SUMMARYFILE=""
+PATCHFILE=""
+
+###############################################################################
+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#*=}
+      ;;
+    --patchfile=*)
+      PATCHFILE=${i#*=}
+      ;;
+    *)
+      echo "Invalid option"
+      echo
+      printUsage
+      cleanupAndExit 1
+      ;;
+    esac
+  done
+  if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" || "${PATCHFILE}" == "" ]] ; 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
+}
+###############################################################################
+checkNoAuthors() {
+  authorTags=`grep "^+ " ${PATCHFILE} | grep -c -i -e ".*\*.* @author"`
+  if [[ ${authorTags} != 0 ]] ; then
+    RAW_REPORT+=("-1 the patch seems to contain ${authorTags} line(s) with @author tags")
+  else
+    RAW_REPORT+=("+1 the patch does not introduce any @author tags")
+  fi
+}
+###############################################################################
+checkNoTabs() {
+  tabs=`grep "^+ " ${PATCHFILE} | grep -c -P "\t"`
+  if [[ ${tabs} != 0 ]] ; then
+    RAW_REPORT+=("-1 the patch contains ${tabs} line(s) with tabs")
+  else
+    RAW_REPORT+=("+1 the patch does not introduce any tabs")
+  fi
+}
+###############################################################################
+checkNoTrailingSpaces() {
+  trailingSpaces=`grep "^+ " ${PATCHFILE} | grep -c -e " $"`
+  if [[ ${trailingSpaces} != 0 ]] ; then
+    RAW_REPORT+=("-1 the patch contains ${trailingSpaces} line(s) with trailing spaces")
+  else
+    RAW_REPORT+=("+1 the patch does not introduce any trailing spaces")
+  fi
+}
+###############################################################################
+checkLinesLength() {
+  longLines=`grep "^+ " ${PATCHFILE} | awk 'BEGIN{count=0}{if ( length > 132 ) { count=count+1} }END{ print count}'`
+  if [[ ${longLines} != 0 ]] ; then
+    RAW_REPORT+=("-1 the patch contains ${longLines} line(s) longer than 132 characters")
+  else
+    RAW_REPORT+=("+1 the patch does not introduce any line longer than 132")
+  fi
+}
+###############################################################################
+
+parseArgs "$@"
+
+case $OP in
+  pre)
+    ;;
+  post)
+    ;;
+  report)
+    RAW_REPORT=()
+    checkNoAuthors
+    checkNoTabs
+    checkNoTrailingSpaces
+    checkLinesLength
+    total=`expr $authorTags + $tabs + $trailingSpaces + $longLines`
+    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
+
+exit 0