yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sek...@apache.org
Subject yetus git commit: YETUS-191. plugins that require external executables should verify those external executables exist.
Date Wed, 23 Dec 2015 19:57:16 GMT
Repository: yetus
Updated Branches:
  refs/heads/master d6a4e58a0 -> 5c8df77f2


YETUS-191. plugins that require external executables should verify those external executables
exist.

Signed-off-by: Kengo Seki <sekikn@apache.org>


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

Branch: refs/heads/master
Commit: 5c8df77f21393a3d401696c20ae50cc91b48b51c
Parents: d6a4e58
Author: Marco Zuehlke <mzuehlke@gmail.com>
Authored: Fri Dec 18 23:45:03 2015 +0100
Committer: Kengo Seki <sekikn@apache.org>
Committed: Thu Dec 24 04:55:38 2015 +0900

----------------------------------------------------------------------
 precommit/core.d/01-common.sh        | 30 ++++++++++++++++-
 precommit/core.d/docker.sh           |  3 +-
 precommit/test-patch.d/findbugs.sh   | 55 +++++++++++--------------------
 precommit/test-patch.d/perlcritic.sh | 20 +++++------
 precommit/test-patch.d/pylint.sh     | 20 +++++------
 precommit/test-patch.d/rubocop.sh    | 20 +++++------
 precommit/test-patch.d/ruby-lint.sh  | 19 +++++------
 precommit/test-patch.d/shellcheck.sh | 19 +++++------
 precommit/test-patch.d/xml.sh        | 12 ++++---
 precommit/test-patch.sh              |  2 +-
 10 files changed, 101 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/5c8df77f/precommit/core.d/01-common.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/01-common.sh b/precommit/core.d/01-common.sh
index 96b092c..a6eb257 100755
--- a/precommit/core.d/01-common.sh
+++ b/precommit/core.d/01-common.sh
@@ -511,4 +511,32 @@ function plugin_usage_output
   echo ""
   echo "${YETUS_USAGE_HEADER}"
   echo ""
-}
\ No newline at end of file
+}
+
+## @description  Verifies the existence of a command
+## @audience     private
+## @stability    evolving
+## @replaceable  no
+## @param        commandname
+## @param        commandpath
+## @return       0 = ok
+## @return       1 = error
+function verify_command
+{
+  local cmd_name="$1"
+  local cmd_path="$2"
+
+  if [[ -z ${cmd_path} ]]; then
+    yetus_error "executable for '${cmd_name}' was not specified."
+    return 1
+  fi
+  if [[ ! -f ${cmd_path} ]]; then
+    yetus_error "executable '${cmd_path}' for '${cmd_name}' does not exist."
+    return 1
+  fi
+  if [[ ! -x ${cmd_path} ]]; then
+    yetus_error "executable '${cmd_path}' for '${cmd_name}' is not executable."
+    return 1
+  fi
+  return 0
+}

http://git-wip-us.apache.org/repos/asf/yetus/blob/5c8df77f/precommit/core.d/docker.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/docker.sh b/precommit/core.d/docker.sh
index 0bad245..80ed919 100755
--- a/precommit/core.d/docker.sh
+++ b/precommit/core.d/docker.sh
@@ -115,8 +115,7 @@ function docker_exeverify
     DOCKERCMD="${pathdocker}"
   fi
 
-  if [[ ! -x "${DOCKERCMD}" ]];then
-    yetus_error "Docker command ${DOCKERCMD} is not executable."
+  if ! verify_command "Docker" "${DOCKERCMD}"; then
     return 1
   fi
 

http://git-wip-us.apache.org/repos/asf/yetus/blob/5c8df77f/precommit/test-patch.d/findbugs.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/findbugs.sh b/precommit/test-patch.d/findbugs.sh
index da0328b..2f77811 100755
--- a/precommit/test-patch.d/findbugs.sh
+++ b/precommit/test-patch.d/findbugs.sh
@@ -20,19 +20,6 @@ FINDBUGS_WARNINGS_FAIL_PRECHECK=false
 
 add_test_type findbugs
 
