yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject yetus git commit: YETUS-40. patch file confuses test-patch (date format problems) (aw)
Date Wed, 07 Oct 2015 17:28:38 GMT
Repository: yetus
Updated Branches:
  refs/heads/master 142dc995f -> 19fe8bc87


YETUS-40. patch file confuses test-patch (date format problems) (aw)


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

Branch: refs/heads/master
Commit: 19fe8bc875c2d9109f97e3ca467f871f19fd821d
Parents: 142dc99
Author: Allen Wittenauer <aw@apache.org>
Authored: Wed Oct 7 10:09:13 2015 -0700
Committer: Allen Wittenauer <aw@apache.org>
Committed: Wed Oct 7 10:27:34 2015 -0700

----------------------------------------------------------------------
 dev-support/core.d/common.sh                    | 597 +++++++++++++++++++
 dev-support/smart-apply-patch.sh                | 495 +++------------
 .../test-patch-docker/test-patch-docker.sh      |   4 +-
 dev-support/test-patch.sh                       | 423 ++-----------
 4 files changed, 700 insertions(+), 819 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/19fe8bc8/dev-support/core.d/common.sh
----------------------------------------------------------------------
diff --git a/dev-support/core.d/common.sh b/dev-support/core.d/common.sh
new file mode 100755
index 0000000..bc13b8a
--- /dev/null
+++ b/dev-support/core.d/common.sh
@@ -0,0 +1,597 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+## @description  Setup the default global variables
+## @audience     public
+## @stability    stable
+## @replaceable  no
+function common_defaults
+{
+  #shellcheck disable=SC2034
+  BASEDIR=$(pwd)
+  LOAD_SYSTEM_PLUGINS=true
+  #shellcheck disable=SC2034
+  JENKINS=false
+  #shellcheck disable=SC2034
+  OFFLINE=false
+  OSTYPE=$(uname -s)
+  #shellcheck disable=SC2034
+  PATCH_BRANCH=""
+  PATCH_BRANCH_DEFAULT="master"
+  #shellcheck disable=SC2034
+  PATCH_DRYRUNMODE=false
+  PATCH_DIR=/tmp
+  while [[ -e ${PATCH_DIR} ]]; do
+    PATCH_DIR=/tmp/yetus-${RANDOM}.${RANDOM}
+  done
+  PATCH_METHOD=""
+  PATCH_METHODS=("gitapply" "patchcmd")
+  PATCH_LEVEL=0
+  PROJECT_NAME=yetus
+  RESULT=0
+  USER_PLUGIN_DIR=""
+  #shellcheck disable=SC2034
+  YETUS_SHELL_SCRIPT_DEBUG=false
+
+  # Solaris needs POSIX and GNU, not SVID
+  case ${OSTYPE} in
+    SunOS)
+      AWK=${AWK:-/usr/xpg4/bin/awk}
+      CURL=${CURL:-curl}
+      DIFF=${DIFF:-/usr/gnu/bin/diff}
+      FILE=${FILE:-file}
+      GIT=${GIT:-git}
+      GREP=${GREP:-/usr/xpg4/bin/grep}
+      PATCH=${PATCH:-/usr/gnu/bin/patch}
+      SED=${SED:-/usr/xpg4/bin/sed}
+    ;;
+    *)
+      AWK=${AWK:-awk}
+      CURL=${CURL:-curl}
+      DIFF=${DIFF:-diff}
+      FILE=${FILE:-file}
+      GIT=${GIT:-git}
+      GREP=${GREP:-grep}
+      PATCH=${PATCH:-patch}
+      SED=${SED:-sed}
+    ;;
+  esac
+}
+
+## @description  Interpret the common command line parameters used by test-patch,
+## @description  smart-apply-patch, and the bug system plugins
+## @audience     private
+## @stability    stable
+## @replaceable  no
+## @params       $@
+## @return       May exit on failure
+function common_args
+{
+  declare i
+
+  for i in "$@"; do
+    case ${i} in
+      --awk-cmd=*)
+        AWK=${i#*=}
+      ;;
+      --basedir=*)
+        #shellcheck disable=SC2034
+        BASEDIR=${i#*=}
+      ;;
+      --branch=*)
+        #shellcheck disable=SC2034
+        PATCH_BRANCH=${i#*=}
+      ;;
+      --branch-default=*)
+        #shellcheck disable=SC2034
+        PATCH_BRANCH_DEFAULT=${i#*=}
+      ;;
+      --curl-cmd=*)
+        CURL=${i#*=}
+      ;;
+      --debug)
+        #shellcheck disable=SC2034
+        YETUS_SHELL_SCRIPT_DEBUG=true
+      ;;
+      --diff-cmd=*)
+        DIFF=${i#*=}
+      ;;
+      --file-cmd=*)
+        FILE=${i#*=}
+      ;;
+      --git-cmd=*)
+        GIT=${i#*=}
+      ;;
+      --grep-cmd=*)
+        GREP=${i#*=}
+      ;;
+      --help|-help|-h|help|--h|--\?|-\?|\?)
+        yetus_usage
+        exit 0
+      ;;
+      --modulelist=*)
+        USER_MODULE_LIST=${i#*=}
+        USER_MODULE_LIST=${USER_MODULE_LIST//,/ }
+        yetus_debug "Manually forcing modules ${USER_MODULE_LIST}"
+      ;;
+      --offline)
+        #shellcheck disable=SC2034
+        OFFLINE=true
+      ;;
+      --patch-cmd=*)
+        PATCH=${i#*=}
+      ;;
+      --patch-dir=*)
+        PATCH_DIR=${i#*=}
+      ;;
+      --plugins=*)
+        USER_PLUGIN_DIR=${i#*=}
+      ;;
+      --project=*)
+        PROJECT_NAME=${i#*=}
+      ;;
+      --skip-system-plugins)
+        LOAD_SYSTEM_PLUGINS=false
+      ;;
+      --sed-cmd=*)
+        SED=${i#*=}
+      ;;
+      *)
+      ;;
+    esac
+  done
+}
+
+## @description  Print a message to stderr
+## @audience     public
+## @stability    stable
+## @replaceable  no
+## @param        string
+function yetus_error
+{
+  echo "$*" 1>&2
+}
+
+## @description  Print a message to stderr if --debug is turned on
+## @audience     public
+## @stability    stable
+## @replaceable  no
+## @param        string
+function yetus_debug
+{
+  if [[ -n "${YETUS_SHELL_SCRIPT_DEBUG}" ]]; then
+    echo "[$(date) DEBUG]: $*" 1>&2
+  fi
+}
+
+## @description  run the command, sending stdout and stderr to the given filename
+## @audience     public
+## @stability    stable
+## @param        filename
+## @param        command
+## @param        [..]
+## @replaceable  no
+## @returns      $?
+function yetus_run_and_redirect
+{
+  declare logfile=$1
+  shift
+
+  # to the log
+  {
+    date
+    echo "cd $(pwd)"
+    echo "${*}"
+  } >> "${logfile}"
+  # run the actual command
+  "${@}" >> "${logfile}" 2>&1
+}
+
+## @description Given a possible patch file, guess if it's a patch file
+## @description only using the more intense verify if we really need to
+## @audience private
+## @stability evolving
+## @param path to patch file to test
+## @return 0 we think it's a patch file
+## @return 1 we think it's not a patch file
+function guess_patch_file
+{
+  declare patch=$1
+  declare fileOutput
+
+  if [[ ! -f ${patch} ]]; then
+    return 1
+  fi
+
+  yetus_debug "Trying to guess if ${patch} is a patch file."
+  fileOutput=$("${FILE}" "${patch}")
+  if [[ $fileOutput =~ \ diff\  ]]; then
+    yetus_debug "file magic says it's a diff."
+    return 0
+  fi
+
+  fileOutput=$(head -n 1 "${patch}" | "${GREP}" -E "^(From [a-z0-9]* Mon Sep 17 00:00:00 2001)|(diff .*)|(Index: .*)$")
+  if [[ $? == 0 ]]; then
+    yetus_debug "first line looks like a patch file."
+    return 0
+  fi
+
+  patchfile_dryrun_driver "${patch}"
+}
+
+## @description  Given ${PATCH_OR_ISSUE}, determine what type of patch file is in use,
+## @description  and do the necessary work to place it into ${PATCH_DIR}/patch.
+## @audience     private
+## @stability    evolving
+## @replaceable  no
+## @return       0 on success
+## @return       1 on failure, may exit
+function locate_patch
+{
+  declare bugsys
+  declare patchfile=""
+  declare gotit=false
+
+  yetus_debug "locate patch"
+
+  # it's a declarely provided file
+  if [[ -f ${PATCH_OR_ISSUE} ]]; then
+    patchfile="${PATCH_OR_ISSUE}"
+  else
+    # run through the bug systems.  maybe they know?
+    for bugsys in ${BUGSYSTEMS}; do
+      if declare -f ${bugsys}_locate_patch >/dev/null 2>&1; then
+        "${bugsys}_locate_patch" "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
+        if [[ $? == 0 ]]; then
+          gotit=true
+        fi
+      fi
+    done
+
+    # ok, none of the bug systems know. let's see how smart we are
+    if [[ ${gotit} == false ]]; then
+      generic_locate_patch "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
+      if [[ $? != 0 ]]; then
+        yetus_error "ERROR: Unsure how to process ${PATCH_OR_ISSUE}."
+        cleanup_and_exit 1
+      fi
+    fi
+  fi
+
+  if [[ ! -f "${PATCH_DIR}/patch"
+      && -f "${patchfile}" ]]; then
+    cp "${patchfile}" "${PATCH_DIR}/patch"
+    if [[ $? == 0 ]] ; then
+      echo "Patch file ${patchfile} copied to ${PATCH_DIR}"
+    else
+      yetus_error "ERROR: Could not copy ${patchfile} to ${PATCH_DIR}"
+      cleanup_and_exit 1
+    fi
+  fi
+}
+
+## @description  Let plugins also get a copy of the arguments
+## @audience     private
+## @stability    evolving
+## @replaceable  no
+function parse_args_plugins
+{
+  for plugin in ${PLUGINS} ${BUGSYSTEMS} ${TESTFORMATS} ${BUILDTOOLS}; do
+    if declare -f ${plugin}_parse_args >/dev/null 2>&1; then
+      yetus_debug "Running ${plugin}_parse_args"
+      #shellcheck disable=SC2086
+      ${plugin}_parse_args "$@"
+      (( RESULT = RESULT + $? ))
+    fi
+  done
+
+  BUGCOMMENTS=${BUGCOMMENTS:-${BUGSYSTEMS}}
+  if [[ ! ${BUGCOMMENTS} =~ console ]]; then
+    BUGCOMMENTS="${BUGCOMMENTS} console"
+  fi
+
+  BUGLINECOMMENTS=${BUGLINECOMMENTS:-${BUGCOMMENTS}}
+}
+
+## @description  Let plugins also get a copy of the arguments
+## @audience     private
+## @stability    evolving
+## @replaceable  no
+function plugins_initialize
+{
+  declare plugin
+
+  for plugin in ${PLUGINS} ${BUGSYSTEMS} ${TESTFORMATS} ${BUILDTOOLS}; do
+    if declare -f ${plugin}_initialize >/dev/null 2>&1; then
+      yetus_debug "Running ${plugin}_initialize"
+      #shellcheck disable=SC2086
+      ${plugin}_initialize
+      (( RESULT = RESULT + $? ))
+    fi
+  done
+}
+
+## @description  Register test-patch.d plugins
+## @audience     public
+## @stability    stable
+## @replaceable  no
+function add_plugin
+{
+  PLUGINS="${PLUGINS} $1"
+}
+
+## @description  Register test-patch.d bugsystems
+## @audience     public
+## @stability    stable
+## @replaceable  no
+function add_bugsystem
+{
+  BUGSYSTEMS="${BUGSYSTEMS} $1"
+}
+
+## @description  Register test-patch.d test output formats
+## @audience     public
+## @stability    stable
+## @replaceable  no
+function add_test_format
+{
+  TESTFORMATS="${TESTFORMATS} $1"
+}
+
+## @description  Register test-patch.d build tools
+## @audience     public
+## @stability    stable
+## @replaceable  no
+function add_build_tool
+{
+  BUILDTOOLS="${BUILDTOOLS} $1"
+}
+
+## @description  Import content from test-patch.d and optionally
+## @description  from user provided plugin directory
+## @audience     private
+## @stability    evolving
+## @replaceable  no
+function importplugins
+{
+  declare i
+  declare files=()
+
+  if [[ ${LOAD_SYSTEM_PLUGINS} == "true" ]]; then
+    if [[ -d "${BINDIR}/test-patch.d" ]]; then
+      files=(${BINDIR}/test-patch.d/*.sh)
+    fi
+  fi
+
+  if [[ -n "${USER_PLUGIN_DIR}" && -d "${USER_PLUGIN_DIR}" ]]; then
+    yetus_debug "Loading user provided plugins from ${USER_PLUGIN_DIR}"
+    files=("${files[@]}" ${USER_PLUGIN_DIR}/*.sh)
+  fi
+
+  for i in "${files[@]}"; do
+    if [[ -f ${i} ]]; then
+      yetus_debug "Importing ${i}"
+      . "${i}"
+    fi
+  done
+
+  if [[ -z ${PERSONALITY}
+      && -f "${BINDIR}/personality/${PROJECT_NAME}.sh" ]]; then
+    PERSONALITY="${BINDIR}/personality/${PROJECT_NAME}.sh"
+  fi
+
+  if [[ -n ${PERSONALITY} ]]; then
+    if [[ ! -f ${PERSONALITY} ]]; then
+      if [[ -f "${BINDIR}/personality/${PROJECT_NAME}.sh" ]]; then
+        PERSONALITY="${BINDIR}/personality/${PROJECT_NAME}.sh"
+      else
+        yetus_debug "Can't find ${PERSONALITY} to import."
+        return
+      fi
+    fi
+    yetus_debug "Importing ${PERSONALITY}"
+    . "${PERSONALITY}"
+  fi
+}
+
+## @description  if patch-level zero, then verify we aren't
+## @description  just adding files
+## @audience     public
+## @stability    stable
+## @param        filename
+## @param        command
+## @param        [..]
+## @replaceable  no
+## @returns      $?
+function patchfile_verify_zero
+{
+  declare logfile=$1
+  shift
+  declare dir
+  declare changed_files1
+  declare changed_files2
+  declare $filename
+
+  # don't return /dev/null
+  # shellcheck disable=SC2016
+  changed_files1=$(${AWK} 'function p(s){if(s!~"^/dev/null"){print s}}
+    /^diff --git /   { p($3); p($4) }
+    /^(\+\+\+|---) / { p($2) }' "${PATCH_DIR}/patch" | sort -u)
+
+  # maybe we interpreted the patch wrong? check the log file
+  # shellcheck disable=SC2016
+  changed_files2=$(${GREP} -E '^[cC]heck' "${logfile}" \
+    | ${AWK} '{print $3}' \
+    | ${SED} -e 's,\.\.\.$,,g')
+
+  for filename in ${changed_files1} ${changed_files2}; do
+
+    # leading prefix = bad
+    if [[ ${filename} =~ ^(a|b)/ ]]; then
+      return 1
+    fi
+
+    # touching an existing file is proof enough
+    # that pl=0 is good
+    if [[ -f ${filename} ]]; then
+      return 0
+    fi
+
+    dir=$(dirname "${filename}" 2>/dev/null)
+    if [[ -n ${dir} && -d ${dir} ]]; then
+      return 0
+    fi
+  done
+
+  # ¯\_(ツ)_/¯ - no way for us to know, all new files with no prefix!
+  yetus_error "WARNING: Patch only adds files; using patch level ${PATCH_LEVEL}"
+  return 0
+}
+
+## @description git apply dryrun
+## @replaceable  no
+## @audience     private
+## @stability    evolving
+function gitapply_dryrun
+{
+  declare patchfile=$1
+  declare prefixsize=${2:-0}
+
+  while [[ ${prefixsize} -lt 4
+    && -z ${PATCH_METHOD} ]]; do
+    yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
+       "${GIT}" apply --binary -v --check "-p${prefixsize}" "${patchfile}"
+    if [[ $? == 0 ]]; then
+      PATCH_LEVEL=${prefixsize}
+      PATCH_METHOD=gitapply
+      break
+    fi
+    ((prefixsize=prefixsize+1))
+  done
+
+  if [[ ${prefixsize} -eq 0 ]]; then
+    patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"
+    if [[ $? != 0 ]]; then
+      PATCH_METHOD=""
+      PATCH_LEVEL=""
+      gitapply_dryrun "${patchfile}" 1
+    fi
+  fi
+}
+
+## @description  patch patch dryrun
+## @replaceable  no
+## @audience     private
+## @stability    evolving
+function patchcmd_dryrun
+{
+  declare patchfile=$1
+  declare prefixsize=${2:-0}
+
+  while [[ ${prefixsize} -lt 4
+    && -z ${PATCH_METHOD} ]]; do
+    yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
+      "${PATCH}" "-p${prefixsize}" -E --dry-run < "${patchfile}"
+    if [[ $? == 0 ]]; then
+      PATCH_LEVEL=${prefixsize}
+      PATCH_METHOD=patchcmd
+      break
+    fi
+    ((prefixsize=prefixsize+1))
+  done
+
+  if [[ ${prefixsize} -eq 0 ]]; then
+    patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"
+    if [[ $? != 0 ]]; then
+      PATCH_METHOD=""
+      PATCH_LEVEL=""
+      patchcmd_dryrun "${patchfile}" 1
+    fi
+  fi
+}
+
+## @description  driver for dryrun methods
+## @replaceable  no
+## @audience     private
+## @stability    evolving
+function patchfile_dryrun_driver
+{
+  declare patchfile=$1
+  declare method
+
+  for method in "${PATCH_METHODS[@]}"; do
+    if declare -f ${method}_dryrun >/dev/null; then
+      "${method}_dryrun" "${patchfile}"
+    fi
+    if [[ -n ${PATCH_METHOD} ]]; then
+      break
+    fi
+  done
+
+  if [[ -n ${PATCH_METHOD} ]]; then
+    return 0
+  fi
+  return 1
+}
+
+## @description  git patch apply
+## @replaceable  no
+## @audience     private
+## @stability    evolving
+function gitapply_apply
+{
+  declare patchfile=$1
+
+  echo "Applying the patch:"
+  yetus_run_and_redirect "${PATCH_DIR}/apply-patch-git-apply.log" \
+    "${GIT}" apply --binary -v --stat --apply "-p${PATCH_LEVEL}" "${patchfile}"
+  ${GREP} -v "^Checking" "${PATCH_DIR}/apply-patch-git-apply.log"
+}
+
+
+## @description  patch patch apply
+## @replaceable  no
+## @audience     private
+## @stability    evolving
+function patchcmd_apply
+{
+  declare patchfile=$1
+
+  echo "Applying the patch:"
+  yetus_run_and_redirect "${PATCH_DIR}/apply-patch-patch-apply.log" \
+    "${PATCH}" "-p${PATCH_LEVEL}" -E < "${patchfile}"
+  cat "${PATCH_DIR}/apply-patch-patch-apply.log"
+}
+
+## @description  driver for patch apply methods
+## @replaceable  no
+## @audience     private
+## @stability    evolving
+function patchfile_apply_driver
+{
+  declare patchfile=$1
+
+  if declare -f ${PATCH_METHOD}_apply >/dev/null; then
+    "${PATCH_METHOD}_apply" "${patchfile}"
+    if [[ $? -gt 0 ]]; then
+     return 1
+    fi
+  else
+    yetus_error "ERROR: Patching method ${PATCH_METHOD} does not have a way to apply patches!"
+    return 1
+  fi
+  return 0
+}

http://git-wip-us.apache.org/repos/asf/yetus/blob/19fe8bc8/dev-support/smart-apply-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/smart-apply-patch.sh b/dev-support/smart-apply-patch.sh
index e11a734..abd4513 100755
--- a/dev-support/smart-apply-patch.sh
+++ b/dev-support/smart-apply-patch.sh
@@ -20,28 +20,32 @@ if [[ -z "${BASH_VERSINFO}" ]] \
   exit 1
 fi
 
-RESULT=0
+this="${BASH_SOURCE-$0}"
+BINDIR=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
+#shellcheck disable=SC2034
+QATESTMODE=false
 
-## @description  Print a message to stderr
-## @audience     public
-## @stability    stable
-## @replaceable  no
-## @param        string
-function yetus_error
+. "${BINDIR}/core.d/common.sh"
+
+# dummy functions
+function add_vote_table
 {
-  echo "$*" 1>&2
+  true
 }
 
-## @description  Print a message to stderr if --debug is turned on
-## @audience     public
-## @stability    stable
-## @replaceable  no
-## @param        string
-function yetus_debug
+function add_footer_table
 {
-  if [[ -n "${YETUS_SHELL_SCRIPT_DEBUG}" ]]; then
-    echo "[$(date) DEBUG]: $*" 1>&2
-  fi
+  true
+}
+
+function big_console_header
+{
+  true
+}
+
+function add_test
+{
+  true
 }
 
 ## @description  Clean the filesystem as appropriate and then exit
@@ -53,7 +57,7 @@ function cleanup_and_exit
 {
   local result=$1
 
-  if [[ ${PATCH_DIR} =~ ^/tmp/apply-patch
+  if [[ ${PATCH_DIR} =~ ^/tmp/yetus
     && -d ${PATCH_DIR} ]]; then
     rm -rf "${PATCH_DIR}"
   fi
@@ -68,41 +72,7 @@ function cleanup_and_exit
 ## @replaceable  no
 function setup_defaults
 {
-  PATCHURL=""
-  OSTYPE=$(uname -s)
-
-  # Solaris needs POSIX, not SVID
-  case ${OSTYPE} in
-    SunOS)
-      AWK=${AWK:-/usr/xpg4/bin/awk}
-      SED=${SED:-/usr/xpg4/bin/sed}
-      CURL=${CURL:-curl}
-      GIT=${GIT:-git}
-      GREP=${GREP:-/usr/xpg4/bin/grep}
-      PATCH=${PATCH:-/usr/gnu/bin/patch}
-      DIFF=${DIFF:-/usr/gnu/bin/diff}
-      FILE=${FILE:-file}
-    ;;
-    *)
-      AWK=${AWK:-awk}
-      SED=${SED:-sed}
-      CURL=${CURL:-curl}
-      GIT=${GIT:-git}
-      GREP=${GREP:-grep}
-      PATCH=${PATCH:-patch}
-      DIFF=${DIFF:-diff}
-      FILE=${FILE:-file}
-    ;;
-  esac
-
-  DRYRUNMODE=false
-  PATCH_DIR=/tmp
-  while [[ -e ${PATCH_DIR} ]]; do
-    PATCH_DIR=/tmp/apply-patch-${RANDOM}.${RANDOM}
-  done
-  PATCHMODES=("git" "patch")
-  PATCHMODE=""
-  PATCHPREFIX=0
+  common_defaults
 }
 
 ## @description  Print the usage information
@@ -115,14 +85,34 @@ function yetus_usage
   echo
   echo "--debug                If set, then output some extra stuff to stderr"
   echo "--dry-run              Check for patch viability without applying"
-  echo "--patch-dir=<dir>      The directory for working and output files (default '/tmp/apply-patch-(random))"
-  echo
+  echo "--modulelist=<list>    Specify additional modules to test (comma delimited)"
+  echo "--offline              Avoid connecting to the Internet"
+  echo "--patch-dir=<dir>      The directory for working and output files (default '/tmp/yetus-(random))"
+  echo "--plugins=<dir>        A directory of user provided plugins. see test-patch.d for examples (default empty)"
+  echo "--skip-system-plugins  Do not load plugins from ${BINDIR}/test-patch.d"
+  echo ""
   echo "Shell binary overrides:"
+  echo "--awk-cmd=<cmd>        The 'awk' command to use (default 'awk')"
+  echo "--curl-cmd=<cmd>       The 'curl' command to use (default 'curl')"
+  echo "--diff-cmd=<cmd>       The GNU-compatible 'diff' command to use (default 'diff')"
   echo "--file-cmd=<cmd>       The 'file' command to use (default 'file')"
-  echo "--grep-cmd=<cmd>       The 'grep' command to use (default 'grep')"
   echo "--git-cmd=<cmd>        The 'git' command to use (default 'git')"
-  echo "--patch-cmd=<cmd>      The GNU-compatible 'patch' command to use (default 'patch')"
-  echo "--curl-cmd=<cmd>       The 'curl' command to use (default 'curl')"
+  echo "--grep-cmd=<cmd>       The 'grep' command to use (default 'grep')"
+  echo "--patch-cmd=<cmd>      The 'patch' command to use (default 'patch')"
+  echo "--sed-cmd=<cmd>        The 'sed' command to use (default 'sed')"
+
+  importplugins
+
+  unset TESTFORMATS
+  unset PLUGINS
+  unset BUILDTOOLS
+
+  for plugin in ${BUGSYSTEMS}; do
+    if declare -f ${plugin}_usage >/dev/null 2>&1; then
+      echo
+      "${plugin}_usage"
+    fi
+  done
 }
 
 ## @description  Interpret the command line parameters
@@ -135,35 +125,12 @@ function parse_args
 {
   local i
 
+  common_args "$@"
+
   for i in "$@"; do
     case ${i} in
-      --debug)
-        YETUS_SHELL_SCRIPT_DEBUG=true
-      ;;
       --dry-run)
-        DRYRUNMODE=true
-      ;;
-      --file-cmd=*)
-        FILE=${i#*=}
-      ;;
-      --git-cmd=*)
-        GIT=${i#*=}
-      ;;
-      --grep-cmd=*)
-        GREP=${i#*=}
-      ;;
-      --help|-help|-h|help|--h|--\?|-\?|\?)
-        yetus_usage
-        exit 0
-      ;;
-      --patch-cmd=*)
-        PATCH=${i#*=}
-      ;;
-      --patch-dir=*)
-        PATCH_DIR=${i#*=}
-      ;;
-      --curl-cmd=*)
-        CURL=${i#*=}
+        PATCH_DRYRUNMODE=true
       ;;
       --*)
         ## PATCH_OR_ISSUE can't be a --.  So this is probably
@@ -185,363 +152,35 @@ function parse_args
   fi
 }
 
-## @description Given a possible patch file, guess if it's a patch file without using smart-apply-patch
-## @audience private
-## @stability evolving
-## @param path to patch file to test
-## @return 0 we think it's a patch file
-## @return 1 we think it's not a patch file
-function guess_patch_file
-{
-  local patch=$1
-  local fileOutput
-
-  yetus_debug "Trying to guess is ${patch} is a patch file."
-  fileOutput=$("${FILE}" "${patch}")
-  if [[ $fileOutput =~ \ diff\  ]]; then
-    yetus_debug "file magic says it's a diff."
-    return 0
-  fi
-  fileOutput=$(head -n 1 "${patch}" | "${GREP}" -E "^(From [a-z0-9]* Mon Sep 17 00:00:00 2001)|(diff .*)|(Index: .*)$")
-  if [[ $? == 0 ]]; then
-    yetus_debug "first line looks like a patch file."
-    return 0
-  fi
-  return 1
-}
-
-## @description  Given ${PATCH_ISSUE}, determine what type of patch file is in use, and do the
-## @description  necessary work to place it into ${PATCH_DIR}/patch.
-## @audience     private
-## @stability    evolving
-## @replaceable  no
-## @return       0 on success
-## @return       1 on failure, may exit
-function locate_patch
-{
-  local notSureIfPatch=false
-  yetus_debug "locate patch"
-
-  # Allow passing "-" for stdin patches
-  if [[ ${PATCH_OR_ISSUE} == - ]]; then
-    PATCH_FILE="${PATCH_DIR}/patch"
-    cat /dev/fd/0 > "${PATCH_FILE}"
-  elif [[ -f ${PATCH_OR_ISSUE} ]]; then
-    PATCH_FILE="${PATCH_OR_ISSUE}"
-  else
-    if [[ ${PATCH_OR_ISSUE} =~ ^http ]]; then
-      echo "Patch is being downloaded at $(date) from"
-      PATCHURL="${PATCH_OR_ISSUE}"
-    else
-      ${CURL} --silent \
-              --output "${PATCH_DIR}/jira" \
-              --location \
-             "https://issues.apache.org/jira/browse/${PATCH_OR_ISSUE}"
-      case $? in
-        0)
-        ;;
-        2)
-          yetus_error "ERROR: .curlrc/.netrc parsing error."
-          cleanup_and_exit 1
-        ;;
-        3)
-          yetus_error "ERROR: File IO error."
-          cleanup_and_exit 1
-        ;;
-        4)
-          yetus_error "ERROR: URL ${PATCH_OR_ISSUE} is unreachable."
-          cleanup_and_exit 1
-        ;;
-        *)
-          yetus_error "ERROR: Unable to fetch ${PATCH_OR_ISSUE}."
-          cleanup_and_exit 1
-        ;;
-      esac
-
-      if [[ -z "${PATCH_FILE}" ]]; then
-        if [[ $(${GREP} -c 'Patch Available' "${PATCH_DIR}/jira") == 0 ]] ; then
-          if [[ ${JENKINS} == true ]]; then
-            yetus_error "ERROR: ${PATCH_OR_ISSUE} is not \"Patch Available\"."
-            cleanup_and_exit 1
-          else
-            yetus_error "WARNING: ${PATCH_OR_ISSUE} is not \"Patch Available\"."
-          fi
-        fi
-
-        #shellcheck disable=SC2016
-        relativePatchURL=$(${AWK} 'match($0,"\"/jira/secure/attachment/[0-9]*/[^\"]*"){print substr($0,RSTART+1,RLENGTH-1)}' "${PATCH_DIR}/jira" |
-          ${GREP} -v -e 'htm[l]*$' | sort | tail -1)
-        PATCHURL="https://issues.apache.org${relativePatchURL}"
-        if [[ ! ${PATCHURL} =~ \.patch$ ]]; then
-          notSureIfPatch=true
-        fi
-        echo "${ISSUE} patch is being downloaded at $(date) from"
-      fi
-    fi
-    if [[ -z "${PATCH_FILE}" ]]; then
-      ${CURL} --silent --location --output "${PATCH_DIR}/patch" "${PATCHURL}"
-      if [[ $? != 0 ]];then
-        yetus_error "ERROR: ${PATCH_OR_ISSUE} could not be downloaded."
-        cleanup_and_exit 1
-      fi
-      PATCH_FILE="${PATCH_DIR}/patch"
-    fi
-  fi
-
-  if [[ ! -f "${PATCH_DIR}/patch" ]]; then
-    cp "${PATCH_FILE}" "${PATCH_DIR}/patch"
-    if [[ $? == 0 ]] ; then
-      echo "Patch file ${PATCH_FILE} copied to ${PATCH_DIR}"
-    else
-      yetus_error "ERROR: Could not copy ${PATCH_FILE} to ${PATCH_DIR}"
-      cleanup_and_exit 1
-    fi
-  fi
-
-  if [[ ! -f "${PATCH_DIR}/patch" ]]; then
-    cp "${PATCH_FILE}" "${PATCH_DIR}/patch"
-    if [[ $? == 0 ]] ; then
-      echo "Patch file ${PATCH_FILE} copied to ${PATCH_DIR}"
-    else
-      yetus_error "ERROR: Could not copy ${PATCH_FILE} to ${PATCH_DIR}"
-      cleanup_and_exit 1
-    fi
-  fi
-
-  if [[ ${notSureIfPatch} == "true" ]]; then
-    guess_patch_file "${PATCH_FILE}"
-    if [[ $? != 0 ]]; then
-      yetus_error "ERROR: ${PATCHURL} is not a patch file."
-      cleanup_and_exit 1
-    else
-      yetus_debug "The patch ${PATCHURL} was not named properly, but it looks like a patch file. proceeding, but issue/branch matching might go awry."
-    fi
-  fi
-}
-
-## @description  if patch-level zero, then verify we aren't
-## @description  just adding files
-## @audience     public
-## @stability    stable
-## @param        filename
-## @param        command
-## @param        [..]
-## @replaceable  no
-## @returns      $?
-function verify_zero
-{
-  local logfile=$1
-  shift
-  local dir
-
-  # don't return /dev/null
-  # shellcheck disable=SC2016
-  changed_files1=$(${AWK} 'function p(s){if(s!~"^/dev/null"){print s}}
-    /^diff --git /   { p($3); p($4) }
-    /^(\+\+\+|---) / { p($2) }' "${PATCH_DIR}/patch" | sort -u)
-
-  # maybe we interpreted the patch wrong? check the log file
-  # shellcheck disable=SC2016
-  changed_files2=$(${GREP} -E '^[cC]heck' "${logfile}" \
-    | ${AWK} '{print $3}' \
-    | ${SED} -e 's,\.\.\.$,,g')
-
-  for filename in ${changed_files1} ${changed_files2}; do
-
-    # leading prefix = bad
-    if [[ ${filename} =~ ^(a|b)/ ]]; then
-      return 1
-    fi
-
-    # touching an existing file is proof enough
-    # that pl=0 is good
-    if [[ -f ${filename} ]]; then
-      return 0
-    fi
-
-    dir=$(dirname "${filename}" 2>/dev/null)
-    if [[ -n ${dir} && -d ${dir} ]]; then
-      return 0
-    fi
-  done
-
-  # ¯\_(ツ)_/¯ - no way for us to know, all new files with no prefix!
-  yetus_error "WARNING: Patch only adds files; using patch level ${PATCHPREFIX}"
-  return 0
-}
-
-## @description  run the command, sending stdout and stderr to the given filename
-## @audience     public
-## @stability    stable
-## @param        filename
-## @param        command
-## @param        [..]
-## @replaceable  no
-## @returns      $?
-function run_and_redirect
-{
-  local logfile=$1
-  shift
-
-  # to the log
-  echo "${*}" > "${logfile}"
-  # the actual command
-  "${@}" >> "${logfile}" 2>&1
-}
-
-## @description git patch dryrun
-## @replaceable  no
-## @audience     private
-## @stability    evolving
-function git_dryrun
-{
-  local prefixsize=${1:-0}
-
-  while [[ ${prefixsize} -lt 4
-    && -z ${PATCHMODE} ]]; do
-    run_and_redirect "${PATCH_DIR}/apply-patch-git-dryrun.log" \
-       "${GIT}" apply --binary -v --check "-p${prefixsize}" "${PATCH_FILE}"
-    if [[ $? == 0 ]]; then
-      PATCHPREFIX=${prefixsize}
-      PATCHMODE=git
-      echo "Verifying the patch:"
-      cat "${PATCH_DIR}/apply-patch-git-dryrun.log"
-      break
-    fi
-    ((prefixsize=prefixsize+1))
-  done
-
-  if [[ ${prefixsize} -eq 0 ]]; then
-    verify_zero "${PATCH_DIR}/apply-patch-git-dryrun.log"
-    if [[ $? != 0 ]]; then
-      PATCHMODE=""
-      PATCHPREFIX=""
-      git_dryrun 1
-    fi
-  fi
-}
-
-## @description  patch patch dryrun
-## @replaceable  no
-## @audience     private
-## @stability    evolving
-function patch_dryrun
-{
-  local prefixsize=${1:-0}
-
-  while [[ ${prefixsize} -lt 4
-    && -z ${PATCHMODE} ]]; do
-    run_and_redirect "${PATCH_DIR}/apply-patch-patch-dryrun.log" \
-      "${PATCH}" "-p${prefixsize}" -E --dry-run < "${PATCH_FILE}"
-    if [[ $? == 0 ]]; then
-      PATCHPREFIX=${prefixsize}
-      PATCHMODE=patch
-      if [[ ${DRYRUNMODE} == true ]]; then
-        echo "Verifying the patch:"
-        cat "${PATCH_DIR}/apply-patch-patch-dryrun.log"
-      fi
-      break
-    fi
-    ((prefixsize=prefixsize+1))
-  done
-
-  if [[ ${prefixsize} -eq 0 ]]; then
-    verify_zero "${PATCH_DIR}/apply-patch-patch-dryrun.log"
-    if [[ $? != 0 ]]; then
-      PATCHMODE=""
-      PATCHPREFIX=""
-      patch_dryrun 1
-    fi
-  fi
-}
-
-## @description  driver for dryrun methods
-## @replaceable  no
-## @audience     private
-## @stability    evolving
-function dryrun
-{
-  local method
-
-  for method in "${PATCHMODES[@]}"; do
-    if declare -f ${method}_dryrun >/dev/null; then
-      "${method}_dryrun"
-    fi
-    if [[ -n ${PATCHMODE} ]]; then
-      break
-    fi
-  done
-
-  if [[ -n ${PATCHMODE} ]]; then
-    RESULT=0
-    return 0
-  fi
-  RESULT=1
-  return 1
-}
-
-## @description  git patch apply
-## @replaceable  no
-## @audience     private
-## @stability    evolving
-function git_apply
-{
-  echo "Applying the patch:"
-  run_and_redirect "${PATCH_DIR}/apply-patch-git-apply.log" \
-    "${GIT}" apply --binary -v --stat --apply "-p${PATCHPREFIX}" "${PATCH_FILE}"
-  ${GREP} -v "^Checking" "${PATCH_DIR}/apply-patch-git-apply.log"
-}
-
-
-## @description  patch patch apply
-## @replaceable  no
-## @audience     private
-## @stability    evolving
-function patch_apply
-{
-  echo "Applying the patch:"
-  run_and_redirect "${PATCH_DIR}/apply-patch-patch-apply.log" \
-    "${PATCH}" "-p${PATCHPREFIX}" -E < "${PATCH_FILE}"
-  cat "${PATCH_DIR}/apply-patch-patch-apply.log"
-}
-
-
-## @description  driver for patch apply methods
-## @replaceable  no
-## @audience     private
-## @stability    evolving
-function apply
-{
-  if declare -f ${PATCHMODE}_apply >/dev/null; then
-    "${PATCHMODE}_apply"
-    if [[ $? -gt 0 ]]; then
-      RESULT=1
-    else
-      RESULT=0
-    fi
-  else
-    yetus_error "ERROR: Patching method ${PATCHMODE} does not have a way to apply patches!"
-    RESULT=1
-  fi
-}
-
 trap "cleanup_and_exit 1" HUP INT QUIT TERM
 
 setup_defaults
 
 parse_args "$@"
 
+importplugins
+yetus_debug "Removing BUILDTOOLS, PLUGINS, and TESTFORMATS from installed plug list"
+unset BUILDTOOLS
+unset PLUGINS
+unset TESTFORMATS
+
+parse_args_plugins "$@"
+
+plugins_initialize
+
 locate_patch
 
-dryrun
+patchfile_dryrun_driver "${PATCH_DIR}/patch"
+RESULT=$?
 
 if [[ ${RESULT} -gt 0 ]]; then
-  yetus_error "ERROR: Aborting! The patch cannot be verified."
+  yetus_error "ERROR: Aborting! ${PATCH_OR_ISSUE} cannot be verified."
   cleanup_and_exit ${RESULT}
 fi
 
-if [[ ${DRYRUNMODE} == false ]]; then
-  apply
+if [[ ${PATCH_DRYRUNMODE} == false ]]; then
+  patchfile_apply_driver "${PATCH_DIR}/patch"
+  RESULT=$?
 fi
 
 cleanup_and_exit ${RESULT}

http://git-wip-us.apache.org/repos/asf/yetus/blob/19fe8bc8/dev-support/test-patch-docker/test-patch-docker.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-docker/test-patch-docker.sh b/dev-support/test-patch-docker/test-patch-docker.sh
index 6a212b9..ec507af 100755
--- a/dev-support/test-patch-docker/test-patch-docker.sh
+++ b/dev-support/test-patch-docker/test-patch-docker.sh
@@ -24,7 +24,7 @@ DID=${RANDOM}
 ## @param        string
 function yetus_debug
 {
-  if [[ -n "${TP_SHELL_SCRIPT_DEBUG}" ]]; then
+  if [[ -n "${YETUS_SHELL_SCRIPT_DEBUG}" ]]; then
     echo "[$(date) DEBUG]: $*" 1>&2
   fi
 }
@@ -53,7 +53,7 @@ function parse_args
   for i in "$@"; do
     case ${i} in
       --debug)
