-
Notifications
You must be signed in to change notification settings - Fork 3
/
combine_ivt_results.sh
executable file
·39 lines (33 loc) · 1.34 KB
/
combine_ivt_results.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# (C) Copyright IBM Corp. 2020
#
# SPDX-License-Identifier: Apache-2.0
function combineTestResults() {
INPUT_DIRECTORY="${1}"
RESULT_FILE=$2
SUITE_NAME="hri-mgmt-api - $BRANCH_NAME - IVT"
failures=0
testCount=0
errors=0
skipped=0
time=0.0
output=""
for file_name in ${INPUT_DIRECTORY}/*.xml; do
newOutput=""
newTime=0.0
testCount=$((testCount+$(cat "$file_name" | grep -o 'tests="[^"]*' | sed 's/tests="//g')))
failures=$((failures+$(cat "$file_name" | grep -o 'failures="[^"]*' | sed 's/failures="//g')))
errors=$((errors+$(cat "$file_name" | grep -o 'errors="[^"]*' | sed 's/errors="//g')))
skipped=$((skipped+$(cat "$file_name" | grep -o 'skipped="[^"]*' | sed 's/skipped="//g')))
newTime=$(cat "$file_name" | head -2 | tail -1 | grep -o 'time="[^"]*' | sed 's/time="//g')
time=$(awk "BEGIN {print $time+$newTime; exit}")
newOutput=$(cat "$file_name" | tail -n +3 | sed '$d')
output="$output$newOutput"
done
date=`date`
header="<testsuite name=\"$SUITE_NAME\" tests=\"$testCount\" failures=\"$failures\" errors=\"$errors\" skipped=\"${skipped}\" timestamp=\"${date}\" time=\"${time}\">"
footer="</testsuite>"
echo -e "$header\n$output\n$footer" > "$RESULT_FILE"
echo "Finished combining IVT JUnit files"
}
echo $(combineTestResults 'test/ivt_test_results' 'ivttest.xml')