http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/shellcheck.sh ---------------------------------------------------------------------- diff --git a/dev-support/test-patch.d/shellcheck.sh b/dev-support/test-patch.d/shellcheck.sh deleted file mode 100755 index d50d212..0000000 --- a/dev-support/test-patch.d/shellcheck.sh +++ /dev/null @@ -1,176 +0,0 @@ -#!/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. - -add_test_type shellcheck - -SHELLCHECK_TIMER=0 - -SHELLCHECK=${SHELLCHECK:-$(which shellcheck 2>/dev/null)} - -SHELLCHECK_SPECIFICFILES="" - -# if it ends in an explicit .sh, then this is shell code. -# if it doesn't have an extension, we assume it is shell code too -function shellcheck_filefilter -{ - local filename=$1 - - if [[ ${filename} =~ \.sh$ ]]; then - add_test shellcheck - SHELLCHECK_SPECIFICFILES="${SHELLCHECK_SPECIFICFILES} ./${filename}" - fi - - if [[ ! ${filename} =~ \. ]]; then - add_test shellcheck - fi -} - -function shellcheck_private_findbash -{ - local i - local value - local list - - while read line; do - value=$(find "${line}" ! -name '*.cmd' -type f \ - | ${GREP} -E -v '(.orig$|.rej$)') - - for i in ${value}; do - if [[ ! ${i} =~ \.sh(\.|$) - && ! $(head -n 1 "${i}") =~ ^#! ]]; then - yetus_debug "Shellcheck skipped: ${i}" - continue - fi - list="${list} ${i}" - done - done < <(find . -type d -name bin -o -type d -name sbin -o -type d -name scripts -o -type d -name libexec -o -type d -name shellprofile.d) - # shellcheck disable=SC2086 - echo ${list} ${SHELLCHECK_SPECIFICFILES} | tr ' ' '\n' | sort -u -} - -function shellcheck_preapply -{ - local i - - verify_needed_test shellcheck - if [[ $? == 0 ]]; then - return 0 - fi - - 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" - pushd "${BASEDIR}" >/dev/null - for i in $(shellcheck_private_findbash); do - if [[ -f ${i} ]]; then - ${SHELLCHECK} -f gcc "${i}" >> "${PATCH_DIR}/branch-shellcheck-result.txt" - fi - done - popd > /dev/null - # keep track of how much as elapsed for us already - SHELLCHECK_TIMER=$(stop_clock) - return 0 -} - -function shellcheck_postapply -{ - local i - local msg - local numPrepatch - local numPostpatch - local diffPostpatch - - verify_needed_test shellcheck - if [[ $? == 0 ]]; then - return 0 - fi - - 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 - # by setting the clock back - offset_clock "${SHELLCHECK_TIMER}" - - echo "Running shellcheck against all identifiable shell scripts" - # we re-check this in case one has been added - for i in $(shellcheck_private_findbash); do - if [[ -f ${i} ]]; then - ${SHELLCHECK} -f gcc "${i}" >> "${PATCH_DIR}/patch-shellcheck-result.txt" - fi - done - - if [[ ! -f "${PATCH_DIR}/branch-shellcheck-result.txt" ]]; then - touch "${PATCH_DIR}/branch-shellcheck-result.txt" - fi - - # shellcheck disable=SC2016 - SHELLCHECK_VERSION=$(${SHELLCHECK} --version | ${GREP} version: | ${AWK} '{print $NF}') - msg="v${SHELLCHECK_VERSION}" - if [[ ${SHELLCHECK_VERSION} =~ 0.[0-3].[0-5] ]]; then - msg="${msg} (This is an old version that has serious bugs. Consider upgrading.)" - fi - add_footer_table shellcheck "${msg}" - - calcdiffs \ - "${PATCH_DIR}/branch-shellcheck-result.txt" \ - "${PATCH_DIR}/patch-shellcheck-result.txt" \ - > "${PATCH_DIR}/diff-patch-shellcheck.txt" - # shellcheck disable=SC2016 - diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-shellcheck.txt" | ${AWK} '{print $1}') - - if [[ ${diffPostpatch} -gt 0 ]] ; then - # shellcheck disable=SC2016 - numPrepatch=$(wc -l "${PATCH_DIR}/branch-shellcheck-result.txt" | ${AWK} '{print $1}') - - # shellcheck disable=SC2016 - numPostpatch=$(wc -l "${PATCH_DIR}/patch-shellcheck-result.txt" | ${AWK} '{print $1}') - - add_vote_table -1 shellcheck "The applied patch generated "\ - "${diffPostpatch} new shellcheck issues (total was ${numPrepatch}, now ${numPostpatch})." - add_footer_table shellcheck "@@BASE@@/diff-patch-shellcheck.txt" - bugsystem_linecomments "shellcheck" "${PATCH_DIR}/diff-patch-shellcheck.txt" - return 1 - fi - - add_vote_table +1 shellcheck "There were no new shellcheck issues." - return 0 -} - -function shellcheck_postcompile -{ - declare repostatus=$1 - - if [[ "${repostatus}" = branch ]]; then - shellcheck_preapply - else - shellcheck_postapply - fi -}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/tap.sh ---------------------------------------------------------------------- diff --git a/dev-support/test-patch.d/tap.sh b/dev-support/test-patch.d/tap.sh deleted file mode 100755 index 7ced908..0000000 --- a/dev-support/test-patch.d/tap.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/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. - -add_test_format tap - -TAP_FAILED_TESTS="" -TAP_LOG_DIR="target/tap" - -function tap_process_args -{ - declare i - - for i in "$@"; do - case ${i} in - --tap-log-dir=*) - TAP_LOG_DIR=${i#=*} - ;; - esac - done -} - -function tap_usage -{ - echo "TAP Options:" - echo "--tap-log-dir=<dir> Directory relative to the module for tap output (default: \"target/tap\")" -} - -function tap_process_tests -{ - # shellcheck disable=SC2034 - declare module=$1 - # shellcheck disable=SC2034 - declare buildlogfile=$2 - declare filefrag=$3 - declare result=0 - declare module_failed_tests - declare filenames - - filenames=$(find "${TAP_LOG_DIR}" -type f -exec "${GREP}" -l -E "^not ok" {} \;) - - if [[ -n "${filenames}" ]]; then - module_failed_tests=$(echo "${filenames}" \ - | ${SED} -e "s,${TAP_LOG_DIR},,g" -e s,^/,,g ) - # shellcheck disable=SC2086 - cat ${filenames} >> "${PATCH_DIR}/patch-${filefrag}.tap" - TAP_LOGS="${TAP_LOGS} @@BASE@@/patch-${filefrag}.tap" - TAP_FAILED_TESTS="${TAP_FAILED_TESTS} ${module_failed_tests}" - ((result=result+1)) - fi - - if [[ ${result} -gt 0 ]]; then - return 1 - fi - return 0 -} - -function tap_finalize_results -{ - declare jdk=$1 - - if [[ -n "${TAP_FAILED_TESTS}" ]] ; then - # shellcheck disable=SC2086 - populate_test_table "${jdk}Failed TAP tests" ${TAP_FAILED_TESTS} - TAP_FAILED_TESTS="" - add_footer_table "TAP logs" "${TAP_LOGS}" - fi -} http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/test4tests.sh ---------------------------------------------------------------------- diff --git a/dev-support/test-patch.d/test4tests.sh b/dev-support/test-patch.d/test4tests.sh deleted file mode 100755 index 94b9b7f..0000000 --- a/dev-support/test-patch.d/test4tests.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/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. - -add_test_type test4tests - -## @description Check the patch file for changed/new tests -## @audience private -## @stability evolving -## @replaceable no -## @return 0 on success -## @return 1 on failure -function test4tests_patchfile -{ - declare testReferences=0 - declare i - - big_console_header "Checking there are new or changed tests in the patch." - - verify_needed_test unit - - if [[ $? == 0 ]]; then - echo "Patch does not appear to need new or modified tests." - return 0 - fi - - start_clock - - for i in ${CHANGED_FILES}; do - if [[ ${i} =~ (^|/)test/ ]]; then - ((testReferences=testReferences + 1)) - fi - done - - echo "There appear to be ${testReferences} test file(s) referenced in the patch." - if [[ ${testReferences} == 0 ]] ; then - add_vote_table -1 "test4tests" \ - "The patch doesn't appear to include any new or modified tests. " \ - "Please justify why no new tests are needed for this patch." \ - "Also please list what manual steps were performed to verify this patch." - return 1 - fi - add_vote_table +1 "test4tests" \ - "The patch appears to include ${testReferences} new or modified test files." - return 0 -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/whitespace.sh ---------------------------------------------------------------------- diff --git a/dev-support/test-patch.d/whitespace.sh b/dev-support/test-patch.d/whitespace.sh deleted file mode 100755 index 32c5f42..0000000 --- a/dev-support/test-patch.d/whitespace.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/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. - -add_test_type whitespace - -function whitespace_linecomment_reporter -{ - declare file=$1 - shift - declare comment=$* - declare tmpfile="${PATCH_DIR}/wlr.$$.${RANDOM}" - - while read -r line; do - { - # shellcheck disable=SC2086 - printf "%s" "$(echo ${line} | cut -f1-2 -d:)" - echo "${comment}" - } >> "${tmpfile}" - done < "${file}" - - bugsystem_linecomments "whitespace:" "${tmpfile}" - rm "${tmpfile}" -} - -function whitespace_postcompile -{ - declare repostatus=$1 - declare count - declare result=0 - - if [[ "${repostatus}" = branch ]]; then - return 0 - fi - - big_console_header "Checking for whitespace at the end of lines" - start_clock - - pushd "${BASEDIR}" >/dev/null - # shellcheck disable=SC2016 - ${AWK} '/\t/ {print $0}' \ - "${GITDIFFCONTENT}" \ - | ${GREP} -v Makefile: >> "${PATCH_DIR}/whitespace-tabs.txt" - - ${GREP} -E '[[:blank:]]$' \ - "${GITDIFFCONTENT}" \ - >> "${PATCH_DIR}/whitespace-eol.txt" - - # shellcheck disable=SC2016 - count=$(wc -l "${PATCH_DIR}/whitespace-eol.txt" | ${AWK} '{print $1}') - - if [[ ${count} -gt 0 ]]; then - add_vote_table -1 whitespace "The patch has ${count}"\ - " line(s) that end in whitespace. Use git apply --whitespace=fix." - - whitespace_linecomment_reporter "${PATCH_DIR}/whitespace-eol.txt" "end of line" - add_footer_table whitespace "@@BASE@@/whitespace-eol.txt" - ((result=result+1)) - fi - - # shellcheck disable=SC2016 - count=$(wc -l "${PATCH_DIR}/whitespace-tabs.txt" | ${AWK} '{print $1}') - - if [[ ${count} -gt 0 ]]; then - add_vote_table -1 whitespace "The patch has ${count}"\ - " line(s) with tabs." - add_footer_table whitespace "@@BASE@@/whitespace-tabs.txt" - whitespace_linecomment_reporter "${PATCH_DIR}/whitespace-tabs.txt" "tabs in line" - ((result=result+1)) - fi - - if [[ ${result} -gt 0 ]]; then - popd >/dev/null - return 1 - fi - - popd >/dev/null - add_vote_table +1 whitespace "Patch has no whitespace issues." - return 0 -} http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/xml.sh ---------------------------------------------------------------------- diff --git a/dev-support/test-patch.d/xml.sh b/dev-support/test-patch.d/xml.sh deleted file mode 100755 index b04a2f3..0000000 --- a/dev-support/test-patch.d/xml.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/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. - -add_test_type xml - -function xml_filefilter -{ - declare filename=$1 - - if [[ ${filename} =~ \.xml$ ]]; then - add_test xml - fi -} - -function xml_postcompile -{ - declare repostatus=$1 - declare js - declare i - declare count - - verify_needed_test xml - if [[ $? == 0 ]]; then - return 0 - fi - - if [[ "${repostatus}" = branch ]]; then - return 0 - fi - - 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 - - pushd "${BASEDIR}" >/dev/null - for i in ${CHANGED_FILES}; do - if [[ ${i} =~ \.xml$ && -f ${i} ]]; then - ${js} -e "XMLDocument(arguments[0])" "${i}" >> "${PATCH_DIR}/xml.txt" 2>&1 - if [[ $? != 0 ]]; then - ((count=count+1)) - fi - fi - done - - if [[ ${count} -gt 0 ]]; then - add_vote_table -1 xml "The patch has ${count} ill-formed XML file(s)." - add_footer_table xml "@@BASE@@/xml.txt" - popd >/dev/null - return 1 - fi - - popd >/dev/null - add_vote_table +1 xml "The patch has no ill-formed XML file." - return 0 -}