-        TP_SHELL_SCRIPT_DEBUG=true
+        YETUS_SHELL_SCRIPT_DEBUG=true
       ;;
       --dockerversion=*)
         DOCKER_VERSION=${i#*=}

http://git-wip-us.apache.org/repos/asf/yetus/blob/19fe8bc8/dev-support/test-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh
index 086a0a4..ccd1bbe 100755
--- a/dev-support/test-patch.sh
+++ b/dev-support/test-patch.sh
@@ -23,8 +23,6 @@ if [[ -z "${BASH_VERSINFO}" ]] \
   exit 1
 fi
 
-### BUILD_URL is set by Hudson if it is run by patch process
-
 this="${BASH_SOURCE-$0}"
 BINDIR=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
 STARTINGDIR=$(pwd)
@@ -33,6 +31,8 @@ GLOBALTIMER=$(date +"%s")
 #shellcheck disable=SC2034
 QATESTMODE=false
 
+. "${BINDIR}/core.d/common.sh"
+
 # global arrays
 declare -a TP_HEADER
 declare -a TP_VOTE_TABLE
@@ -56,22 +56,18 @@ TP_FOOTER_COUNTER=0
 ## @replaceable  no
 function setup_defaults
 {
-  PROJECT_NAME=yetus
+  common_defaults
+
   DOCKERFILE="${BINDIR}/test-patch-docker/Dockerfile-startstub"
   HOW_TO_CONTRIBUTE="https://wiki.apache.org/hadoop/HowToContribute"
-  JENKINS=false
   INSTANCE=${RANDOM}
-  BASEDIR=$(pwd)
   RELOCATE_PATCH_DIR=false
 
-  USER_PLUGIN_DIR=""
-  LOAD_SYSTEM_PLUGINS=true
   ALLOWSUMMARIES=true
 
   DOCKERSUPPORT=false
   BUILD_NATIVE=${BUILD_NATIVE:-true}
-  PATCH_BRANCH=""
-  PATCH_BRANCH_DEFAULT="master"
+
   BUILDTOOLCWD=true
 
   # shellcheck disable=SC2034
@@ -81,64 +77,14 @@ function setup_defaults
   # shellcheck disable=SC2034
   CHANGED_UNION_MODULES=""
   USER_MODULE_LIST=""
-  OFFLINE=false
   CHANGED_FILES=""
   REEXECED=false
   RESETREPO=false
   ISSUE=""
   TIMER=$(date +"%s")
-  OSTYPE=$(uname -s)
   BUILDTOOL=maven
   TESTFORMATS=""
   JDK_TEST_LIST="compile javadoc unit"
-
-  # Solaris needs POSIX, not SVID
-  case ${OSTYPE} in
-    SunOS)
-      AWK=${AWK:-/usr/xpg4/bin/awk}
-      SED=${SED:-/usr/xpg4/bin/sed}
-      CURL=${CURL:-curl}
-      GIT=${GIT:-git}
-      GREP=${GREP:-/usr/xpg4/bin/grep}
-      PATCH=${PATCH:-/usr/gnu/bin/patch}
-      DIFF=${DIFF:-/usr/gnu/bin/diff}
-      FILE=${FILE:-file}
-    ;;
-    *)
-      AWK=${AWK:-awk}
-      SED=${SED:-sed}
-      CURL=${CURL:-curl}
-      GIT=${GIT:-git}
-      GREP=${GREP:-grep}
-      PATCH=${PATCH:-patch}
-      DIFF=${DIFF:-diff}
-      FILE=${FILE:-file}
-    ;;
-  esac
-
-  RESULT=0
-}
-
-## @description  Print a message to stderr
-## @audience     public
-## @stability    stable
-## @replaceable  no
-## @param        string
-function yetus_error
-{
-  echo "$*" 1>&2
-}
-
-## @description  Print a message to stderr if --debug is turned on
-## @audience     public
-## @stability    stable
-## @replaceable  no
-## @param        string
-function yetus_debug
-{
-  if [[ -n "${TP_SHELL_SCRIPT_DEBUG}" ]]; then
-    echo "[$(date) DEBUG]: $*" 1>&2
-  fi
 }
 
 ## @description  Convert the given module name to a file fragment