-function findbugs_filefilter
-{
-  local filename=$1
-
-  if [[ ${BUILDTOOL} == maven
-    || ${BUILDTOOL} == ant ]]; then
-    if [[ ${filename} =~ \.java$
-      || ${filename} =~ (^|/)findbugs-exclude.xml$ ]]; then
-      add_test findbugs
-    fi
-  fi
-}
-
 function findbugs_usage
 {
   yetus_add_option "--findbugs-home=<path>" "Findbugs home directory (default \${FINDBUGS_HOME})"
@@ -55,13 +42,20 @@ function findbugs_parse_args
   done
 }
 
-## @description  are the needed bits for findbugs present?
-## @audience     private
-## @stability    evolving
-## @replaceable  no
-## @return       0 findbugs will work for our use
-## @return       1 findbugs is missing some component
-function findbugs_is_installed
+function findbugs_filefilter
+{
+  local filename=$1
+
+  if [[ ${BUILDTOOL} == maven
+    || ${BUILDTOOL} == ant ]]; then
+    if [[ ${filename} =~ \.java$
+      || ${filename} =~ (^|/)findbugs-exclude.xml$ ]]; then
+      add_test findbugs
+    fi
+  fi
+}
+
+function findbugs_precheck
 {
   declare exec
   declare status=0
@@ -71,12 +65,14 @@ function findbugs_is_installed
               convertXmlToText \
               filterBugs \
               setBugDatabaseInfo; do
-    if [[ ! -x "${FINDBUGS_HOME}/bin/${exec}"  ]]; then
-      yetus_error "ERROR: ${FINDBUGS_HOME}/bin/${exec} is not executable."
+    if ! verify_command "${exec}" "${FINDBUGS_HOME}/bin/${exec}"; then
       status=1
     fi
   done
-  return ${status}
+  if [[ ${status} == 1 ]]; then
+    add_vote_table 0 findbugs "Findbugs executables are not available."
+    delete_test findbugs
+  fi
 }
 
 ## @description  Run the maven findbugs plugin and record found issues in a bug database
@@ -192,17 +188,10 @@ function findbugs_preapply
   declare msg
 
   verify_needed_test findbugs
-
   if [[ $? == 0 ]]; then
     return 0
   fi
 
-  findbugs_is_installed
-  if [[ $? != 0 ]]; then
-    add_vote_table 0 findbugs "findbugs executables are not available."
-    return 0
-  fi
-
   big_console_header "Pre-patch findbugs detection"
 
   findbugs_runner branch
@@ -277,16 +266,10 @@ function findbugs_postinstall
   local savestop
 
   verify_needed_test findbugs
-
   if [[ $? == 0 ]]; then
     return 0
   fi
 
-  findbugs_is_installed
-  if [[ $? != 0 ]]; then
-    return 0
-  fi
-
   big_console_header "Patch findbugs detection"
 
   findbugs_runner patch

http://git-wip-us.apache.org/repos/asf/yetus/blob/5c8df77f/precommit/test-patch.d/perlcritic.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/perlcritic.sh b/precommit/test-patch.d/perlcritic.sh
index a099fd6..d97326d 100755
--- a/precommit/test-patch.d/perlcritic.sh
+++ b/precommit/test-patch.d/perlcritic.sh
@@ -47,6 +47,15 @@ function perlcritic_filefilter
   fi
 }
 
