Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 483b4fc

Browse files
committed
fixed ut_run.sql to execute files from working folder
enhanced Teamcity reporter
1 parent abce191 commit 483b4fc

3 files changed

Lines changed: 67 additions & 41 deletions

File tree

client_source/sqlplus/ut_run.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ set define &
111111
/*
112112
* Make SQLPlus parameters optional and pass parameters call to param_list variable
113113
*/
114-
@@define_params_variable.sql.tmp
114+
@define_params_variable.sql.tmp
115115

116116

117117

@@ -290,8 +290,8 @@ begin
290290
p(' v_reporter.reporter_id := '''||l_reporter_id||''';');
291291
p(' v_reporters_list.extend; v_reporters_list(v_reporters_list.last) := v_reporter;');
292292
end loop;
293+
close :l_run_params_cur;
293294
end if;
294-
close :l_run_params_cur;
295295
p( ' ut_runner.run( ut_varchar2_list('||:l_paths||'), v_reporters_list, a_color_console => '||:l_color_enabled||' );');
296296
p( 'end;');
297297
p( '/');

source/reporters/ut_teamcity_reporter.tpb

Lines changed: 63 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ create or replace type body ut_teamcity_reporter is
22
/*
33
utPLSQL - Version X.X.X.X
44
Copyright 2016 - 2017 utPLSQL Project
5-
5+
66
Licensed under the Apache License, Version 2.0 (the "License"):
77
you may not use this file except in compliance with the License.
88
You may obtain a copy of the License at
9-
9+
1010
http://www.apache.org/licenses/LICENSE-2.0
11-
11+
1212
Unless required by applicable law or agreed to in writing, software
1313
distributed under the License is distributed on an "AS IS" BASIS,
1414
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,84 +24,110 @@ create or replace type body ut_teamcity_reporter is
2424

2525
overriding member procedure before_calling_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_logical_suite) is
2626
begin
27-
self.print_text(
28-
ut_teamcity_reporter_helper.test_suite_started(
29-
a_suite_name => nvl(replace(trim(a_suite.description), '.'),a_suite.name))
30-
);
27+
self.print_text(ut_teamcity_reporter_helper.test_suite_started(a_suite_name => nvl(replace(trim(a_suite.description)
28+
,'.')
29+
,a_suite.name)));
3130
end;
3231

3332
overriding member procedure after_calling_suite(self in out nocopy ut_teamcity_reporter, a_suite in ut_logical_suite) is
3433
begin
35-
self.print_text(
36-
ut_teamcity_reporter_helper.test_suite_finished(
37-
a_suite_name => nvl(replace(trim(a_suite.description), '.'),a_suite.name))
38-
);
34+
self.print_text(ut_teamcity_reporter_helper.test_suite_finished(a_suite_name => nvl(replace(trim(a_suite.description)
35+
,'.')
36+
,a_suite.name)));
3937
end;
4038

4139
overriding member procedure before_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test) is
4240
l_test_full_name varchar2(4000);
4341
begin
44-
45-
l_test_full_name := lower(a_test.item.owner_name)||'.'||lower(a_test.item.object_name)||'.'||lower(a_test.item.procedure_name);
46-
47-
self.print_text(ut_teamcity_reporter_helper.test_started(a_test_name => l_test_full_name,a_capture_standard_output => true));
48-
42+
43+
l_test_full_name := lower(a_test.item.owner_name) || '.' || lower(a_test.item.object_name) || '.' ||
44+
lower(a_test.item.procedure_name);
45+
46+
self.print_text(ut_teamcity_reporter_helper.test_started(a_test_name => l_test_full_name
47+
,a_capture_standard_output => true));
48+
4949
end;
5050

5151
overriding member procedure after_calling_test(self in out nocopy ut_teamcity_reporter, a_test in ut_test) is
52-
l_assert ut_assert_result;
53-
l_test_full_name varchar2(4000);
52+
l_assert ut_assert_result;
53+
l_test_full_name varchar2(4000);
5454
procedure print_output(a_exectable ut_executable) is
5555
l_lines ut_varchar2_list;
5656
begin
57-
if a_exectable is not null and a_exectable.is_defined and a_exectable.serveroutput is not null and dbms_lob.getlength(a_exectable.serveroutput) > 0 then
57+
if a_exectable is not null and a_exectable.is_defined and a_exectable.serveroutput is not null and
58+
dbms_lob.getlength(a_exectable.serveroutput) > 0 then
5859
l_lines := ut_utils.clob_to_table(a_exectable.serveroutput);
59-
for i in 1..l_lines.count loop
60+
for i in 1 .. l_lines.count loop
6061
self.print_text(l_lines(i));
6162
end loop;
6263
end if;
6364
end;
6465
begin
65-
-- l_test_full_name := self.suite_names_stack(self.suite_names_stack.last) || ':' ||
66-
-- nvl(replace(a_test.description, '.'), a_test.name);
67-
l_test_full_name := lower(a_test.item.owner_name)||'.'||lower(a_test.item.object_name)||'.'||lower(a_test.item.procedure_name);
68-
66+
-- l_test_full_name := self.suite_names_stack(self.suite_names_stack.last) || ':' ||
67+
-- nvl(replace(a_test.description, '.'), a_test.name);
68+
l_test_full_name := lower(a_test.item.owner_name) || '.' || lower(a_test.item.object_name) || '.' ||
69+
lower(a_test.item.procedure_name);
70+
6971
if a_test.result = ut_utils.tr_ignore then
7072
self.print_text(ut_teamcity_reporter_helper.test_ignored(l_test_full_name));
7173
else
72-
74+
7375
-- reproduce the output from before/after procedures and the test
7476
print_output(a_test.before_each);
7577
print_output(a_test.before_test);
7678
print_output(a_test.item);
7779
print_output(a_test.after_test);
7880
print_output(a_test.after_each);
79-
80-
if a_test.results is not null and a_test.results.count > 0 then
81+
82+
if a_test.result = ut_utils.tr_error then
83+
self.print_text(ut_teamcity_reporter_helper.test_std_err(a_test_name => l_test_full_name
84+
,a_out => coalesce(a_test.before_each.error_backtrace
85+
,a_test.before_test.error_backtrace
86+
,a_test.item.error_backtrace
87+
,a_test.after_test.error_backtrace
88+
,a_test.after_each.error_backtrace)));
89+
self.print_text(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name
90+
,a_msg => 'Test failed with an exception'
91+
,a_details => coalesce(a_test.before_each.error_stack
92+
,a_test.before_test.error_stack
93+
,a_test.item.error_stack
94+
,a_test.after_test.error_stack
95+
,a_test.after_each.error_stack)));
96+
elsif a_test.results is not null and a_test.results.count > 0 then
8197
for i in 1 .. a_test.results.count loop
82-
98+
8399
l_assert := a_test.results(i);
84-
100+
85101
if l_assert.result > ut_utils.tr_success then
86102
self.print_text(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name
87103
,a_msg => l_assert.message
88-
,a_expected => l_assert.expected_value_string
89-
,a_actual => l_assert.actual_value_string));
104+
,a_expected => case
105+
when l_assert.matcher_name in
106+
('equal', 'be false', 'be true') then
107+
l_assert.expected_value_string
108+
end
109+
,a_actual => case
110+
when l_assert.matcher_name in
111+
('equal', 'be false', 'be true') then
112+
l_assert.actual_value_string
113+
end));
90114
-- Teamcity supports only a single failure message
91115
exit;
92116
end if;
93-
117+
94118
end loop;
95119
elsif a_test.result = ut_utils.tr_failure then
96-
self.print_text(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name, a_msg => 'Test failed'));
120+
self.print_text(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name
121+
,a_msg => 'Test failed'));
97122
elsif a_test.result = ut_utils.tr_error then
98-
self.print_text(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name, a_msg => 'Error occured'));
123+
self.print_text(ut_teamcity_reporter_helper.test_failed(a_test_name => l_test_full_name
124+
,a_msg => 'Error occured'));
99125
end if;
100-
126+
101127
self.print_text(ut_teamcity_reporter_helper.test_finished(l_test_full_name, trunc(a_test.execution_time * 1e3)));
102-
128+
103129
end if;
104-
130+
105131
end;
106132

107133
end;

source/reporters/ut_teamcity_reporter_helper.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ create or replace package body ut_teamcity_reporter_helper is
2121

2222
function escape_value(a_value in varchar2) return varchar2 is
2323
begin
24-
return regexp_replace(a_value, '(''|"|' || chr(13) || '|' || chr(10) || '|[|])', '|\1');
24+
return translate(regexp_replace(a_value, '(''|"|[|]|' || chr(13) || '|' || chr(10) || ')', '|\1'),chr(13)||chr(10),'nr');
2525
end;
2626

2727
function message(a_command in varchar2, a_props t_props default cast(null as t_props)) return varchar2 is
@@ -30,7 +30,7 @@ create or replace package body ut_teamcity_reporter_helper is
3030
l_value varchar2(32767);
3131
begin
3232
l_message := '##teamcity[' || a_command || ' timestamp=''' ||
33-
regexp_replace(to_char(systimestamp, 'YYYY-MM-DD"T"HH24:MI:ss.FFTZHTZM'), '(\.\d{3})\d+(\+)', '\1\2') || '''';
33+
regexp_replace(to_char(systimestamp, 'YYYY-MM-DD"T"HH24:MI:ss.FF3TZHTZM'), '(\.\d{3})\d+(\+)', '\1\2') || '''';
3434

3535
l_index := a_props.first;
3636
while l_index is not null loop

0 commit comments

Comments
 (0)