|
| 1 | +create or replace package body ut_teamcity_reporter_printer is |
| 2 | + |
| 3 | + subtype t_prop_index is varchar2(2000 char); |
| 4 | + type t_props is table of varchar2(32767) index by t_prop_index; |
| 5 | + |
| 6 | + function escape_value(a_value in varchar2) return varchar2 is |
| 7 | + begin |
| 8 | + return regexp_replace(a_value, '(''|"|' || chr(13) || '|' || chr(10) || '|[|])', '|\1'); |
| 9 | + end; |
| 10 | + |
| 11 | + procedure message(a_command in varchar2, a_props t_props default cast(null as t_props)) is |
| 12 | + l_message varchar2(32767); |
| 13 | + l_index t_prop_index; |
| 14 | + l_value varchar2(32767); |
| 15 | + begin |
| 16 | + l_message := '##teamcity[' || a_command || ' timestamp=''' || |
| 17 | + regexp_replace(to_char(systimestamp, 'YYYY-MM-DD"T"HH24:MI:ss.FFTZHTZM'), '(\.\d{3})\d+(\+)', '\1\2') || ''''; |
| 18 | + |
| 19 | + l_index := a_props.first; |
| 20 | + while l_index is not null loop |
| 21 | + if a_props(l_index) is not null then |
| 22 | + l_value := escape_value(a_props(l_index)); |
| 23 | + l_message := l_message || ' ' || l_index || '=''' || l_value || ''''; |
| 24 | + end if; |
| 25 | + l_index := a_props.next(l_index); |
| 26 | + end loop; |
| 27 | + l_message := l_message || ']'; |
| 28 | + sys.dbms_output.put_line(l_message); |
| 29 | + |
| 30 | + end message; |
| 31 | + |
| 32 | + procedure block_opened(a_name varchar2, a_flow_id varchar2 default null) is |
| 33 | + l_props t_props; |
| 34 | + begin |
| 35 | + l_props('name') := a_name; |
| 36 | + l_props('flowId') := a_flow_id; |
| 37 | + message('blockOpened', l_props); |
| 38 | + end; |
| 39 | + |
| 40 | + procedure block_closed(a_name varchar2, a_flow_id varchar2 default null) is |
| 41 | + l_props t_props; |
| 42 | + begin |
| 43 | + l_props('name') := a_name; |
| 44 | + l_props('flowId') := a_flow_id; |
| 45 | + message('blockClosed', l_props); |
| 46 | + end; |
| 47 | + |
| 48 | + procedure test_suite_started(a_suite_name varchar2, a_flow_id varchar2 default null) is |
| 49 | + l_props t_props; |
| 50 | + begin |
| 51 | + l_props('name') := a_suite_name; |
| 52 | + l_props('flowId') := a_flow_id; |
| 53 | + message('testSuiteStarted', l_props); |
| 54 | + end; |
| 55 | + procedure test_suite_finished(a_suite_name varchar2, a_flow_id varchar2 default null) is |
| 56 | + l_props t_props; |
| 57 | + begin |
| 58 | + l_props('name') := a_suite_name; |
| 59 | + l_props('flowId') := a_flow_id; |
| 60 | + message('testSuiteFinished', l_props); |
| 61 | + end; |
| 62 | + |
| 63 | + procedure test_started(a_test_name varchar2, a_capture_standard_output boolean default null, a_flow_id varchar2 default null) is |
| 64 | + l_props t_props; |
| 65 | + begin |
| 66 | + l_props('name') := a_test_name; |
| 67 | + l_props('captureStandardOutput') := case a_capture_standard_output |
| 68 | + when true then |
| 69 | + 'true' |
| 70 | + when false then |
| 71 | + 'false' |
| 72 | + else |
| 73 | + null |
| 74 | + end; |
| 75 | + l_props('flowId') := a_flow_id; |
| 76 | + message('testStarted', l_props); |
| 77 | + end; |
| 78 | + |
| 79 | + procedure test_finished(a_test_name varchar2, a_test_duration_milisec number default null, a_flow_id varchar2 default null) is |
| 80 | + l_props t_props; |
| 81 | + begin |
| 82 | + l_props('name') := a_test_name; |
| 83 | + l_props('duration') := a_test_duration_milisec; |
| 84 | + l_props('flowId') := a_flow_id; |
| 85 | + message('testFinished', l_props); |
| 86 | + end; |
| 87 | + |
| 88 | + procedure test_ignored(a_test_name varchar2, a_flow_id varchar2 default null) is |
| 89 | + l_props t_props; |
| 90 | + begin |
| 91 | + l_props('name') := a_test_name; |
| 92 | + l_props('flowId') := a_flow_id; |
| 93 | + message('testIgnored', l_props); |
| 94 | + end; |
| 95 | + procedure test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) is |
| 96 | + l_props t_props; |
| 97 | + begin |
| 98 | + l_props('name') := a_test_name; |
| 99 | + l_props('message') := a_msg; |
| 100 | + l_props('details') := a_details; |
| 101 | + l_props('flowId') := a_flow_id; |
| 102 | + |
| 103 | + if a_actual is not null and a_expected is not null then |
| 104 | + l_props('actual') := a_actual; |
| 105 | + l_props('expected') := a_expected; |
| 106 | + end if; |
| 107 | + |
| 108 | + message('testFailed', l_props); |
| 109 | + end; |
| 110 | + procedure test_std_out(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) is |
| 111 | + l_props t_props; |
| 112 | + begin |
| 113 | + l_props('name') := a_test_name; |
| 114 | + l_props('out') := a_out; |
| 115 | + l_props('flowId') := a_flow_id; |
| 116 | + message('testStdOut', l_props); |
| 117 | + end; |
| 118 | + procedure test_std_err(a_test_name varchar2, a_out in varchar2, a_flow_id in varchar2 default null) is |
| 119 | + l_props t_props; |
| 120 | + begin |
| 121 | + l_props('name') := a_test_name; |
| 122 | + l_props('out') := a_out; |
| 123 | + l_props('flowId') := a_flow_id; |
| 124 | + message('testStdErr', l_props); |
| 125 | + end; |
| 126 | + |
| 127 | + procedure custom_message(a_text in varchar2, a_status in varchar2, a_error_deatils in varchar2 default null, a_flow_id in varchar2 default null) is |
| 128 | + l_props t_props; |
| 129 | + begin |
| 130 | + l_props('text') := a_text; |
| 131 | + l_props('status') := a_status; |
| 132 | + l_props('errorDetails') := a_error_deatils; |
| 133 | + l_props('flowId') := a_flow_id; |
| 134 | + message('message', l_props); |
| 135 | + end; |
| 136 | + |
| 137 | +end ut_teamcity_reporter_printer; |
| 138 | +/ |
0 commit comments