|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +# contributor license agreements. See the NOTICE file distributed with |
| 4 | +# this work for additional information regarding copyright ownership. |
| 5 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | +# (the "License"); you may not use this file except in compliance with |
| 7 | +# the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +REPORT_DIR=${REPORT_DIR:-$PWD} |
| 18 | + |
| 19 | +## generate summary txt file |
| 20 | +find "." -name 'TEST*.xml' -print0 \ |
| 21 | + | xargs -n1 -0 "grep" -l -E "<failure|<error" \ |
| 22 | + | awk -F/ '{sub("'"TEST-"'",""); sub(".xml",""); print $NF}' \ |
| 23 | + | tee "$REPORT_DIR/summary.txt" |
| 24 | + |
| 25 | +#Copy heap dump and dump leftovers |
| 26 | +find "." -name "*.hprof" -exec cp {} "$REPORT_DIR/" \; |
| 27 | +find "." -name "*.dump" -exec cp {} "$REPORT_DIR/" \; |
| 28 | + |
| 29 | +## Add the tests where the JVM is crashed |
| 30 | +grep -A1 'Crashed tests' "${REPORT_DIR}/output.log" \ |
| 31 | + | grep -v -e 'Crashed tests' -e '--' \ |
| 32 | + | cut -f2- -d' ' \ |
| 33 | + | sort -u >> "${REPORT_DIR}/summary.txt" |
| 34 | + |
| 35 | +#Collect of all of the report failes of FAILED tests |
| 36 | +while IFS= read -r -d '' dir; do |
| 37 | + while IFS=$'\n' read -r file; do |
| 38 | + DIR_OF_TESTFILE=$(dirname "$file") |
| 39 | + NAME_OF_TESTFILE=$(basename "$file") |
| 40 | + NAME_OF_TEST="${NAME_OF_TESTFILE%.*}" |
| 41 | + DESTDIRNAME=$(realpath --relative-to="$PWD" "$DIR_OF_TESTFILE/../..") |
| 42 | + mkdir -p "$REPORT_DIR/$DESTDIRNAME" |
| 43 | + #shellcheck disable=SC2086 |
| 44 | + cp -r "$DIR_OF_TESTFILE"/*$NAME_OF_TEST* "$REPORT_DIR/$DESTDIRNAME/" |
| 45 | + done < <(grep -l -r FAILURE --include="*.txt" "$dir" | grep -v output.txt) |
| 46 | +done < <(find "." -name surefire-reports -print0) |
| 47 | + |
| 48 | +## generate summary markdown file |
| 49 | +export SUMMARY_FILE="$REPORT_DIR/summary.md" |
| 50 | +for TEST_RESULT_FILE in $(find "$REPORT_DIR" -name "*.txt" | grep -v output); do |
| 51 | + |
| 52 | + FAILURES=$(grep FAILURE "$TEST_RESULT_FILE" | grep "Tests run" | awk '{print $18}' | sort | uniq) |
| 53 | + |
| 54 | + for FAILURE in $FAILURES; do |
| 55 | + TEST_RESULT_LOCATION="$(realpath --relative-to="$REPORT_DIR" "$TEST_RESULT_FILE")" |
| 56 | + TEST_OUTPUT_LOCATION="${TEST_RESULT_LOCATION//.txt/-output.txt/}" |
| 57 | + printf " * [%s](%s) ([output](%s))\n" "$FAILURE" "$TEST_RESULT_LOCATION" "$TEST_OUTPUT_LOCATION" >> "$SUMMARY_FILE" |
| 58 | + done |
| 59 | +done |
| 60 | + |
| 61 | +if [ -s "$SUMMARY_FILE" ]; then |
| 62 | + printf "# Failing tests: \n\n" | cat - "$SUMMARY_FILE" > temp && mv temp "$SUMMARY_FILE" |
| 63 | +fi |
| 64 | + |
| 65 | +## generate counter |
| 66 | +wc -l "$REPORT_DIR/summary.txt" | awk '{print $1}'> "$REPORT_DIR/failures" |
0 commit comments