<commit_before>#!/usr/bin/env 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.


#set -x

### Setup some variables.  
### SVN_REVISION and BUILD_URL are set by Hudson if it is run by patch process
### Read variables from properties file
. `dirname $0`/test-patch.properties

###############################################################################
parseArgs() {
  case "$1" in
    HUDSON)
      ### Set HUDSON to true to indicate that this script is being run by Hudson
      HUDSON=true
      if [[ $# != 15 ]] ; then
        echo "ERROR: usage $0 HUDSON <PATCH_DIR> <PS_CMD> <WGET_CMD> <JIRACLI> <SVN_CMD> <GREP_CMD> <PATCH_CMD> <FINDBUGS_HOME> <FORREST_HOME> <WORKSPACE_BASEDIR> <JIRA_PASSWD> <JAVA5_HOME> <CURL_CMD> <DEFECT> "
        cleanupAndExit 0
      fi
      PATCH_DIR=$2
      PS=$3
      WGET=$4
      JIRACLI=$5
      SVN=$6
      GREP=$7
      PATCH=$8
      FINDBUGS_HOME=$9
      FORREST_HOME=${10}
      BASEDIR=${11}
      JIRA_PASSWD=${12}
      JAVA5_HOME=${13}
      CURL=${14}
      defect=${15}
		
      ### Retrieve the defect number
      if [ -z "$defect" ] ; then
        echo "Could not determine the patch to test.  Exiting."
        cleanupAndExit 0
      fi

      if [ ! -e "$PATCH_DIR" ] ; then
        mkdir -p $PATCH_DIR 
      fi

      ;;
    DEVELOPER)
      ### Set HUDSON to false to indicate that this script is being run by a developer
      HUDSON=false
      if [[ $# != 10 ]] ; then
        echo "ERROR: usage $0 DEVELOPER <PATCH_FILE> <SCRATCH_DIR> <SVN_CMD> <GREP_CMD> <PATCH_CMD> <FINDBUGS_HOME> <FORREST_HOME> <WORKSPACE_BASEDIR> <JAVA5_HOME>"
        cleanupAndExit 0
      fi
      ### PATCH_FILE contains the location of the patchfile
      PATCH_FILE=$2 
      if [[ ! -e "$PATCH_FILE" ]] ; then
        echo "Unable to locate the patch file $PATCH_FILE"
        cleanupAndExit 0
      fi
      PATCH_DIR=$3
      ### Check if $PATCH_DIR exists. If it does not exist, create a new directory
      if [[ ! -e "$PATCH_DIR" ]] ; then
	mkdir "$PATCH_DIR"
	if [[ $? == 0 ]] ; then 
	  echo "$PATCH_DIR has been created"
	else
	  echo "Unable to create $PATCH_DIR"
	  cleanupAndExit 0
	fi
      fi
      SVN=$4
      GREP=$5
      PATCH=$6
      FINDBUGS_HOME=$7
      FORREST_HOME=$8
      BASEDIR=$9
      JAVA5_HOME=${10}
      ### Obtain the patch filename to append it to the version number
      defect=`basename $PATCH_FILE` 
      ;;
    *)
      echo "ERROR: usage $0 HUDSON [args] | DEVELOPER [args]"
      cleanupAndExit 0
      ;;
  esac
}

###############################################################################
checkout () {
  echo ""
  echo ""
  echo "======================================================================"
  echo "======================================================================"
  echo "    Testing patch for ${defect}."
  echo "======================================================================"
  echo "======================================================================"
  echo ""
  echo ""
  ### When run by a developer, if the workspace contains modifications, do not continue
  status=`$SVN stat --ignore-externals | sed -e '/^X[ ]*/D'`
  if [[ $HUDSON == "false" ]] ; then
    if [[ "$status" != "" ]] ; then
      echo "ERROR: can't run in a workspace that contains the following modifications"
      echo "$status"
      cleanupAndExit 1
    fi
  else   
    cd $BASEDIR
    $SVN revert -R .
    rm -rf `$SVN status --no-ignore`<commit_msg>ZOOKEEPER-2336: Jenkins not working due to old SVN (Akihiro Suda via rgs)<commit_after>#!/usr/bin/env 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.


#set -x

### Setup some variables.  
### SVN_REVISION and BUILD_URL are set by Hudson if it is run by patch process
### Read variables from properties file
. `dirname $0`/test-patch.properties

###############################################################################
parseArgs() {
  case "$1" in
    HUDSON)
      ### Set HUDSON to true to indicate that this script is being run by Hudson
      HUDSON=true
      if [[ $# != 15 ]] ; then
        echo "ERROR: usage $0 HUDSON <PATCH_DIR> <PS_CMD> <WGET_CMD> <JIRACLI> <SVN_CMD> <GREP_CMD> <PATCH_CMD> <FINDBUGS_HOME> <FORREST_HOME> <WORKSPACE_BASEDIR> <JIRA_PASSWD> <JAVA5_HOME> <CURL_CMD> <DEFECT> "
        cleanupAndExit 0
      fi
      PATCH_DIR=$2
      PS=$3
      WGET=$4
      JIRACLI=$5
      SVN=$6
      GREP=$7
      PATCH=$8
      FINDBUGS_HOME=$9
      FORREST_HOME=${10}
      BASEDIR=${11}
      JIRA_PASSWD=${12}
      JAVA5_HOME=${13}
      CURL=${14}
      defect=${15}
		
      ### Retrieve the defect number
      if [ -z "$defect" ] ; then
        echo "Could not determine the patch to test.  Exiting."
        cleanupAndExit 0
      fi

      if [ ! -e "$PATCH_DIR" ] ; then
        mkdir -p $PATCH_DIR 
      fi

      ;;
    DEVELOPER)
      ### Set HUDSON to false to indicate that this script is being run by a developer
      HUDSON=false
      if [[ $# != 10 ]] ; then
        echo "ERROR: usage $0 DEVELOPER <PATCH_FILE> <SCRATCH_DIR> <SVN_CMD> <GREP_CMD> <PATCH_CMD> <FINDBUGS_HOME> <FORREST_HOME> <WORKSPACE_BASEDIR> <JAVA5_HOME>"
        cleanupAndExit 0
      fi
      ### PATCH_FILE contains the location of the patchfile
      PATCH_FILE=$2 
      if [[ ! -e "$PATCH_FILE" ]] ; then
        echo "Unable to locate the patch file $PATCH_FILE"
        cleanupAndExit 0
      fi
      PATCH_DIR=$3
      ### Check if $PATCH_DIR exists. If it does not exist, create a new directory
      if [[ ! -e "$PATCH_DIR" ]] ; then
	mkdir "$PATCH_DIR"
	if [[ $? == 0 ]] ; then 
	  echo "$PATCH_DIR has been created"
	else
	  echo "Unable to create $PATCH_DIR"
	  cleanupAndExit 0
	fi
      fi
      SVN=$4
      GREP=$5
      PATCH=$6
      FINDBUGS_HOME=$7
      FORREST_HOME=$8
      BASEDIR=$9
      JAVA5_HOME=${10}
      ### Obtain the patch filename to append it to the version number
      defect=`basename $PATCH_FILE` 
      ;;
    *)
      echo "ERROR: usage $0 HUDSON [args] | DEVELOPER [args]"
      cleanupAndExit 0
      ;;
  esac
}

###############################################################################
checkout () {
  echo ""
  echo ""
  echo "======================================================================"
  echo "======================================================================"
  echo "    Testing patch for ${defect}."
  echo "======================================================================"
  echo "======================================================================"
  echo ""
  echo ""
  ### When run by a developer, if the workspace contains modifications, do not continue
  status=`$SVN stat --ignore-externals | sed -e '/^X[ ]*/D'`
  if [[ $HUDSON == "false" ]] ; then
    if [[ "$status" != "" ]] ; then
      echo "ERROR: can't run in a workspace that contains the following modifications"
      echo "$status"
      cleanupAndExit 1
    fi
  else   
    cd $BASEDIR
    $SVN revert -R .
    rm -rf `$SVN status --no-ignore`
    $SVN upgrade
{'fraction_non_alphanumeric': 0.20826590314950827, 'fraction_numerical': 0.014191460226565417, 'mean_word_length': 2.901894123360855, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6864865', 'n_tokens_mistral': 2595, 'n_tokens_neox': 2447, 'n_words': 794}