Skip to content

Commit 6d54472

Browse files
committed
[report_result] Add testcase error detection and reporting
Previously, report_result.yml only checked for testcase failures but ignored errors in the JUnit XML output. This meant that tests could error out without causing the CI job to fail. This change adds: - Extraction of 'errors' count from XML testsuites - Failure task that triggers when errors > 0 This ensures both failures and errors in testcases are properly reported and cause the CI job to fail as expected.
1 parent 5bb7fe6 commit 6d54472

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ci/report_result.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,20 @@
4444
msg: "There were no XML files found in {{ logs_dir }}."
4545
when: verbose_matches.stdout_lines | length == 0
4646

47+
- name: "Get the number of testcase errors"
48+
ansible.builtin.set_fact:
49+
tasks_errored: "{{ verbose_matches.stdout | regex_replace('.*errors=\"([0-9]*)\".*>', '\\1') | split('\n') | map('int') | sum }}"
50+
4751
- name: "Get the number of failed testcases"
4852
ansible.builtin.set_fact:
4953
tasks_failed: "{{ verbose_matches.stdout | regex_replace('.*failures=\"([0-9]*)\".*>', '\\1') | split('\n') | map('int') | sum }}"
5054

55+
# The RC from grep is 0 if the string is matched
56+
- name: Fail when there's a testcase error
57+
ansible.builtin.fail:
58+
msg: There were {{ tasks_errored }} errors in the testcases.
59+
when: tasks_errored | int > 0 and verbose_matches.rc == 0
60+
5161
# The RC from grep is 0 if the string is matched
5262
- name: Fail when there's a testcase failure
5363
ansible.builtin.fail:

0 commit comments

Comments
 (0)