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

Skip to content

Commit 4577015

Browse files
authored
Merge pull request #310 from jgebal/bugfix/coverage_with_empty_params
Removed default paths for sources and tests in ut_run script.
2 parents dabf38c + 5aa1a79 commit 4577015

5 files changed

Lines changed: 36 additions & 35 deletions

File tree

client_source/sqlplus/file_list

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@ invalidArgs=0
66
[ -z "$1" ] && invalidArgs=1
77
[ -z "$2" ] && invalidArgs=1
88
[ -z "$3" ] && invalidArgs=1
9-
[ -z "$4" ] && invalidArgs=1
109

1110
if [ $invalidArgs -eq 1 ]; then
12-
echo Usage: ut_run.sh "project_path" "scan_path" "sql_param_name" "output_file"
11+
echo Usage: ut_run.sh "project_path" "sql_param_name" "output_file" "scan_path"
1312
exit 1
1413
fi
1514

1615
# Remove trailing slashes.
1716
projectPath=${1%/}
18-
scanPath=$2
19-
sqlParamName=$3
20-
outputFile=$4
17+
sqlParamName=$2
18+
outputFile=$3
19+
scanPath=$4
2120

2221
fullScanPath="$projectPath/$scanPath"
2322

24-
if [ ! -d "$fullScanPath" ]; then
23+
if [ ! -d "$fullScanPath" ] || [ -z "$4" ]; then
2524
echo "begin" > $outputFile
26-
echo " open :$sqlParamName for select null from dual;" >> $outputFile
25+
echo " open :$sqlParamName for select null from dual where 1= 0;" >> $outputFile
2726
echo "end;" >> $outputFile
2827
echo "/" >> $outputFile
2928
exit 0

client_source/sqlplus/file_list.bat

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,29 @@ setlocal EnableDelayedExpansion
33

44
REM All parameters are required. This way, users can't pass empty string as parameter.
55
set invalidArgs=0
6-
if "%1" == "" set invalidArgs=1
7-
if "%2" == "" set invalidArgs=1
8-
if "%3" == "" set invalidArgs=1
9-
if "%4" == "" set invalidArgs=1
6+
set pathNotProvided=0
7+
if [%1] == "" set invalidArgs=1
8+
if [%2] == "" set invalidArgs=1
9+
if [%3] == "" set invalidArgs=1
1010

1111
if %invalidArgs% == 1 (
12-
echo Usage: ut_run.bat "project_path" "scan_path" "sql_param_name" "output_file"
12+
echo Usage: ut_run.bat "project_path" "sql_param_name" "output_file" "scan_path"
1313
exit /b 1
1414
)
15-
16-
set projectPath=%~1
17-
set scanPath=%~2
18-
set sqlParamName=%~3
19-
set outputFile=%~4
15+
REM Expand relative path from parameter to be a full path
16+
set projectPath=%~f1
17+
set sqlParamName=%~2
18+
set outputFile=%~3
19+
set scanPath=%~4
2020

2121
REM Remove trailing slashes.
2222
if %projectPath:~-1%==\ set projectPath=%projectPath:~0,-1%
23-
set fullScanPath="%projectPath%\%scanPath%"
23+
if [%scanPath%] == [] (set pathNotProvided=1) else (set "fullScanPath=%projectPath%\%scanPath%")
24+
if not exist "%fullScanPath%\*" set pathNotProvided=1
2425