@@ -236,7 +182,7 @@ function generate_stack
 {
   declare frame
 
-  if [[ -n "${TP_SHELL_SCRIPT_DEBUG}" ]]; then
+  if [[ -n "${YETUS_SHELL_SCRIPT_DEBUG}" ]]; then
     while caller "${frame}"; do
       ((frame++));
     done
@@ -349,6 +295,10 @@ function prepopulate_footer
   if [[ -n ${PERSONALITY} ]]; then
     add_footer_table "Personality" "${PERSONALITY}"
   fi
+
+  gitrev=$(${GIT} rev-parse --verify --short HEAD)
+
+  add_footer_table "git revision" "${PATCH_BRANCH} / ${gitrev}"
 }
 
 ## @description  Put docker stats in various tables
@@ -528,7 +478,7 @@ function verify_patchdir_still_exists
     fi
 
     rm "${commentfile}"
-    cleanup_and_exit ${RESULT}
+    cleanup_and_exit "${RESULT}"
   fi
 }
 
@@ -679,11 +629,7 @@ function echo_and_redirect
   # to the screen
   echo "cd $(pwd)"
   echo "${*} > ${logfile} 2>&1"
-  # to the log
-  echo "cd $(pwd)" > "${logfile}"
-  echo "${*}" >> "${logfile}"
-  # run the actual command
-  "${@}" >> "${logfile}" 2>&1
+  yetus_run_and_redirect "${logfile}" "${@}"
 }
 
 ## @description is a given directory relative to BASEDIR?
