You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@yetus.apache.org by aw...@apache.org on 2019/05/02 16:03:24 UTC
[yetus] branch master updated: YETUS-685. add junit xml as a
reporting format (#48)
This is an automated email from the ASF dual-hosted git repository.
aw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yetus.git
The following commit(s) were added to refs/heads/master by this push:
new 1a55acd YETUS-685. add junit xml as a reporting format (#48)
1a55acd is described below
commit 1a55acdcfc7de2853ee5aea4ef68b4180ff61417
Author: Allen Wittenauer <aw...@effectivemachines.com>
AuthorDate: Thu May 2 09:03:19 2019 -0700
YETUS-685. add junit xml as a reporting format (#48)
---
.circleci/config.yml | 12 ++-
.gitlab-ci.yml | 5 +-
Jenkinsfile | 9 +-
precommit/src/main/shell/test-patch.d/junit.sh | 116 +++++++++++++++++++++++++
4 files changed, 139 insertions(+), 3 deletions(-)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index dfdff7c..76ffc36 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -42,8 +42,18 @@ jobs:
--html-report-file=/tmp/yetus-out/report.html
--console-report-file=/tmp/yetus-out/console.txt
--brief-report-file=/tmp/yetus-out/brief.txt
- --bugcomments=briefreport,htmlout
+ --bugcomments=briefreport,htmlout,junit
--tests-filter=checkstyle,javadoc,rubocop,test4tests
+ --junit-results-xml=/tmp/yetus-out/results.xml
+
+ - store_test_results:
+ path: /tmp/yetus-out
- store_artifacts:
path: /tmp/yetus-out
+
+workflows:
+ version: 2
+ build:
+ jobs:
+ - build
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1c8ee4c..c2b65b8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -27,11 +27,14 @@ buretoolbox-job:
--html-report-file=/tmp/yetus-out/report.html
--console-report-file=/tmp/yetus-out/console.txt
--brief-report-file=/tmp/yetus-out/brief.txt
- --bugcomments=briefreport,htmlout,gitlab
+ --bugcomments=briefreport,htmlout,gitlab,junit
--tests-filter=checkstyle,javadoc,rubocop,test4tests
+ --junit-results-xml=/tmp/yetus-out/results.xml
artifacts:
expire_in: 1 week
when: always
paths:
- yetus-out/
+ reports:
+ junit: yetus-out/results.xml
diff --git a/Jenkinsfile b/Jenkinsfile
index 2392586..4addf22 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -128,6 +128,7 @@ pipeline {
YETUS_ARGS+=("--brief-report-file=${WORKSPACE}/${YETUS_RELATIVE_PATCHDIR}/brief.txt")
YETUS_ARGS+=("--console-report-file=${WORKSPACE}/${YETUS_RELATIVE_PATCHDIR}/console.txt")
YETUS_ARGS+=("--html-report-file=${WORKSPACE}/${YETUS_RELATIVE_PATCHDIR}/report.html")
+ YETUS_ARGS+=("--junit-results-xml=${WORKSPACE}/${YETUS_RELATIVE_PATCHDIR}/results.xml")
# enable writing back to Github
YETUS_ARGS+=(--github-password="${GITHUB_PASSWORD}")
@@ -198,9 +199,15 @@ pipeline {
post {
always {
script {
+ // Publish JUnit results
+ try {
+ junit "${env.YETUS_RELATIVE_PATCHDIR}/results.xml"
+ } catch(e) {
+ echo 'junit processing: ' + e.toString()
+ }
+ archiveArtifacts "${env.YETUS_RELATIVE_PATCHDIR}/**"
// Publish the HTML report so that it can be looked at
// Has to be relative to WORKSPACE.
- archiveArtifacts "${env.YETUS_RELATIVE_PATCHDIR}/**"
publishHTML (target: [
allowMissing: true,
keepAll: true,
diff --git a/precommit/src/main/shell/test-patch.d/junit.sh b/precommit/src/main/shell/test-patch.d/junit.sh
index fe9c2a3..c1a0c55 100755
--- a/precommit/src/main/shell/test-patch.d/junit.sh
+++ b/precommit/src/main/shell/test-patch.d/junit.sh
@@ -16,6 +16,7 @@
# SHELLDOC-IGNORE
+add_bugsystem junit
add_test_format junit
JUNIT_TEST_TIMEOUTS=""
@@ -28,6 +29,7 @@ function junit_usage
{
yetus_add_option "--junit-test-output=<path>" "Directory to search for the test output TEST-*.xml files, relative to the module directory (default:'${JUNIT_TEST_OUTPUT_DIR}')"
yetus_add_option "--junit-test-prefix=<prefix to trim>" "Prefix of test names to be be removed. Used to shorten test names by removing common package name. (default:'${JUNIT_TEST_PREFIX}')"
+ yetus_add_option "--junit-results-xml=<path>" "Filename to generate a Junit report"
}
function junit_parse_args
@@ -42,6 +44,9 @@ function junit_parse_args
--junit-test-prefix=*)
JUNIT_TEST_PREFIX=${i#*=}
;;
+ --junit-results-xml=*)
+ JUNIT_RESULTS_XML=${i#*=}
+ ;;
esac
done
}
@@ -92,3 +97,114 @@ function junit_finalize_results
JUNIT_TEST_TIMEOUTS=""
fi
}
+
+## @description Only print selected information to a report file
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param runresult
+## @return 0 on success
+## @return 1 on failure
+function junit_finalreport
+{
+ declare result=$1
+ shift
+ declare i=0
+ declare failures
+ declare ourstring
+ declare vote
+ declare subs
+ declare ela
+ declare footsub
+ declare footcomment
+
+ if [[ -z "${JUNIT_RESULTS_XML}" ]]; then
+ return
+ fi
+
+ big_console_header "Writing JUnit results to ${JUNIT_RESULTS_XML}"
+
+ url=$(get_artifact_url)
+
+cat << EOF > "${JUNIT_RESULTS_XML}"
+<testsuites>
+ <testsuite tests="1" failures="'${result}'" time="1" name="Apache Yetus">
+EOF
+
+ i=0
+ until [[ $i -eq ${#TP_VOTE_TABLE[@]} ]]; do
+ ourstring=$(echo "${TP_VOTE_TABLE[${i}]}" | tr -s ' ')
+ vote=$(echo "${ourstring}" | cut -f2 -d\|)
+ subs=$(echo "${ourstring}" | cut -f3 -d\|)
+ ela=$(echo "${ourstring}" | cut -f4 -d\|)
+ msg=$(echo "${ourstring}" | cut -f5 -d\|)
+
+ subs=${subs// }
+
+ if [[ "${subs}" == "${oldsubs}" ]]; then
+ ((counter=counter+1))
+ else
+ oldsubs=${subs}
+ ((counter=0))
+ fi
+
+ if [[ "${vote}" = "H" ]]; then
+ ((i=i+1))
+ continue
+ fi
+
+ if [[ ${vote// } = -1 ]]; then
+ failures=1
+ else
+ failures=0
+ fi
+
+ {
+ printf "<testcase id=\"%s\" classname=\"%s\" name=\"%s\" failures=\"%s\" tests=\"1\" time=\"%s\">" \
+ "${subs}.${counter}" \
+ "${subs}" \
+ "${subs}" \
+ "${failures}" \
+ "${ela}"
+ if [[ "${failures}" == 1 ]]; then
+ msg="${msg//&/&}"
+ msg="${msg//</<}"
+ msg="${msg//>/>}"
+ msg="${msg//\"/"}"
+ msg="${msg//\'/'}"
+ printf "<failure message=\"%s\">" "${msg}"
+ j=0
+ until [[ $j -eq ${#TP_FOOTER_TABLE[@]} ]]; do
+ if [[ "${TP_FOOTER_TABLE[${j}]}" =~ \@\@BASE\@\@ ]]; then
+ footsub=$(echo "${TP_FOOTER_TABLE[${j}]}" | cut -f2 -d\|)
+ footcomment=$(echo "${TP_FOOTER_TABLE[${j}]}" |
+ cut -f3 -d\| |
+ "${SED}" -e "s,@@BASE@@,${PATCH_DIR},g")
+ if [[ -n "${url}" ]]; then
+ footcomment=$(echo "${TP_FOOTER_TABLE[${j}]}" |
+ cut -f3 -d\| |
+ "${SED}" -e "s,@@BASE@@,${url},g")
+ fi
+ if [[ "${footsub// }" == "${subs}" ]]; then
+ footcomment="${footcomment//&/&}"
+ footcomment="${footcomment//</<}"
+ footcomment="${footcomment//>/>}"
+ footcomment="${footcomment//\"/"}"
+ footcomment="${footcomment//\'/'}"
+ echo "${footcomment}"
+ fi
+ fi
+ ((j=j+1))
+ done
+ echo "</failure>"
+ fi
+ echo "</testcase>"
+ } >> "${JUNIT_RESULTS_XML}"
+
+ ((i=i+1))
+ done
+
+ echo "</testsuite>" >> "${JUNIT_RESULTS_XML}"
+ echo "</testsuites>" >> "${JUNIT_RESULTS_XML}"
+}
+