25-
if not exist "%fullScanPath%\*" (
26+
if %pathNotProvided% == 1 (
2627
echo begin>%outputFile%
27-
echo ^ open :%sqlParamName% for select null from dual;>>%outputFile%
28+
echo ^ open :%sqlParamName% for select null from dual where 1 = 0;>>%outputFile%
2829
echo end;>>%outputFile%
2930
echo />>%outputFile%
3031
exit /b 0

client_source/sqlplus/ut_run.sql

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ declare
231231
return l_call_params;
232232
end;
233233

234-
function parse_paths_param(a_params ut_varchar2_list) return varchar2 is
234+
function parse_suite_paths_param(a_params ut_varchar2_list) return varchar2 is
235235
l_paths varchar2(4000);
236236
begin
237237
begin
@@ -258,7 +258,7 @@ declare
258258
return 'false';
259259
end;
260260

261-
function parse_path_param(a_params ut_varchar2_list, a_param_name varchar2, a_default_value varchar2) return varchar2 is
261+
function parse_source_files_path_param(a_params ut_varchar2_list, a_param_name varchar2) return varchar2 is
262262
l_path varchar2(4000);
263263
begin
264264
begin
@@ -268,7 +268,7 @@ declare
268268
where param_value is not null;
269269
exception
270270
when no_data_found then
271-
l_path := a_default_value;
271+
null;
272272
when too_many_rows then
273273
raise_application_error(-20000, 'Parameter "-'||a_param_name||'='||a_param_name||'" defined more than once. Only one "-'||a_param_name||'='||a_param_name||'" parameter can be used.');
274274
end;
@@ -295,18 +295,19 @@ begin
295295
end if;
296296
end loop;
297297

298-
:l_paths := parse_paths_param(l_input_params);
298+
:l_paths := parse_suite_paths_param(l_input_params);
299299
:l_color_enabled := parse_color_enabled(l_input_params);
300300

301-
:l_source_path := parse_path_param(l_input_params,'source_path','source');
302-
:l_test_path := parse_path_param(l_input_params,'test_path','test');
301+
:l_source_path := parse_source_files_path_param(l_input_params,'source_path');
302+
:l_test_path := parse_source_files_path_param(l_input_params,'test_path');
303303

304304
if l_run_cursor_sql is not null then
305305
open :l_run_params_cur for l_run_cursor_sql;
306306
end if;
307307
if l_out_cursor_sql is not null then
308308
open :l_out_params_cur for l_out_cursor_sql;
309309
end if;
310+
dbms_output.put_line(:l_source_path);
310311
end;
311312
/
312313
set termout off
@@ -321,11 +322,11 @@ column test_path new_value test_path noprint;
321322
select :l_test_path as test_path from dual;
322323

323324
--try running on windows
324-
$ "&&client_path\file_list.bat" "&&project_path" "&&source_path" "l_source_files" "&&client_path\source_file_list.sql.tmp"
325-
$ "&&client_path\file_list.bat" "&&project_path" "&&test_path" "l_test_files" "&&client_path\test_file_list.sql.tmp"
325+
$ "&&client_path\file_list.bat" "&&project_path" "l_source_files" "&&client_path\source_file_list.sql.tmp" "&&source_path"
326+
$ "&&client_path\file_list.bat" "&&project_path" "l_test_files" "&&client_path\test_file_list.sql.tmp" "&&test_path"
326327
--try running on linux/unix
327-
! "&&client_path/file_list" "&&project_path" "&&source_path" "l_source_files" "&&client_path/source_file_list.sql.tmp"
328-
! "&&client_path/file_list" "&&project_path" "&&test_path" "l_test_files" "&&client_path/test_file_list.sql.tmp"
328+
! "&&client_path/file_list" "&&project_path" "l_source_files" "&&client_path/source_file_list.sql.tmp" "&&source_path"
329+
! "&&client_path/file_list" "&&project_path" "l_test_files" "&&client_path/test_file_list.sql.tmp" "&&test_path"
329330

330331
undef source_path
331332
undef test_path
@@ -361,7 +362,7 @@ begin
361362
if :l_run_params_cur%isopen then
362363
loop
363364
fetch :l_run_params_cur into l_reporter_id, l_reporter_name;
364-
exit when :l_run_params_cur%notfound;
365+
exit when :l_run_params_cur%notfound;
365366
p(' v_reporter := '||l_reporter_name||'();');
366367
p(' v_reporter.reporter_id := '''||l_reporter_id||''';');
367368
p(' v_reporters_list.extend; v_reporters_list(v_reporters_list.last) := v_reporter;');

docs/about/support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
- Feel free post questions, bugs or issues]to the [issues area of GitHub](https://github.com/utPLSQL/utPLSQL/issues).
5-
- Join developers the [utPLSQL team](http://utplsql-slack-invite.herokuapp.com) on [Slack](https://slack.com/)
5+
- Join developers the [utPLSQL team](http://utplsql-slack-invite.herokuapp.com) on [Slack](https://slack.com/)

source/core/coverage/ut_coverage.pkb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ create or replace package body ut_coverage is
3232
l_result varchar2(32767);
3333
l_full_name varchar2(100);
3434
begin
35-
if a_coverage_options.file_mappings is not null then
35+
if a_coverage_options.file_mappings is not null and a_coverage_options.file_mappings.count > 0 then
3636
l_full_name := 'f.file_name';
3737
else
3838
l_full_name := 'lower(s.owner||''.''||s.name)';
@@ -70,7 +70,7 @@ create or replace package body ut_coverage is
7070
then 'Y'
7171
end as to_be_skipped
7272
from all_source s]';
73-
if a_coverage_options.file_mappings is not null then
73+
if a_coverage_options.file_mappings is not null and a_coverage_options.file_mappings.count > 0 then
7474
l_result := l_result || '
7575
join table(:file_mappings) f
7676
on s.name = f.object_name
@@ -161,7 +161,7 @@ create or replace package body ut_coverage is
161161

162162
--prepare global temp table with sources
163163
delete from ut_coverage_sources_tmp;
164-
if a_coverage_options.file_mappings is not null then
164+
if a_coverage_options.file_mappings is not null and a_coverage_options.file_mappings.count > 0 then
165165
execute immediate populate_sources_tmp_table(a_coverage_options) using a_coverage_options.file_mappings, l_skipped_objects, a_coverage_options.include_objects;
166166
else
167167
execute immediate populate_sources_tmp_table(a_coverage_options) using l_schema_names, l_skipped_objects, a_coverage_options.include_objects;

0 commit comments

Comments
 (0)