HADOOP-12286. test-patch pylint plugin should support indent-string option 
(Kengo Seki via aw)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/fd4424b6
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/fd4424b6
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/fd4424b6

Branch: refs/heads/HADOOP-12111
Commit: fd4424b6a7899358ff9584b888d1672920e5636d
Parents: f3bc13c
Author: Allen Wittenauer <a...@apache.org>
Authored: Mon Aug 3 10:34:01 2015 -0700
Committer: Allen Wittenauer <a...@apache.org>
Committed: Mon Aug 3 10:34:01 2015 -0700

----------------------------------------------------------------------
 dev-support/personality/hadoop.sh  |  2 ++
 dev-support/test-patch.d/pylint.sh | 19 +++++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/fd4424b6/dev-support/personality/hadoop.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/hadoop.sh 
b/dev-support/personality/hadoop.sh
index 3d6e3fa..60dbb3d 100755
--- a/dev-support/personality/hadoop.sh
+++ b/dev-support/personality/hadoop.sh
@@ -22,6 +22,8 @@ PATCH_BRANCH_DEFAULT=trunk
 HOW_TO_CONTRIBUTE="https://wiki.apache.org/hadoop/HowToContribute";
 #shellcheck disable=SC2034
 ISSUE_RE='^(HADOOP|YARN|MAPREDUCE|HDFS)-[0-9]+$'
+#shellcheck disable=SC2034
+PYLINT_OPTIONS="--indent-string='  '"
 
 HADOOP_MODULES=""
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/fd4424b6/dev-support/test-patch.d/pylint.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/pylint.sh 
b/dev-support/test-patch.d/pylint.sh
index faa8136..ebac162 100755
--- a/dev-support/test-patch.d/pylint.sh
+++ b/dev-support/test-patch.d/pylint.sh
@@ -19,11 +19,13 @@ add_plugin pylint
 PYLINT_TIMER=0
 
 PYLINT=${PYLINT:-$(which pylint 2>/dev/null)}
+PYLINT_OPTIONS=${PYLINT_OPTIONS:-}
 
 function pylint_usage
 {
   echo "Pylint specific:"
-  echo "--pylint=<path> path to pylint executable"
+  echo "--pylint=<path>         path to pylint executable"
+  echo "--pylint-options=<path> pylint options other than output-format and 
reports"
 }
 
 function pylint_parse_args
@@ -35,6 +37,9 @@ function pylint_parse_args
     --pylint=*)
       PYLINT=${i#*=}
     ;;
+    --pylint-options=*)
+      PYLINT_OPTIONS=${i#*=}
+    ;;
     esac
   done
 }
@@ -70,7 +75,8 @@ function pylint_preapply
   pushd "${BASEDIR}" >/dev/null
   for i in ${CHANGED_FILES}; do
     if [[ ${i} =~ \.py$ && -f ${i} ]]; then
-      ${PYLINT} --indent-string="  " --output-format=parseable --reports=n 
"${i}" 2>/dev/null |
+      # shellcheck disable=SC2086
+      eval "${PYLINT} ${PYLINT_OPTIONS} --output-format=parseable --reports=n 
${i}" 2>/dev/null |
       ${AWK} '1<NR' >> "${PATCH_DIR}/branch-pylint-result.txt"
     fi
   done
@@ -111,7 +117,8 @@ function pylint_postapply
   pushd "${BASEDIR}" >/dev/null
   for i in ${CHANGED_FILES}; do
     if [[ ${i} =~ \.py$ && -f ${i} ]]; then
-      ${PYLINT} --indent-string="  " --output-format=parseable --reports=n 
"${i}" 2>/dev/null |
+      # shellcheck disable=SC2086
+      eval "${PYLINT} ${PYLINT_OPTIONS} --output-format=parseable --reports=n 
${i}" 2>/dev/null |
       ${AWK} '1<NR' >> "${PATCH_DIR}/patch-pylint-result.txt"
     fi
   done
@@ -122,14 +129,14 @@ function pylint_postapply
   add_footer_table pylint "v${PYLINT_VERSION%,}"
 
   calcdiffs "${PATCH_DIR}/branch-pylint-result.txt" 
"${PATCH_DIR}/patch-pylint-result.txt" > "${PATCH_DIR}/diff-patch-pylint.txt"
-  diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 2<NF {sum+=1} END {print sum}' 
"${PATCH_DIR}/diff-patch-pylint.txt")
+  diffPostpatch=$(${AWK} 'BEGIN {sum=0} 2<NF {sum+=1} END {print sum}' 
"${PATCH_DIR}/diff-patch-pylint.txt")
 
   if [[ ${diffPostpatch} -gt 0 ]] ; then
     # shellcheck disable=SC2016
-    numPrepatch=$(${AWK} -F: 'BEGIN {sum=0} 2<NF {sum+=1} END {print sum}' 
"${PATCH_DIR}/branch-pylint-result.txt")
+    numPrepatch=$(${AWK} 'BEGIN {sum=0} 2<NF {sum+=1} END {print sum}' 
"${PATCH_DIR}/branch-pylint-result.txt")
 
     # shellcheck disable=SC2016
-    numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 2<NF {sum+=1} END {print sum}' 
"${PATCH_DIR}/patch-pylint-result.txt")
+    numPostpatch=$(${AWK} 'BEGIN {sum=0} 2<NF {sum+=1} END {print sum}' 
"${PATCH_DIR}/patch-pylint-result.txt")
 
     add_vote_table -1 pylint "The applied patch generated "\
       "${diffPostpatch} new pylint issues (total was ${numPrepatch}, now 
${numPostpatch})."

Reply via email to