+function perlcritic_precheck
+{
+  if ! verify_command "Perl::Critic" "${PERLCRITIC}"; then
+    add_vote_table 0 perlcritic "Perl::Critic was not available."
+    delete_test perlcritic
+  fi
+}
+
+
 function perlcritic_preapply
 {
   local i
@@ -58,11 +67,6 @@ function perlcritic_preapply
 
   big_console_header "Perl::Critic plugin: prepatch"
 
-  if [[ ! -x ${PERLCRITIC} ]]; then
-    yetus_error "${PERLCRITIC} does not exist."
-    return 0
-  fi
-
   start_clock
 
   echo "Running perlcritic against modified perl scripts/modules."
@@ -92,12 +96,6 @@ function perlcritic_postapply
 
   big_console_header "Perl::Critic plugin: postpatch"
 
-  if [[ ! -x ${PERLCRITIC} ]]; then
-    yetus_error "${PERLCRITIC} is not available."
-    add_vote_table 0 perlcritic "Perl::Critic was not available."
-    return 0
-  fi
-
   start_clock
 
   # add our previous elapsed to our new timer

http://git-wip-us.apache.org/repos/asf/yetus/blob/5c8df77f/precommit/test-patch.d/pylint.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/pylint.sh b/precommit/test-patch.d/pylint.sh
index 5706d23..3e48197 100755
--- a/precommit/test-patch.d/pylint.sh
+++ b/precommit/test-patch.d/pylint.sh
@@ -52,6 +52,15 @@ function pylint_filefilter
   fi
 }
 
+function pylint_precheck
+{
+  if ! verify_command "Pylint" "${PYLINT}"; then
+    add_vote_table 0 pylint "Pylint was not available."
+    delete_test pylint
+  fi
+}
+
+
 function pylint_preapply
 {
   local i
@@ -65,11 +74,6 @@ function pylint_preapply
 
   big_console_header "pylint plugin: prepatch"
 
-  if [[ ! -x ${PYLINT} ]]; then
-    yetus_error "${PYLINT} does not exist."
-    return 0
-  fi
-
   start_clock
 
   echo "Running pylint against modified python scripts."
@@ -111,12 +115,6 @@ function pylint_postapply
 
   big_console_header "pylint plugin: postpatch"
 
-  if [[ ! -x ${PYLINT} ]]; then
-    yetus_error "${PYLINT} is not available."
-    add_vote_table 0 pylint "Pylint was not available."
-    return 0
-  fi
-
   start_clock
 
   # add our previous elapsed to our new timer

http://git-wip-us.apache.org/repos/asf/yetus/blob/5c8df77f/precommit/test-patch.d/rubocop.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/rubocop.sh b/precommit/test-patch.d/rubocop.sh
index 36a5e5d..ddea0ca 100755
--- a/precommit/test-patch.d/rubocop.sh
+++ b/precommit/test-patch.d/rubocop.sh
@@ -47,6 +47,15 @@ function rubocop_filefilter
   fi
 }
 
+function rubocop_precheck
+{
+  if ! verify_command rubocop "${RUBOCOP}"; then
+    add_vote_table 0 rubocop "rubocop was not available."
+    delete_test rubocop
+  fi
+}
+
+
 function rubocop_preapply
 {
   local i
@@ -58,11 +67,6 @@ function rubocop_preapply
 
   big_console_header "rubocop plugin: prepatch"
 
-  if [[ ! -x ${RUBOCOP} ]]; then
-    yetus_error "${RUBOCOP} does not exist."
-    return 0
-  fi
-
   start_clock
 
   echo "Running rubocop against modified ruby scripts."
@@ -92,12 +96,6 @@ function rubocop_postapply
 
   big_console_header "rubocop plugin: postpatch"
 
-  if [[ ! -x ${RUBOCOP} ]]; then
-    yetus_error "${RUBOCOP} is not available."
-    add_vote_table 0 rubocop "Rubocop was not available."
-    return 0
-  fi
-
   start_clock
 
   # add our previous elapsed to our new timer

http://git-wip-us.apache.org/repos/asf/yetus/blob/5c8df77f/precommit/test-patch.d/ruby-lint.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/ruby-lint.sh b/precommit/test-patch.d/ruby-lint.sh
index 3246a6a..862c5b4 100755
--- a/precommit/test-patch.d/ruby-lint.sh
+++ b/precommit/test-patch.d/ruby-lint.sh
@@ -47,6 +47,14 @@ function ruby_lint_filefilter
   fi
 }
 