@@ -710,9 +656,9 @@ function relative_dir
 ## @audience     public
 ## @stability    stable
 ## @replaceable  no
-function testpatch_usage
+function yetus_usage
 {
-  local -r up=$(echo ${PROJECT_NAME} | tr '[:lower:]' '[:upper:]')
+  local -r up=$(echo "${PROJECT_NAME}" | tr '[:lower:]' '[:upper:]')
 
   echo "Usage: test-patch.sh [options] patch-file | issue-number | http"
   echo
@@ -726,6 +672,7 @@ function testpatch_usage
   echo "--branch=<ref>         Forcibly set the branch"
   echo "--branch-default=<ref> If the branch isn't forced and we don't detect one in the patch name, use this branch (default 'master')"
   echo "--build-native=<bool>  If true, then build native components (default 'true')"
+  # shellcheck disable=SC2153
   echo "--build-tool=<tool>    Pick which build tool to focus around (${BUILDTOOLS})"
   echo "--bugcomments=<bug>    Only write comments to the screen and this comma delimited list (${BUGSYSTEMS})"
   echo "--contrib-guide=<url>  URL to point new users towards project conventions. (default: ${HOW_TO_CONTRIBUTE} )"
@@ -790,20 +737,10 @@ function parse_args
   local j
   local testlist
 
+  common_args "$@"
+
   for i in "$@"; do
     case ${i} in
-      --awk-cmd=*)
-        AWK=${i#*=}
-      ;;
-      --basedir=*)
-        BASEDIR=${i#*=}
-      ;;
-      --branch=*)
-        PATCH_BRANCH=${i#*=}
-      ;;
-      --branch-default=*)
-        PATCH_BRANCH_DEFAULT=${i#*=}
-      ;;
       --bugcomments=*)
         BUGCOMMENTS=${i#*=}
         BUGCOMMENTS=${BUGCOMMENTS//,/ }
@@ -820,15 +757,6 @@ function parse_args
       --contrib-guide=*)
         HOW_TO_CONTRIBUTE=${i#*=}
       ;;
-      --curl-cmd=*)
-        CURL=${i#*=}
-      ;;
-      --debug)
-        TP_SHELL_SCRIPT_DEBUG=true
-      ;;
-      --diff-cmd=*)
-        DIFF=${i#*=}
-      ;;
       --dirty-workspace)
         DIRTY_WORKSPACE=true
       ;;
