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

Skip to content

Commit 00e7dce

Browse files
committed
Updated ut_run.sql parameters description.
The "-s" parameter is now optional. Invocation with one reporter is now simplified (only reporter class name is needed). Renamed temporary sql files created at runtime. Changed the name of log file created to capture dbms_output from tests.
1 parent 7436277 commit 00e7dce

3 files changed

Lines changed: 54 additions & 30 deletions

File tree

client_source/sqlplus/ut_run.sql

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,31 @@ Scrip invocation:
88
ut_run.sql user password database [ut_path|ut_paths] (-f=format [-o=output] [-s] ...)
99
1010
Parameters:
11-
user - username to connect as
12-
password - password of the user
13-
database - database to connect to
14-
ut_path - a path(s) ot unit test(s) to be executed: user[.package[.procedure]]
15-
ut_paths - a comma separated list of ut_path (with no spaces in between)
16-
-f=format - a format to be used for reporting
17-
-o=output - a file name to put the outputs into
18-
-s - put output to screen can be used in combination with -o
11+
user - username to connect as
12+
password - password of the user
13+
database - database to connect to
14+
ut_path - a path(s) ot unit test(s) to be executed: user[.package[.procedure]]
15+
ut_paths - a comma separated list of ut_path (with no spaces in between)
16+
-f=format - reporter to be used for reporting
17+
-o=output - file name to save the output provided by the reporter.
18+
If defined, the output is not displayed on screen by default. This can be changed with the -s parameter.
19+
If not defined, then output will be displayed on screen, even if the parameter -s is not specified.
20+
If more than one -o parameter is specified for one -f parameter, the last one is taken into consideration.
21+
-s - Forces putting output to to screen for a given -f parameter.
1922
2023
Parameters -f, -o, -s are correlated. That is parameters -o and -s are defining outputs for -f.
21-
Example:
22-
ut_run hr hr xe hr -f=ut_documentation_reporter -o=run.log -s -f=ut_teamcity_reporter -o=teamcity.xml
23-
Unit tests will be be invoked with two reporters:
24-
- ut_documentation_reporter - this one will output to screen and into file "run.log"
25-
- ut_teamcity_reporter - this one will output to file "teamcity.xml"
24+
Examples of invocation using sqlplus from command line:
25+
26+
sqlplus /nolog @ut_run hr hr xe hr -f=ut_documentation_reporter -o=run.log -s -f=ut_teamcity_reporter -o=teamcity.xml
27+
28+
Unit tests will be be invoked with two reporters:
29+
- ut_documentation_reporter - this one will output to screen and into file "run.log"
30+
- ut_teamcity_reporter - this one will output to file "teamcity.xml"
31+
32+
sqlplus /nolog @ut_run hr hr xe hr -f=ut_documentation_reporter
33+
34+
Unit tests will be be invoked with ut_documentation_reporter as a format and the results will be printed to screen
35+
2636
*/
2737

2838
whenever sqlerror exit failure
@@ -44,7 +54,7 @@ set verify off
4454
set heading off
4555

4656
set define off
47-
spool make_input_params_optional.sql
57+
spool make_input_params_optional.sql.tmp
4858
declare
4959
l_sql_columns varchar2(4000);
5060
begin
@@ -58,13 +68,13 @@ end;
5868
spool off
5969
set define &
6070

61-
@@make_input_params_optional.sql
71+
@@make_input_params_optional.sql.tmp
6272

6373

6474
--prepare executor scripts
6575

6676
set define off
67-
spool set_run_params.sql
77+
spool set_run_params.sql.tmp
6878
declare
6979
l_params varchar2(4000);
7080
begin
@@ -78,10 +88,10 @@ spool off
7888
set define &
7989

8090

81-
@@set_run_params.sql
91+
@@set_run_params.sql.tmp
8292

8393

84-
spool run_in_backgroung.sql
94+
spool run_in_backgroung.sql.tmp
8595
declare
8696
l_output_type varchar2(256) := ut_runner.get_streamed_output_type_name();
8797
l_run_params ut_runner.t_run_params := ut_runner.get_run_params();
@@ -94,7 +104,7 @@ begin
94104
p( 'set trimspool on');
95105
p( 'set pagesize 0');
96106
p( 'set linesize 4000');
97-
p( 'spool run_background.log');
107+
p( 'spool ut_run.dbms_output.log');
98108
p( 'declare');
99109
p( ' v_reporter ut_reporter;');
100110
p( ' v_reporters_list ut_reporters_list := ut_reporters_list();');
@@ -113,7 +123,7 @@ end;
113123
/
114124
spool off
115125

116-
spool gather_data_from_outputs.sql
126+
spool gather_data_from_outputs.sql.tmp
117127
declare
118128
l_output_type varchar2(256) := ut_runner.get_streamed_output_type_name();
119129
l_run_params ut_runner.t_run_params := ut_runner.get_run_params();
@@ -136,16 +146,24 @@ end;
136146
/
137147

138148
spool off
139-
149+
set termout off
140150
set define #
141151
--try running on windows
142-
$ start sqlplus ##1/##2@##3 @run_in_backgroung.sql
152+
$ start sqlplus ##1/##2@##3 @run_in_backgroung.sql.tmp
143153
--try running on linus/unix
144-
! sqlplus ##1/##2@##3 @run_in_backgroung.sql &
154+
! sqlplus ##1/##2@##3 @run_in_backgroung.sql.tmp &
145155
set define &
146-
156+
set termout on
147157
--make sure we fetch row by row to indicate the progress
148158
set arraysize 1
149-
@gather_data_from_outputs.sql
159+
@gather_data_from_outputs.sql.tmp
160+
161+
set termout off
162+
--cleanup temporary sql files
163+
--try running on windows
164+
$ del *.sql.tmp
165+
--try running on linus/unix
166+
! rm *.sql.tmp
167+
set termout on
150168

151169
exit

source/core/ut_runner.pkb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ create or replace package body ut_runner is
2929
end run;
3030

3131
procedure set_run_params(a_params ut_varchar2_list) is
32-
l_call_param t_call_param;
33-
l_call_params tt_call_params := tt_call_params();
34-
l_ut_paths varchar2(4000);
32+
l_call_param t_call_param;
33+
l_call_params tt_call_params := tt_call_params();
34+
l_ut_paths varchar2(4000);
35+
l_force_out_to_screen boolean;
3536
begin
3637
for param in
3738
( with
@@ -48,11 +49,16 @@ create or replace package body ut_runner is
4849
l_call_params.extend;
4950
l_call_params(l_call_params.last) := l_call_param;
5051
l_call_params(l_call_params.last).ut_reporter_name := param.param_value;
52+
l_force_out_to_screen := false;
5153
elsif l_call_params.last is not null then
5254
if param.param_type = 'o' then
53-
l_call_params(l_call_params.last).output_file_name := param.param_value;
55+
l_call_params(l_call_params.last).output_file_name := param.param_value;
56+
if not l_force_out_to_screen then
57+
l_call_params(l_call_params.last).output_to_screen := 'off';
58+
end if;
5459
elsif param.param_type = 's' then
5560
l_call_params(l_call_params.last).output_to_screen := 'on';
61+
l_force_out_to_screen := true;
5662
end if;
5763
end if;
5864
end loop;

source/core/ut_runner.pks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ create or replace package ut_runner authid definer is
33
type t_call_param is record (
44
ut_reporter_name varchar2(4000),
55
output_file_name varchar2(4000),
6-
output_to_screen varchar2(3) := 'off',
6+
output_to_screen varchar2(3) := 'on',
77
output_id varchar2(4000)
88
);
99

0 commit comments

Comments
 (0)