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

Skip to content

Commit bf73441

Browse files
committed
Addressed review comments.
Changed the way client software interacts to pass the `color_enabled` flag.
1 parent d5eb4d0 commit bf73441

12 files changed

Lines changed: 82 additions & 73 deletions

client_source/sqlplus/ut_run.sql

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ declare
115115
begin
116116
dbms_output.put_line(a_text);
117117
end;
118+
l_color_enabled varchar2(5) := case when l_run_params.color_enabled then 'true' else 'false' end;
118119
begin
119120
p( 'set serveroutput on size unlimited format truncated');
120121
p( 'set trimspool on');
@@ -130,12 +131,7 @@ begin
130131
p(' v_reporter.output.output_id := '''||l_run_params.call_params(i).output_id||''';');
131132
p(' v_reporters_list.extend; v_reporters_list(v_reporters_list.last) := v_reporter;');
132133
end loop;
133-
if l_run_params.color_enabled then
134-
p(' ut_reporter_base.set_color_enabled(true);');
135-
else
136-
p(' ut_reporter_base.set_color_enabled(false);');
137-
end if;
138-
p( ' ut_runner.run( ut_varchar2_list('||l_run_params.ut_paths||'), v_reporters_list );');
134+
p( ' ut_runner.run( ut_varchar2_list('||l_run_params.ut_paths||'), v_reporters_list, a_color_console => '||l_color_enabled||' );');
139135
p( 'end;');
140136
p( '/');
141137
p( 'spool off');

source/api/ut_runner.pkb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ create or replace package body ut_runner is
22

33
g_run_params t_run_params;
44

5-
procedure run(a_paths ut_varchar2_list, a_reporters ut_reporters) is
5+
procedure run(a_paths ut_varchar2_list, a_reporters ut_reporters, a_color_console boolean := false) is
66
l_items_to_run ut_run;
77
l_listener ut_event_listener;
88
l_current_suite ut_suite;
99
begin
10+
ut_console_reporter_base.set_color_enabled(a_color_console);
1011
if a_reporters is null or a_reporters.count = 0 then
1112
l_listener := ut_event_listener(ut_reporters(ut_documentation_reporter()));
1213
else
@@ -29,20 +30,20 @@ create or replace package body ut_runner is
2930
raise;
3031
end;
3132

32-
procedure run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter()) is
33+
procedure run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false) is
3334
begin
34-
run(a_paths, ut_reporters(coalesce(a_reporter,ut_documentation_reporter())));
35+
run(a_paths, ut_reporters(coalesce(a_reporter,ut_documentation_reporter())), a_color_console);
3536
end;
3637

3738

38-
procedure run(a_path in varchar2, a_reporter ut_reporter_base := ut_documentation_reporter()) is
39+
procedure run(a_path in varchar2, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false) is
3940
begin
40-
run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporter);
41+
run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporter, a_color_console);
4142
end run;
4243

43-
procedure run(a_path in varchar2, a_reporters in ut_reporters) is
44+
procedure run(a_path in varchar2, a_reporters in ut_reporters, a_color_console boolean := false) is
4445
begin
45-
run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporters);
46+
run(ut_varchar2_list(coalesce(a_path, sys_context('userenv', 'current_schema'))), a_reporters, a_color_console);
4647
end run;
4748

4849
function parse_reporting_params(a_params ut_varchar2_list) return tt_call_params is

source/api/ut_runner.pks

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ create or replace package ut_runner authid current_user is
2929
* parent setup/teardown procedures
3030
*/
3131

32-
procedure run(a_path varchar2 := null, a_reporter ut_reporter_base := ut_documentation_reporter());
32+
procedure run(a_path varchar2 := null, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false);
3333

34-
procedure run(a_path varchar2, a_reporters ut_reporters);
34+
procedure run(a_path varchar2, a_reporters ut_reporters, a_color_console boolean := false);
3535

3636
-- TODO - implementation to be changed
37-
procedure run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter());
37+
procedure run(a_paths ut_varchar2_list, a_reporter ut_reporter_base := ut_documentation_reporter(), a_color_console boolean := false);
3838

3939
-- TODO - implementation to be changed
40-
procedure run(a_paths ut_varchar2_list, a_reporters ut_reporters);
40+
procedure run(a_paths ut_varchar2_list, a_reporters ut_reporters, a_color_console boolean := false);
4141

4242

4343

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
create or replace type body ut_console_reporter_base is
2+
3+
static procedure set_color_enabled(a_flag boolean) is
4+
begin
5+
ut_ansiconsole_helper.color_enabled(a_flag);
6+
end;
7+
8+
member procedure print_red_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
9+
begin
10+
self.print_text(ut_ansiconsole_helper.red(a_text));
11+
end;
12+
13+
member procedure print_green_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
14+
begin
15+
self.print_text(ut_ansiconsole_helper.green(a_text));
16+
end;
17+
18+
member procedure print_yellow_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
19+
begin
20+
self.print_text(ut_ansiconsole_helper.yellow(a_text));
21+
end;
22+
23+
member procedure print_blue_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
24+
begin
25+
self.print_text(ut_ansiconsole_helper.red(a_text));
26+
end;
27+
28+
member procedure print_cyan_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
29+
begin
30+
self.print_text(ut_ansiconsole_helper.cyan(a_text));
31+
end;
32+
33+
member procedure print_magenta_text(self in out nocopy ut_console_reporter_base, a_text varchar2) is
34+
begin
35+
self.print_text(ut_ansiconsole_helper.magenta(a_text));
36+
end;
37+
38+
end;
39+
/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
create or replace type ut_console_reporter_base under ut_reporter_base
2+
(
3+
static procedure set_color_enabled(a_flag boolean),
4+
5+
member procedure print_red_text(self in out nocopy ut_console_reporter_base, a_text varchar2),
6+
7+
member procedure print_green_text(self in out nocopy ut_console_reporter_base, a_text varchar2),
8+
9+
member procedure print_yellow_text(self in out nocopy ut_console_reporter_base, a_text varchar2),
10+
11+
member procedure print_blue_text(self in out nocopy ut_console_reporter_base, a_text varchar2),
12+
13+
member procedure print_cyan_text(self in out nocopy ut_console_reporter_base, a_text varchar2),
14+
15+
member procedure print_magenta_text(self in out nocopy ut_console_reporter_base, a_text varchar2)
16+
17+
) not final not instantiable
18+
/

source/core/types/ut_reporter_base.tpb

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,6 @@ create or replace type body ut_reporter_base is
1212
self.output.send_line(a_text);
1313
end;
1414

15-
static procedure set_color_enabled(a_flag boolean) is
16-
begin
17-
ut_color_helper.color_enabled(a_flag);
18-
end;
19-
20-
member procedure print_red_text(self in out nocopy ut_reporter_base, a_text varchar2) is
21-
begin
22-
self.print_text(ut_color_helper.red(a_text));
23-
end;
24-
25-
member procedure print_green_text(self in out nocopy ut_reporter_base, a_text varchar2) is
26-
begin
27-
self.print_text(ut_color_helper.green(a_text));
28-
end;
29-
30-
member procedure print_yellow_text(self in out nocopy ut_reporter_base, a_text varchar2) is
31-
begin
32-
self.print_text(ut_color_helper.yellow(a_text));
33-
end;
34-
35-
member procedure print_blue_text(self in out nocopy ut_reporter_base, a_text varchar2) is
36-
begin
37-
self.print_text(ut_color_helper.red(a_text));
38-
end;
39-
40-
member procedure print_cyan_text(self in out nocopy ut_reporter_base, a_text varchar2) is
41-
begin
42-
self.print_text(ut_color_helper.cyan(a_text));
43-
end;
44-
45-
member procedure print_magenta_text(self in out nocopy ut_reporter_base, a_text varchar2) is
46-
begin
47-
self.print_text(ut_color_helper.magenta(a_text));
48-
end;
49-
5015
member procedure print_clob(self in out nocopy ut_reporter_base, a_text clob) is
5116
begin
5217
self.output.send_clob(a_text);

source/core/types/ut_reporter_base.tps

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,6 @@ create or replace type ut_reporter_base force authid current_user as object
66

77
member procedure print_text(self in out nocopy ut_reporter_base, a_text varchar2),
88

9-
static procedure set_color_enabled(a_flag boolean),
10-
11-
member procedure print_red_text(self in out nocopy ut_reporter_base, a_text varchar2),
12-
13-
member procedure print_green_text(self in out nocopy ut_reporter_base, a_text varchar2),
14-
15-
member procedure print_yellow_text(self in out nocopy ut_reporter_base, a_text varchar2),
16-
17-
member procedure print_blue_text(self in out nocopy ut_reporter_base, a_text varchar2),
18-
19-
member procedure print_cyan_text(self in out nocopy ut_reporter_base, a_text varchar2),
20-
21-
member procedure print_magenta_text(self in out nocopy ut_reporter_base, a_text varchar2),
22-
239
member procedure print_clob(self in out nocopy ut_reporter_base, a_text clob),
2410

2511
-- run hooks

source/install.sql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ whenever oserror exit failure rollback
1818
@@core/ut_metadata.pks
1919
@@core/ut_utils.pkb
2020
@@core/ut_metadata.pkb
21-
@@core/ut_color_helper.pks
22-
@@core/ut_color_helper.pkb
21+
@@reporters/ut_ansiconsole_helper.pks
22+
@@reporters/ut_ansiconsole_helper.pkb
2323

2424
--core types
2525
@@core/types/ut_assert_result.tps
@@ -68,8 +68,10 @@ whenever oserror exit failure rollback
6868
@@core/types/ut_output_dbms_pipe.tpb
6969
@@core/types/ut_reporter_base.tpb
7070
@@core/types/ut_executable.tpb
71+
@@core/types/ut_console_reporter_base.tps
72+
@@core/types/ut_console_reporter_base.tpb
7173

72-
--expecations and matchers
74+
--expectations and matchers
7375
@@expectations/data_values/ut_data_value.tps
7476
@@expectations/data_values/ut_data_value_anydata.tps
7577
@@expectations/data_values/ut_data_value_blob.tps

source/core/ut_color_helper.pkb renamed to source/reporters/ut_ansiconsole_helper.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create or replace package body ut_color_helper as
1+
create or replace package body ut_ansiconsole_helper as
22
c_red constant varchar2(7) := chr(27) || '[31m';
33
c_green constant varchar2(7) := chr(27) || '[32m';
44
c_yellow constant varchar2(7) := chr(27) || '[33m';

source/core/ut_color_helper.pks renamed to source/reporters/ut_ansiconsole_helper.pks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create or replace package ut_color_helper as
1+
create or replace package ut_ansiconsole_helper as
22
procedure color_enabled(a_enabled boolean);
33
function color_enabled return boolean;
44
function red(a_text varchar2) return varchar2;

0 commit comments

Comments
 (0)