@@ -841,19 +769,6 @@ function parse_args
       --dockermode)
         DOCKERMODE=true
       ;;
-      --file-cmd=*)
-        FILE=${i#*=}
-      ;;
-      --git-cmd=*)
-        GIT=${i#*=}
-      ;;
-      --grep-cmd=*)
-        GREP=${i#*=}
-      ;;
-      --help|-help|-h|help|--h|--\?|-\?|\?)
-        testpatch_usage
-        exit 0
-      ;;
       --java-home=*)
         JAVA_HOME=${i#*=}
       ;;
@@ -866,11 +781,6 @@ function parse_args
         BUGLINECOMMENTS=${i#*=}
         BUGLINECOMMENTS=${BUGLINECOMMENTS//,/ }
       ;;
-      --modulelist=*)
-        USER_MODULE_LIST=${i#*=}
-        USER_MODULE_LIST=${USER_MODULE_LIST//,/ }
-        yetus_debug "Manually forcing modules ${USER_MODULE_LIST}"
-      ;;
       --multijdkdirs=*)
         JDK_DIR_LIST=${i#*=}
         JDK_DIR_LIST=${JDK_DIR_LIST//,/ }
@@ -884,24 +794,9 @@ function parse_args
       --mv-patch-dir)
         RELOCATE_PATCH_DIR=true;
       ;;
-      --offline)
-        OFFLINE=true
-      ;;
-      --patch-cmd=*)
-        PATCH=${i#*=}
-      ;;
-      --patch-dir=*)
-        USER_PATCH_DIR=${i#*=}
-      ;;
       --personality=*)
         PERSONALITY=${i#*=}
       ;;
-      --plugins=*)
-        USER_PLUGIN_DIR=${i#*=}
-      ;;
-      --project=*)
-        PROJECT_NAME=${i#*=}
-      ;;
       --reexec)
         REEXECED=true
       ;;
@@ -916,9 +811,6 @@ function parse_args
         MODULE_SKIPDIRS=${MODULE_SKIPDIRS//,/ }
         yetus_debug "Setting skipdirs to ${MODULE_SKIPDIRS}"
       ;;
-      --skip-system-plugins)
-        LOAD_SYSTEM_PLUGINS=false
-      ;;
       --summarize=*)
         ALLOWSUMMARIES=${i#*=}
       ;;
@@ -974,7 +866,7 @@ function parse_args
   fi
 
   if [[ -z "${PATCH_OR_ISSUE}" ]]; then
-    testpatch_usage
+    yetus_usage
     exit 1
   fi
 
@@ -984,8 +876,6 @@ function parse_args
 
   if [[ -n ${USER_PATCH_DIR} ]]; then
     PATCH_DIR="${USER_PATCH_DIR}"
-  else
-    PATCH_DIR=/tmp/test-patch-${PROJECT_NAME}/$$
   fi
 
   cd "${STARTINGDIR}"
@@ -1212,7 +1102,7 @@ function find_changed_modules
 }
 
 ## @description  git checkout the appropriate branch to test.  Additionally, this calls
-## @description  'determine_issue' and 'determine_branch' based upon the context provided
+## @description  'determine_branch' based upon the context provided
 ## @description  in ${PATCH_DIR} and in git after checkout.
 ## @audience     private
 ## @stability    stable
@@ -1318,18 +1208,6 @@ function git_checkout
     fi
   fi
 
-  determine_issue
-
-  GIT_REVISION=$(${GIT} rev-parse --verify --short HEAD)
-
-  if [[ "${ISSUE}" == 'Unknown' ]]; then
-    echo "Testing patch on ${PATCH_BRANCH}."
-  else
-    echo "Testing ${ISSUE} patch on ${PATCH_BRANCH}."
-  fi
-
-  add_footer_table "git revision" "${PATCH_BRANCH} / ${GIT_REVISION}"
-
   return 0
 }
 