+function ruby_lint_precheck
+{
+  if ! verify_command "Ruby-lint" "${RUBY_LINT}"; then
+    add_vote_table 0 ruby-lint "Ruby-lint was not available."
+    delete_test ruby_lint
+  fi
+}
+
 function ruby_lint_preapply
 {
   local i
@@ -58,11 +66,6 @@ function ruby_lint_preapply
 
   big_console_header "ruby-lint plugin: prepatch"
 
-  if [[ ! -x ${RUBY_LINT} ]]; then
-    yetus_error "${RUBY_LINT} does not exist."
-    return 0
-  fi
-
   start_clock
 
   echo "Running ruby-lint against modified ruby scripts."
@@ -92,12 +95,6 @@ function ruby_lint_postapply
 
   big_console_header "ruby-lint plugin: postpatch"
 
-  if [[ ! -x ${RUBY_LINT} ]]; then
-    yetus_error "${RUBY_LINT} is not available."
-    add_vote_table 0 ruby-lint "Ruby-lint was not available."
-    return 0
-  fi
-
   start_clock
 
   # add our previous elapsed to our new timer

http://git-wip-us.apache.org/repos/asf/yetus/blob/5c8df77f/precommit/test-patch.d/shellcheck.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/shellcheck.sh b/precommit/test-patch.d/shellcheck.sh
index d50d212..9043acb 100755
--- a/precommit/test-patch.d/shellcheck.sh
+++ b/precommit/test-patch.d/shellcheck.sh
@@ -38,6 +38,14 @@ function shellcheck_filefilter
   fi
 }
 
+function shellcheck_precheck
+{
+  if ! verify_command "shellcheck" "${SHELLCHECK}"; then
+    add_vote_table 0 shellcheck "Shellcheck was not available."
+    delete_test shellcheck
+  fi
+}
+
 function shellcheck_private_findbash
 {
   local i
@@ -72,11 +80,6 @@ function shellcheck_preapply
 
   big_console_header "shellcheck plugin: prepatch"
 
-  if [[ ! -x "${SHELLCHECK}" ]]; then
-    yetus_error "shellcheck is not available."
-    return 0
-  fi
-
   start_clock
 
   echo "Running shellcheck against all identifiable shell scripts"
@@ -107,12 +110,6 @@ function shellcheck_postapply
 
   big_console_header "shellcheck plugin: postpatch"
 
-  if [[ ! -x "${SHELLCHECK}" ]]; then
-    yetus_error "shellcheck is not available."
-    add_vote_table 0 shellcheck "Shellcheck was not available."
-    return 0
-  fi
-
   start_clock
 
   # add our previous elapsed to our new timer

http://git-wip-us.apache.org/repos/asf/yetus/blob/5c8df77f/precommit/test-patch.d/xml.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/xml.sh b/precommit/test-patch.d/xml.sh
index b04a2f3..4aba556 100755
--- a/precommit/test-patch.d/xml.sh
+++ b/precommit/test-patch.d/xml.sh
@@ -25,6 +25,14 @@ function xml_filefilter
   fi
 }
 
+function xml_precheck
+{
+  if ! verify_command "jrunscript" "${JAVA_HOME}/bin/jrunscript"; then
+    add_vote_table 0 xml "jrunscript was not available."
+    delete_test xml
+  fi
+}
+
 function xml_postcompile
 {
   declare repostatus=$1
@@ -44,10 +52,6 @@ function xml_postcompile
   big_console_header "Checking if XML files are well-formed"
 
   js="${JAVA_HOME}/bin/jrunscript"
-  if [[ ! -x ${js} ]]; then
-    yetus_error "${js} does not exist"
-    return 0
-  fi
 
   start_clock
 

http://git-wip-us.apache.org/repos/asf/yetus/blob/5c8df77f/precommit/test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.sh b/precommit/test-patch.sh
index 4eca16a..e992d0f 100755
--- a/precommit/test-patch.sh
+++ b/precommit/test-patch.sh
@@ -2608,7 +2608,7 @@ function prechecks
   declare plugin
   declare result=0
 
-  for plugin in ${BUILDTOOL} ${NEEDEDTESTS} ${TESTFORMATS}; do
+  for plugin in ${BUILDTOOL} ${NEEDED_TESTS} ${TESTFORMATS}; do
     verify_patchdir_still_exists
 
     if declare -f ${plugin}_precheck >/dev/null 2>&1; then


Mime
View raw message