@@ -10,12 +10,12 @@ if [ $# -lt 3 ]; then
1010 exit 1
1111fi
1212
13- # parameters
13+ # Parameters
1414RESULT=" $1 "
1515TEST_TYPE=" $2 "
1616WORKSPACE=" $3 "
1717
18- # file paths
18+ # File paths
1919INPUT_FILE=" $WORKSPACE /test/dashboard/logs/$TEST_TYPE /raw_logs.log"
2020OUTPUT_DIR=" $WORKSPACE /test/dashboard/logs/$TEST_TYPE "
2121
@@ -25,16 +25,6 @@ if [ ! -f "$INPUT_FILE" ]; then
2525 exit 1
2626fi
2727
28- load_job_status (){
29- if [ " $RESULT " == " success" ]; then
30- JOB_RESULT=" pass"
31- elif [ " $RESULT " == " failure" ]; then
32- JOB_RESULT=" fail"
33- else
34- JOB_RESULT=" skip"
35- fi
36- }
37-
3828format_log () {
3929 local line=" $1 "
4030 json=" {"
@@ -101,6 +91,7 @@ format_results() {
10191 # Detect if the line is a test start
10292 if [[ " $line " =~ ^=== \ RUN[[:space:]]+ (.+) ]]; then
10393 test_name=" ${BASH_REMATCH[1]} "
94+ has_failed=false
10495
10596 if [[ " ${test_group[0]} " == " name" && " $is_running " == false ]]; then
10697 is_running=true
@@ -126,7 +117,7 @@ format_results() {
126117 continue
127118 fi
128119
129- # Get end time
120+ # Get end time
130121 if [[ " $line " =~ ^([0-9]{4}/[0-9]{2}/[0-9]{2}[[:space:]][0-9]{2}:[0-9]{2}:[0-9]{2}).* INFO[[:space:]]+finished.* test* ]]; then
131122 test_end=" ${BASH_REMATCH[1]} "
132123 if [[ " ${current_test[2]} " == " end_at" ]]; then
@@ -143,14 +134,10 @@ format_results() {
143134 # Capture error messages
144135 if [[ " $line " == * " Error Trace" * || " $line " == * " runtime error" * ]]; then
145136 has_failed=true
146- error_trace+=" $line \n "
137+ error_trace+=" ${ line} " $' \n '
147138 continue
148139 fi
149140
150- # if [[ has_failed==true ]]; then
151- # error_trace+="$line\n"
152- # fi
153-
154141 # Detect result
155142 if [[ " $line " == * " --- PASS" * || " $line " == * " --- FAIL" * ]]; then
156143 [[ " $line " == * " --- PASS" * ]] && result_val=" pass"
@@ -177,6 +164,9 @@ format_results() {
177164 fi
178165 test_group[3]=" $result_val "
179166 if [[ " $result_val " == " fail" ]]; then
167+ if [[ ${test_group[4]} == " msg" ]]; then
168+ test_group[4]=" "
169+ fi
180170 test_group[4]+=" $error_trace "
181171 fi
182172 write_result " ${test_group[1]} " " ${test_group[2]} " " ${test_group[3]} " " ${test_group[4]} " " $OUTPUT_DIR /${test_group[0]} "
@@ -190,6 +180,9 @@ format_results() {
190180 test_match=(" ${test_queue[0]} " " ${test_queue[1]} " " ${test_queue[2]} " " ${test_queue[3]} " " ${test_queue[4]} " )
191181 test_match[3]=" $result_val "
192182 if [[ " $result_val " == " fail" ]]; then
183+ if [[ ${test_match[4]} == " msg" ]]; then
184+ test_match[4]=" "
185+ fi
193186 test_match[4]+=" $error_trace "
194187 fi
195188 write_result " ${test_match[1]} " " ${test_match[2]} " " ${test_match[3]} " " ${test_match[4]} " " $OUTPUT_DIR /${test_match[0]} "
@@ -202,10 +195,16 @@ format_results() {
202195
203196 # No tests to analyze
204197 if [[ " ${test_group[0]} " == " name" && " ${# test_queue[@]} " -eq 0 ]]; then
198+ error_trace=" "
205199 continue
206200 fi
207201 fi
208202
203+ # Capture error messages
204+ if [[ $has_failed == true ]]; then
205+ error_trace+=" ${line} " $' \n '
206+ fi
207+
209208 # Capture logs
210209 if [[ " $line " =~ time= ([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\. [0-9]{3}Z)[[:space:]]+level= ]]; then
211210 LOG_LINE=$( format_log " $line " )
@@ -221,6 +220,5 @@ format_results() {
221220}
222221
223222{
224- load_job_status
225223 format_results
226224}
0 commit comments