@@ -1427,7 +1305,7 @@ function determine_branch
 ## @return       1 on failure, with ISSUE updated to "Unknown"
 function determine_issue
 {
-  local bugsys
+  declare bugsys
 
   yetus_debug "Determine issue"
 
@@ -1521,114 +1399,6 @@ function determine_needed_tests
   add_footer_table "Optional Tests" "${NEEDED_TESTS}"
 }
 
-## @description  Given ${PATCH_ISSUE}, determine what type of patch file is in use, and do the
-## @description  necessary work to place it into ${PATCH_DIR}/patch.
-## @audience     private
-## @stability    evolving
-## @replaceable  no
-## @return       0 on success
-## @return       1 on failure, may exit
-function locate_patch
-{
-  local bugsys
-  local patchfile=""
-  local gotit=false
-
-  yetus_debug "locate patch"
-
-  # it's a locally provided file
-  if [[ -f ${PATCH_OR_ISSUE} ]]; then
-    patchfile="${PATCH_OR_ISSUE}"
-  else
-    # run through the bug systems.  maybe they know?
-    for bugsys in ${BUGSYSTEMS}; do
-      if declare -f ${bugsys}_locate_patch >/dev/null 2>&1; then
-        "${bugsys}_locate_patch" "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
-        if [[ $? == 0 ]]; then
-          guess_patch_file "${PATCH_DIR}/patch"
-          if [[ $? == 0 ]]; then
-            gotit=true
-            break;
-          fi
-        fi
-      fi
-    done
-
-    # ok, none of the bug systems know. let's see how smart we are
-    if [[ ${gotit} == false ]]; then
-      generic_locate_patch "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
-    fi
-  fi
-
-  if [[ ! -f "${PATCH_DIR}/patch"
-      && -f "${patchfile}" ]]; then
-    cp "${patchfile}" "${PATCH_DIR}/patch"
-    if [[ $? == 0 ]] ; then
-      echo "Patch file ${patchfile} copied to ${PATCH_DIR}"
-    else
-      yetus_error "ERROR: Could not copy ${patchfile} to ${PATCH_DIR}"
-      cleanup_and_exit 1
-    fi
-  fi
-
-  guess_patch_file "${PATCH_DIR}/patch"
-  if [[ $? != 0 ]]; then
-    yetus_error "ERROR: Unsure how to process ${PATCH_OR_ISSUE}."
-    cleanup_and_exit 1
-  fi
-}
-
-## @description Given a possible patch file, guess if it's a patch file without using smart-apply-patch
-## @audience private
-## @stability evolving
-## @param path to patch file to test
-## @return 0 we think it's a patch file
-## @return 1 we think it's not a patch file
-function guess_patch_file
-{
-  local patch=$1
-  local fileOutput
-
-  if [[ ! -f ${patch} ]]; then
-    return 1
-  fi
-
-  yetus_debug "Trying to guess is ${patch} is a patch file."
-  fileOutput=$("${FILE}" "${patch}")
-  if [[ $fileOutput =~ \ diff\  ]]; then
-    yetus_debug "file magic says it's a diff."
-    return 0
-  fi
-  fileOutput=$(head -n 1 "${patch}" | "${GREP}" -E "^(From [a-z0-9]* Mon Sep 17 00:00:00 2001)|(diff .*)|(Index: .*)$")
-  if [[ $? == 0 ]]; then
-    yetus_debug "first line looks like a patch file."
-    return 0
-  fi
-  return 1
-}
-
-## @description  Given ${PATCH_DIR}/patch, verify the patch is good using ${BINDIR}/smart-apply-patch.sh
-## @description  in dryrun mode.
-## @audience     private
-## @stability    evolving
-## @replaceable  no
-## @return       0 on success
-## @return       1 on failure
-function verify_patch_file
-{
-  # Before building, check to make sure that the patch is valid
-  export PATCH
-
-  "${BINDIR}/smart-apply-patch.sh" --dry-run "${PATCH_DIR}/patch"
-  if [[ $? != 0 ]] ; then
-    echo "PATCH APPLICATION FAILED"
-    add_vote_table -1 patch "The patch command could not apply the patch during dryrun."
-    return 1
-  else
-    return 0
-  fi
-}
-
 ## @description  Given ${PATCH_DIR}/patch, apply the patch using ${BINDIR}/smart-apply-patch.sh
 ## @audience     private
 ## @stability    evolving
