You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@yetus.apache.org by bu...@apache.org on 2015/09/23 04:23:46 UTC
[16/50] [abbrv] yetus git commit: Convert 'unit' to 'junit' (aw)
Convert 'unit' to 'junit' (aw)
Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/11ad56e2
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/11ad56e2
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/11ad56e2
Branch: refs/heads/master
Commit: 11ad56e2eb41bbc5e90afc9c8107e57691339a4f
Parents: a627ff0
Author: Allen Wittenauer <aw...@apache.org>
Authored: Mon Aug 3 19:40:51 2015 -0700
Committer: Allen Wittenauer <aw...@apache.org>
Committed: Mon Aug 3 19:40:51 2015 -0700
----------------------------------------------------------------------
dev-support/test-patch.d/junit.sh | 68 ++++++++++++++++++++++++++++++++++
dev-support/test-patch.sh | 53 ++++++++++----------------
2 files changed, 88 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/yetus/blob/11ad56e2/dev-support/test-patch.d/junit.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/junit.sh b/dev-support/test-patch.d/junit.sh
new file mode 100755
index 0000000..4393511
--- /dev/null
+++ b/dev-support/test-patch.d/junit.sh
@@ -0,0 +1,68 @@
+#!/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 junit
+
+JUNIT_TEST_TIMEOUTS=""
+JUNIT_FAILED_TESTS=""
+
+function junit_process_tests
+{
+ # shellcheck disable=SC2034
+ declare module=$1
+ declare buildlogfile=$2
+ declare result=0
+ declare module_test_timeouts
+ declare module_failed_tests
+
+ # shellcheck disable=SC2016
+ module_test_timeouts=$(${AWK} '/^Running / { array[$NF] = 1 } /^Tests run: .* in / { delete array[$NF] } END { for (x in array) { print x } }' "${buildlogfile}")
+ if [[ -n "${module_test_timeouts}" ]] ; then
+ JUNIT_TEST_TIMEOUTS="${JUNIT_TEST_TIMEOUTS} ${module_test_timeouts}"
+ ((result=result+1))
+ fi
+
+ #shellcheck disable=SC2026,SC2038,SC2016
+ module_failed_tests=$(find . -name 'TEST*.xml'\
+ | xargs "${GREP}" -l -E "<failure|<error"\
+ | ${AWK} -F/ '{sub("TEST-org.apache.",""); sub(".xml",""); print $NF}')
+
+ if [[ -n "${module_failed_tests}" ]] ; then
+ JUNIT_FAILED_TESTS="${JUNIT_FAILED_TESTS} ${module_failed_tests}"
+ ((result=result+1))
+ fi
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+function junit_finalize_results
+{
+ declare jdk=$1
+
+ if [[ -n "${JUNIT_FAILED_TESTS}" ]] ; then
+ # shellcheck disable=SC2086
+ populate_test_table "${jdk}Failed junit tests" ${JUNIT_FAILED_TESTS}
+ JUNIT_FAILED_TESTS=""
+ fi
+ if [[ -n "${JUNIT_TEST_TIMEOUTS}" ]] ; then
+ # shellcheck disable=SC2086
+ populate_test_table "${jdk}Timed out junit tests" ${JUNIT_TEST_TIMEOUTS}
+ JUNIT_TEST_TIMEOUTS=""
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/11ad56e2/dev-support/test-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh
index 1f1f88e..1faf99f 100755
--- a/dev-support/test-patch.sh
+++ b/dev-support/test-patch.sh
@@ -102,6 +102,7 @@ function setup_defaults
OSTYPE=$(uname -s)
BUILDTOOL=maven
BUGSYSTEM=jira
+ TESTFORMATS=""
JDK_TEST_LIST="javac javadoc unit"
GITDIFFLINES="${PATCH_DIR}/gitdifflines.txt"
GITDIFFCONTENT="${PATCH_DIR}/gitdiffcontent.txt"
@@ -774,7 +775,7 @@ function testpatch_usage
importplugins
- for plugin in ${PLUGINS} ${BUGSYSTEMS}; do
+ for plugin in ${PLUGINS} ${BUGSYSTEMS} ${TESTFORMATS}; do
if declare -f ${plugin}_usage >/dev/null 2>&1; then
echo
"${plugin}_usage"
@@ -2940,10 +2941,7 @@ function populate_test_table
function check_unittests
{
local i
- local failed_tests=""
- local test_timeouts=""
local test_logfile
- local module_test_timeouts=""
local result=0
local -r savejavahome=${JAVA_HOME}
local multijdkmode=false
@@ -3001,40 +2999,20 @@ function check_unittests
fn="${fn}${jdk}"
test_logfile="${PATCH_DIR}/patch-unit-${fn}.txt"
- # shellcheck disable=2016
- module_test_timeouts=$(${AWK} '/^Running / { array[$NF] = 1 } /^Tests run: .* in / { delete array[$NF] } END { for (x in array) { print x } }' "${test_logfile}")
- if [[ -n "${module_test_timeouts}" ]] ; then
- test_timeouts="${test_timeouts} ${module_test_timeouts}"
- ((result=result+1))
- fi
-
pushd "${MODULE[${i}]}" >/dev/null
- #shellcheck disable=SC2026,SC2038,SC2016
- module_failed_tests=$(find . -name 'TEST*.xml'\
- | xargs "${GREP}" -l -E "<failure|<error"\
- | ${AWK} -F/ '{sub("TEST-org.apache.",""); sub(".xml",""); print $NF}')
- popd >/dev/null
+ for j in ${TESTSYSTEMS}; do
+ if declare -f ${j}_process_tests; then
+ "${j}_process_tests" "${module}" "${test_logfile}"
+ ((results=results+$?))
+ fi
+ done
- if [[ -n "${module_failed_tests}" ]] ; then
- failed_tests="${failed_tests} ${module_failed_tests}"
- ((result=result+1))
- fi
+ popd >/dev/null
((i=i+1))
done
- if [[ -n "${failed_tests}" ]] ; then
- # shellcheck disable=SC2086
- populate_test_table "${statusjdk}Failed unit tests" ${failed_tests}
- failed_tests=""
- fi
- if [[ -n "${test_timeouts}" ]] ; then
- # shellcheck disable=SC2086
- populate_test_table "${statusjdk}Timed out tests" ${test_timeouts}
- test_timeouts=""
- fi
-
done
JAVA_HOME=${savejavahome}
@@ -3433,7 +3411,7 @@ function importplugins
## @replaceable no
function parse_args_plugins
{
- for plugin in ${PLUGINS} ${BUGSYSTEMS}; do
+ for plugin in ${PLUGINS} ${BUGSYSTEMS} ${TESTFORMATS}; do
if declare -f ${plugin}_parse_args >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_parse_args"
#shellcheck disable=SC2086
@@ -3452,7 +3430,7 @@ function add_plugin
PLUGINS="${PLUGINS} $1"
}
-## @description Register test-patch.d plugins
+## @description Register test-patch.d bugsystems
## @audience public
## @stability stable
## @replaceable no
@@ -3461,6 +3439,15 @@ 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 Calculate the differences between the specified files
## @description and output it to stdout.
## @audience public