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

Skip to content

Commit 06e4421

Browse files
committed
Removed client_path parameter from file_list script and assume source and tests as default
1 parent df10da0 commit 06e4421

3 files changed

Lines changed: 43 additions & 52 deletions

File tree

client_source/sqlplus/file_list

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,34 @@ invalidArgs=0
77
[ -z "$2" ] && invalidArgs=1
88
[ -z "$3" ] && invalidArgs=1
99
[ -z "$4" ] && invalidArgs=1
10-
[ -z "$5" ] && invalidArgs=1
1110

1211
if [ $invalidArgs -eq 1 ]; then
13-
echo Usage: ut_run.sh "client_path" "project_path" "scan_path" "out_file_name" "sql_param_name"
12+
echo Usage: ut_run.sh "project_path" "scan_path" "sql_param_name" "output_file"
1413
exit 1
1514
fi
1615

17-
clientPath=${1%/}
18-
projectPath=${2%/}
19-
scanPath=$3
20-
outFileName=$4
21-
sqlParamName=$5
16+
# Remove trailing slashes.
17+
projectPath=${1%/}
18+
scanPath=$2
19+
sqlParamName=$3
20+
outputFile=$4
2221

23-
fullOutPath="$clientPath/$outFileName"
2422
fullScanPath="$projectPath/$scanPath"
2523

26-
# If scan path is "-", bypass the file list generation.
27-
if [ "$scanPath" = "-" ]; then
28-
echo "begin" > $fullOutPath
29-
echo " open :$sqlParamName for select null from dual;" >> $fullOutPath
30-
echo "end;" >> $fullOutPath
31-
echo "/" >> $fullOutPath
24+
if [ ! -d "$fullScanPath" ]; then
25+
echo "begin" > $outputFile
26+
echo " open :$sqlParamName for select null from dual;" >> $outputFile
27+
echo "end;" >> $outputFile
28+
echo "/" >> $outputFile
3229
exit 0
3330
fi
3431

35-
echo "declare" > $fullOutPath
36-
echo " l_list ut_varchar2_list := ut_varchar2_list();" >> $fullOutPath
37-
echo "begin" >> $fullOutPath
32+
echo "declare" > $outputFile
33+
echo " l_list ut_varchar2_list := ut_varchar2_list();" >> $outputFile
34+
echo "begin" >> $outputFile
3835
for f in $(find $fullScanPath/* -type f | sed "s|$projectPath/||"); do
39-
echo " l_list.extend; l_list(l_list.last) := '$f';" >> $fullOutPath
36+
echo " l_list.extend; l_list(l_list.last) := '$f';" >> $outputFile
4037
done
41-
echo " open :$sqlParamName for select * from table(l_list);" >> $fullOutPath
42-
echo "end;" >> $fullOutPath
43-
echo "/" >> $fullOutPath
38+
echo " open :$sqlParamName for select * from table(l_list);" >> $outputFile
39+
echo "end;" >> $outputFile
40+
echo "/" >> $outputFile

client_source/sqlplus/file_list.bat

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,37 @@ if "%1" == "" set invalidArgs=1
77
if "%2" == "" set invalidArgs=1
88
if "%3" == "" set invalidArgs=1
99
if "%4" == "" set invalidArgs=1
10-
if "%5" == "" set invalidArgs=1
1110

1211
if %invalidArgs% == 1 (
13-
echo Usage: ut_run.bat "client_path" "project_path" "scan_path" "out_file_name" "sql_param_name"
12+
echo Usage: ut_run.bat "project_path" "scan_path" "sql_param_name" "output_file"
1413
exit /b 1
1514
)
1615

17-
set clientPath=%~1
18-
set projectPath=%~2
19-
set scanPath=%~3
20-
set outFileName=%~4
21-
set sqlParamName=%~5
16+
set projectPath=%~1
17+
set scanPath=%~2
18+
set sqlParamName=%~3
19+
set outputFile=%~4
2220

2321
REM Remove trailing slashes.
24-
if %clientPath:~-1%==\ set clientPath=%clientPath:~0,-1%
2522
if %projectPath:~-1%==\ set projectPath=%projectPath:~0,-1%
26-
27-
set fullOutPath="%clientPath%\%outFileName%"
2823
set fullScanPath="%projectPath%\%scanPath%"
2924

30-
REM If scan path was -, bypass the file list generation.
31-
if "%scanPath%" == "-" (
32-
echo begin>%fullOutPath%
33-
echo ^ open :%sqlParamName% for select null from dual;>>%fullOutPath%
34-
echo end;>>%fullOutPath%
35-
echo />>%fullOutPath%
25+
if not exist "%fullScanPath%\*" (
26+
echo begin>%outputFile%
27+
echo ^ open :%sqlParamName% for select null from dual;>>%outputFile%
28+
echo end;>>%outputFile%
29+
echo />>%outputFile%
3630
exit /b 0
3731
)
3832

39-
echo declare>%fullOutPath%
40-
echo ^ l_list ut_varchar2_list := ut_varchar2_list();>>%fullOutPath%
41-
echo begin>>%fullOutPath%
33+
echo declare>%outputFile%
34+
echo ^ l_list ut_varchar2_list := ut_varchar2_list();>>%outputFile%
35+
echo begin>>%outputFile%
4236
for /f "tokens=* delims= " %%a in ('dir %fullScanPath%\* /B /S /A:-D') do (
4337
set "filePath=%%a"
4438
set filePath=!filePath:%projectPath%\=!
45-
echo ^ l_list.extend; l_list^(l_list.last^) := '!filePath!^';>>%fullOutPath%
39+
echo ^ l_list.extend; l_list^(l_list.last^) := '!filePath!^';>>%outputFile%
4640
)
47-
echo ^ open :%sqlParamName% for select * from table(l_list);>>%fullOutPath%
48-
echo end;>>%fullOutPath%
49-
echo />>%fullOutPath%
41+
echo ^ open :%sqlParamName% for select * from table(l_list);>>%outputFile%
42+
echo end;>>%outputFile%
43+
echo />>%outputFile%

client_source/sqlplus/ut_run.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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) return varchar2 is
261+
function parse_path_param(a_params ut_varchar2_list, a_param_name varchar2, a_default_value 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 := '-';
271+
l_path := a_default_value;
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;
@@ -298,8 +298,8 @@ begin
298298
:l_paths := parse_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');
302-
:l_test_path := parse_path_param(l_input_params,'test_path');
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','tests');
303303

304304
if l_run_cursor_sql is not null then
305305
open :l_run_params_cur for l_run_cursor_sql;
@@ -321,11 +321,11 @@ column test_path new_value test_path noprint;
321321
select :l_test_path as test_path from dual;
322322

323323
--try running on windows
324-
$ "&&client_path\file_list.bat" "&&client_path" "&&project_path" "&&source_path" "source_file_list.sql.tmp" "l_source_files"
325-
$ "&&client_path\file_list.bat" "&&client_path" "&&project_path" "&&test_path" "test_file_list.sql.tmp" "l_test_files"
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"
326326
--try running on linux/unix
327-
! "&&client_path/file_list" "&&client_path" "&&project_path" "&&source_path" "source_file_list.sql.tmp" "l_source_files"
328-
! "&&client_path/file_list" "&&client_path" "&&project_path" "&&test_path" "test_file_list.sql.tmp" "l_test_files"
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"
329329

330330
undef source_path
331331
undef test_path

0 commit comments

Comments
 (0)