@@ -1639,8 +1409,7 @@ function apply_patch_file
 {
   big_console_header "Applying patch to ${PATCH_BRANCH}"
 
-  export PATCH
-  "${BINDIR}/smart-apply-patch.sh" "${PATCH_DIR}/patch"
+  patchfile_apply_driver "${PATCH_DIR}/patch"
   if [[ $? != 0 ]] ; then
     echo "PATCH APPLICATION FAILED"
     ((RESULT = RESULT + 1))
@@ -1788,7 +1557,6 @@ function check_reexec
   if [[ ${DOCKERSUPPORT} == true
       && ${copy} == false ]]; then
     big_console_header "Re-execing under Docker"
-
   fi
 
   # copy our universe
@@ -2357,130 +2125,6 @@ function runtests
   done
 }
 
-## @description  Import content from test-patch.d and optionally
-## @description  from user provided plugin directory
-## @audience     private
-## @stability    evolving
-## @replaceable  no
-function importplugins
-{
-  local i
-  local files=()
-
-  if [[ ${LOAD_SYSTEM_PLUGINS} == "true" ]]; then
-    if [[ -d "${BINDIR}/test-patch.d" ]]; then
-      files=(${BINDIR}/test-patch.d/*.sh)
-    fi
-  fi
-
-  if [[ -n "${USER_PLUGIN_DIR}" && -d "${USER_PLUGIN_DIR}" ]]; then
-    yetus_debug "Loading user provided plugins from ${USER_PLUGIN_DIR}"
-    files=("${files[@]}" ${USER_PLUGIN_DIR}/*.sh)
-  fi
-
-  for i in "${files[@]}"; do
-    if [[ -f ${i} ]]; then
-      yetus_debug "Importing ${i}"
-      . "${i}"
-    fi
-  done
-
-  if [[ -z ${PERSONALITY}
-      && -f "${BINDIR}/personality/${PROJECT_NAME}.sh" ]]; then
-    PERSONALITY="${BINDIR}/personality/${PROJECT_NAME}.sh"
-  fi
-
-  if [[ -n ${PERSONALITY} ]]; then
-    if [[ ! -f ${PERSONALITY} ]]; then
-      if [[ -f "${BINDIR}/personality/${PROJECT_NAME}.sh" ]]; then
-        PERSONALITY="${BINDIR}/personality/${PROJECT_NAME}.sh"
-      else
-        yetus_debug "Can't find ${PERSONALITY} to import."
-        return
-      fi
-    fi
-    yetus_debug "Importing ${PERSONALITY}"
-    . "${PERSONALITY}"
-  fi
-}
-
-## @description  Let plugins also get a copy of the arguments
-## @audience     private
-## @stability    evolving
-## @replaceable  no
-function parse_args_plugins
-{
-  for plugin in ${PLUGINS} ${BUGSYSTEMS} ${TESTFORMATS} ${BUILDTOOLS}; do
-    if declare -f ${plugin}_parse_args >/dev/null 2>&1; then
-      yetus_debug "Running ${plugin}_parse_args"
-      #shellcheck disable=SC2086
-      ${plugin}_parse_args "$@"
-      (( RESULT = RESULT + $? ))
-    fi
-  done
-
-  BUGCOMMENTS=${BUGCOMMENTS:-${BUGSYSTEMS}}
-  if [[ ! ${BUGCOMMENTS} =~ console ]]; then
-    BUGCOMMENTS="${BUGCOMMENTS} console"
-  fi
-
-  BUGLINECOMMENTS=${BUGLINECOMMENTS:-${BUGCOMMENTS}}
-}
-
-## @description  Let plugins also get a copy of the arguments
-## @audience     private
-## @stability    evolving
-## @replaceable  no
-function plugins_initialize
-{
-  declare plugin
-
-  for plugin in ${PLUGINS} ${BUGSYSTEMS} ${TESTFORMATS} ${BUILDTOOLS}; do
-    if declare -f ${plugin}_initialize >/dev/null 2>&1; then
-      yetus_debug "Running ${plugin}_initialize"
-      #shellcheck disable=SC2086
-      ${plugin}_initialize
-      (( RESULT = RESULT + $? ))
-    fi
-  done
-}
-
-## @description  Register test-patch.d plugins
-## @audience     public
-## @stability    stable
-## @replaceable  no
-function add_plugin
-{
-  PLUGINS="${PLUGINS} $1"
-}
-
-## @description  Register test-patch.d bugsystems
-## @audience     public
-## @stability    stable
-## @replaceable  no
-function add_bugsystem
-{
-  BUGSYSTEMS="${BUGSYSTEMS} $1"
-}
-
-## @description  Register test-patch.d test output formats
-## @audience     public
-## @stability    stable
-## @replaceable  no
-function add_test_format
-{
-  TESTFORMATS="${TESTFORMATS} $1"
-}
-
-## @description  Register test-patch.d build tools
-## @audience     public
-## @stability    stable
-## @replaceable  no
-function add_build_tool
-{
-  BUILDTOOLS="${BUILDTOOLS} $1"
-}
-
 ## @description  Calculate the differences between the specified files
 ## @description  and output it to stdout.
 ## @audience     public
@@ -2519,6 +2163,7 @@ function calcdiffs
   rm "${tmp}.branch" "${tmp}.patch" "${tmp}.lined" 2>/dev/null
 }
 
+
 ## @description  Helper routine for plugins to ask projects, etc
 ## @description  to count problems in a log file
 ## @description  and output it to stdout.
@@ -2941,11 +2586,18 @@ function initialize
   # from here on out, we'll be in ${BASEDIR} for cwd
   # plugins need to pushd/popd if they change.
   git_checkout
-  RESULT=$?
-  if [[ ${JENKINS} == "true" ]] ; then
-    if [[ ${RESULT} != 0 ]] ; then
-      exit 1
-    fi
+
+  patchfile_dryrun_driver "${PATCH_DIR}/patch"
+  if [[ $? != 0 ]]; then
+    yetus_error "ERROR: ${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}."
+    cleanup_and_exit 1
+  fi
+
+  determine_issue
+  if [[ "${ISSUE}" == 'Unknown' ]]; then
+    echo "Testing patch on ${PATCH_BRANCH}."
+  else
+    echo "Testing ${ISSUE} patch on ${PATCH_BRANCH}."
   fi
 
   find_changed_files
@@ -2966,13 +2618,6 @@ function prechecks
   declare plugin
   declare result=0
 
-  verify_patch_file
-  (( result = result + $? ))
-  if [[ ${result} != 0 ]] ; then
-    bugsystem_finalreport 1
-    cleanup_and_exit 1
-  fi
-
   for plugin in ${BUILDTOOL} ${PLUGINS} ${TESTFORMATS}; do
     verify_patchdir_still_exists
 


Mime
View raw message