Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ services:

env:
global:
- UT3_OWNER=ut3
- UT3_OWNER_PASSWORD=ut3
- UT3_RELEASE_VERSION_SCHEMA=UT3_LATEST_RELEASE
- UT3_DEVELOP_SCHEMA=UT3_DEVELOP
- UT3_DEVELOP_SCHEMA_PASSWORD=ut3
- UT3_RELEASE_VERSION_SCHEMA=UT3
- UT3_RELEASE_VERSION_SCHEMA_PASSWORD=ut3
- UT3_USER="UT3\$USER#"
- UT3_USER_PASSWORD=ut3
- UT3_TESTER=ut3_tester
- UT3_TESTER=UT3_TESTER
- UT3_TESTER_PASSWORD=ut3
- UT3_TESTER_HELPER=ut3_tester_helper
- UT3_TESTER_HELPER=UT3_TESTER_HELPER
- UT3_TESTER_HELPER_PASSWORD=ut3
- UT3_TABLESPACE=users
# Environment for building a release
Expand Down
41 changes: 23 additions & 18 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
cd source
set -ev

INSTALL_FILE="install_headless_with_trigger.sql"
if [[ ! -f "${INSTALL_FILE}" ]]; then
INSTALL_FILE="install_headless.sql"
fi

#install core of utplsql
time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL
whenever sqlerror exit failure rollback
Expand All @@ -11,33 +16,33 @@ set verify off

--alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6003,6009,6010,7206)';
alter session set plsql_optimize_level=0;
@install_headless_with_trigger.sql $UT3_OWNER $UT3_OWNER_PASSWORD
@${INSTALL_FILE} $UT3_DEVELOP_SCHEMA $UT3_DEVELOP_SCHEMA_PASSWORD
SQL

#Run this step only on second child job (12.1 - at it's fastest)
if [[ "${TRAVIS_JOB_NUMBER}" =~ \.2$ ]]; then

#check code-style for errors
time "$SQLCLI" $UT3_OWNER/$UT3_OWNER_PASSWORD@//$CONNECTION_STR @../development/utplsql_style_check.sql
time "$SQLCLI" $UT3_DEVELOP_SCHEMA/$UT3_DEVELOP_SCHEMA_PASSWORD@//$CONNECTION_STR @../development/utplsql_style_check.sql

#test install/uninstall process
time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL
set feedback off
set verify off
whenever sqlerror exit failure rollback

@uninstall_all.sql $UT3_OWNER
@uninstall_all.sql $UT3_DEVELOP_SCHEMA
whenever sqlerror exit failure rollback
declare
v_leftover_objects_count integer;
begin
select sum(cnt)
into v_leftover_objects_count
from (
select count(1) cnt from dba_objects where owner = '$UT3_OWNER'
select count(1) cnt from dba_objects where owner = '$UT3_DEVELOP_SCHEMA'
where object_name not like 'PLSQL_PROFILER%' and object_name not like 'DBMSPCC_%'
union all
select count(1) cnt from dba_synonyms where table_owner = '$UT3_OWNER'
select count(1) cnt from dba_synonyms where table_owner = '$UT3_DEVELOP_SCHEMA'
where table_name not like 'PLSQL_PROFILER%' and table_name not like 'DBMSPCC_%'
);
if v_leftover_objects_count > 0 then
Expand All @@ -52,9 +57,9 @@ SQL
set verify off

alter session set plsql_optimize_level=0;
@install.sql $UT3_OWNER
@install_ddl_trigger.sql $UT3_OWNER
@create_synonyms_and_grants_for_public.sql $UT3_OWNER
@install.sql $UT3_DEVELOP_SCHEMA
@install_ddl_trigger.sql $UT3_DEVELOP_SCHEMA
@create_synonyms_and_grants_for_public.sql $UT3_DEVELOP_SCHEMA
SQL

fi
Expand All @@ -65,8 +70,8 @@ set feedback off
whenever sqlerror exit failure rollback

--------------------------------------------------------------------------------
PROMPT Adding back create-trigger privilege to $UT3_OWNER for testing
grant administer database trigger to $UT3_OWNER;
PROMPT Adding back create-trigger privilege to $UT3_DEVELOP_SCHEMA for testing
grant administer database trigger to $UT3_DEVELOP_SCHEMA;

--------------------------------------------------------------------------------
PROMPT Creating $UT3_TESTER - Power-user for testing internal framework code
Expand All @@ -76,27 +81,27 @@ grant create session, create procedure, create type, create table to $UT3_TESTER

grant execute on dbms_lock to $UT3_TESTER;

PROMPT Granting $UT3_OWNER code to $UT3_TESTER
PROMPT Granting $UT3_DEVELOP_SCHEMA code to $UT3_TESTER

begin
for i in (
select object_name from all_objects t
where t.object_type in ('PACKAGE','TYPE')
and owner = 'UT3'
and owner = '$UT3_DEVELOP_SCHEMA'
and generated = 'N'
and object_name not like 'SYS%')
loop
execute immediate 'grant execute on $UT3_OWNER."'||i.object_name||'" to $UT3_TESTER';
execute immediate 'grant execute on $UT3_DEVELOP_SCHEMA."'||i.object_name||'" to $UT3_TESTER';
end loop;
end;
/

PROMPT Granting $UT3_OWNER tables to $UT3_TESTER
PROMPT Granting $UT3_DEVELOP_SCHEMA tables to $UT3_TESTER

begin
for i in ( select table_name from all_tables t where owner = 'UT3' and nested = 'NO' and iot_name is null)
for i in ( select table_name from all_tables t where owner = '$UT3_DEVELOP_SCHEMA' and nested = 'NO' and iot_name is null)
loop
execute immediate 'grant select on $UT3_OWNER.'||i.table_name||' to $UT3_TESTER';
execute immediate 'grant select on $UT3_DEVELOP_SCHEMA.'||i.table_name||' to $UT3_TESTER';
end loop;
end;
/
Expand All @@ -119,11 +124,11 @@ PROMPT Grants for testing distributed transactions
grant create public database link to $UT3_TESTER_HELPER;
grant drop public database link to $UT3_TESTER_HELPER;

PROMPT Grants for testing coverage outside of main UT3 schema.
PROMPT Grants for testing coverage outside of main $UT3_DEVELOP_SCHEMA schema.
grant create any procedure, drop any procedure, execute any procedure, create any type, drop any type, execute any type, under any type,
select any table, update any table, insert any table, delete any table, create any table, drop any table, alter any table,
select any dictionary, create any synonym, drop any synonym,
grant any object privilege, grant any privilege
grant any object privilege, grant any privilege, create public synonym, drop public synonym
to $UT3_TESTER_HELPER;

grant create job to $UT3_TESTER_HELPER;
Expand Down
8 changes: 4 additions & 4 deletions .travis/install_utplsql_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ set trimspool on
declare
i integer := 0;
begin
dbms_output.put_line('Dropping synonyms pointing to schema '||upper('${UT3_OWNER}'));
dbms_output.put_line('Dropping synonyms pointing to schema '||upper('${UT3_DEVELOP_SCHEMA}'));
for syn in (
select
case when owner = 'PUBLIC'
then 'public synonym '
else 'synonym ' || owner || '.' end || synonym_name as syn_name,
table_owner||'.'||table_name as for_object
from all_synonyms s
where table_owner = upper('${UT3_OWNER}') and table_owner != owner
where table_owner = upper('${UT3_DEVELOP_SCHEMA}') and table_owner != owner
)
loop
i := i + 1;
Expand All @@ -28,7 +28,7 @@ begin
dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object);
exception
when others then
dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object);
dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object||' with error '||sqlerrm);
end;
end loop;
dbms_output.put_line(i||' synonyms dropped');
Expand All @@ -45,7 +45,7 @@ fi
alter session set plsql_optimize_level=0;
alter session set plsql_ccflags = 'SELF_TESTING_INSTALL:TRUE';

@${INSTALL_FILE} ${UT3_RELEASE_VERSION_SCHEMA}
@${INSTALL_FILE} ${UT3_RELEASE_VERSION_SCHEMA} ${UT3_RELEASE_VERSION_SCHEMA_PASSWORD}
exit
SQL

Expand Down
9 changes: 4 additions & 5 deletions .travis/run_examples.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash

cd "$(dirname "$(readlink -f "$0")")"/../examples

set -ev

"$SQLCLI" $UT3_OWNER/$UT3_OWNER_PASSWORD@//$CONNECTION_STR <<SQL
whenever sqlerror exit failure rollback
whenever oserror exit failure rollback
"$SQLCLI" $UT3_DEVELOP_SCHEMA/$UT3_DEVELOP_SCHEMA_PASSWORD@//$CONNECTION_STR <<SQL

cd examples
@RunAllExamplesAsTests.sql

exit

SQL
SQL
11 changes: 3 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ Your local environment can be of any flavor (Unix/Linux/Windows/Mac).
At minimum you need to have Oracle database 11.2 XE accessible for the project and SYS account access to install and develop utPLSQL.

We use four different database accounts (users) for development process.
* `ut3_latest_release` - holds latest released version of utPLSQL. This schema holds the testing framework used for self-testing of utPLSQL development.
* `ut3` - holds the version of utPLSQL of your current branch. This is the schema you will be working on.
* `ut3` - holds latest released version of utPLSQL. This schema holds the testing framework used for self-testing of utPLSQL development.
* `ut3_develop` - holds the version of utPLSQL of your current branch. This is the schema you will be working on.
* `ut3_tester` - holds unit test packages for development of utPLSQL.
* `ut3$user#` - used for testing accessibility to schema names with special characters.
* `ut3_tester_helper` - elevated privileges user, used for creating and dropping objects in other schemas during test run.



Expand Down Expand Up @@ -89,12 +90,6 @@ export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string
export ORACLE_PWD=oracle # Adjust your local SYS password
```

### Download Oracle JDBC drivers

Download `ojdbc8-xxx.jar` and `orai18n-xxx.jar` from [Oracle](https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html).
Place them in `development` directory of the project.


### Download utPLSQL release sources and utplsq-cli

The below script is fetching latest release version from utPLSQL repository. Latest release version is used for self-testing.
Expand Down
4 changes: 2 additions & 2 deletions development/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ set echo on
begin
for x in (
select * from dba_objects
where owner in ( upper('${UT3_RELEASE_VERSION_SCHEMA}'), upper('${UT3_OWNER}') )
where owner in ( upper('${UT3_RELEASE_VERSION_SCHEMA}'), upper('${UT3_DEVELOP_SCHEMA}') )
and object_name like 'SYS_PLSQL%')
loop
execute immediate 'drop type '||x.owner||'.'||x.object_name||' force';
end loop;
end;
/

drop user ${UT3_OWNER} cascade;
drop user ${UT3_DEVELOP_SCHEMA} cascade;
drop user ${UT3_RELEASE_VERSION_SCHEMA} cascade;
drop user ${UT3_TESTER} cascade;
drop user ${UT3_TESTER_HELPER} cascade;
Expand Down
2 changes: 1 addition & 1 deletion development/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if ! development/cleanup.sh; then
exit 1
fi
if ! .travis/install.sh; then
echo -e ${header}"\nFailed to install utPLSQL from current branch into ${UT3_OWNER} schema\n"${header}
echo -e ${header}"\nFailed to install utPLSQL from current branch into ${UT3_DEVELOP_SCHEMA} schema\n"${header}
exit 1
fi
if ! .travis/install_utplsql_release.sh; then
Expand Down
1 change: 0 additions & 1 deletion development/refresh_sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/down
# unzip utPLSQL-cli and remove the zip file
unzip utPLSQL-cli.zip && chmod u+x utPLSQL-cli/bin/utplsql && rm utPLSQL-cli.zip

cp development/*.jar utPLSQL-cli/lib/
4 changes: 2 additions & 2 deletions development/refresh_ut3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ git rev-parse && cd "$(git rev-parse --show-cdup)"
cd source

"${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<-SQL
@uninstall ${UT3_OWNER}
@install ${UT3_OWNER}
@uninstall ${UT3_DEVELOP_SCHEMA}
@install ${UT3_DEVELOP_SCHEMA}
exit
SQL
11 changes: 6 additions & 5 deletions development/template.env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ export UTPLSQL_CLI_VERSION="3.1.6"
export SELFTESTING_BRANCH=develop

export UTPLSQL_DIR="utPLSQL_latest_release"
export UT3_OWNER=ut3
export UT3_OWNER_PASSWORD=ut3
export UT3_RELEASE_VERSION_SCHEMA=ut3_latest_release
export UT3_TESTER=ut3_tester
export UT3_DEVELOP_SCHEMA=UT3_DEVELOP
export UT3_DEVELOP_SCHEMA_PASSWORD=ut3
export UT3_RELEASE_VERSION_SCHEMA=UT3
export UT3_RELEASE_VERSION_SCHEMA_PASSWORD=ut3
export UT3_TESTER=UT3_TESTER
export UT3_TESTER_PASSWORD=ut3
export UT3_TESTER_HELPER=ut3_tester_helper
export UT3_TESTER_HELPER=UT3_TESTER_HELPER
export UT3_TESTER_HELPER_PASSWORD=ut3
export UT3_TABLESPACE=users
export UT3_USER="UT3\$USER#"
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Amongst many benefits they provide ability to:
* use many reporting formats simultaneously and save reports to files (publish)
* map your project source files and test files into database objects

Just download the [latest client](https://github.com/utPLSQL/utPLSQL-cli/releases/latest), download Oracle jdbc driver you are good to go.
Download the [latest client](https://github.com/utPLSQL/utPLSQL-cli/releases/latest) and you are good to go.
See [project readme](https://github.com/utPLSQL/utPLSQL-cli/blob/develop/README.md) for details.

# Coverage
Expand Down
10 changes: 8 additions & 2 deletions docs/userguide/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2064,9 +2064,15 @@ When processing the test suite `test_employee_pkg` defined in [Example of annota

## sys_context

It is possible to access information about currently running suite, test and befire/after procedure form within PLSQL procedure using SYS_CONTEXT.

It is possible to access information about currently running suite.
The information is available by calling `sys_context( 'UT3_INFO', attribute )`.
It can be accessed from any procecure invoked as part of utPLSQL test execution.

**Note:**
> Context name is derived from schema name where utPLSQL is installed.
> The context name in below examples represents the default install schema -> `UT3`
> If you install utPLSQL into another schema the context name will be different.
> For example if utPLSQL is installed into `HR` schema, the context name will be `HR_INFO`

Following attributes are populated:
- Always:
Expand Down
2 changes: 1 addition & 1 deletion docs/userguide/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ By default, utPLSQL will convert file paths into database objects using the foll
> This is done to simplify the syntax of regular expressions. Regular expression will always use '/' as a directory separator on a file path regardless of whether you're on a Windows or Unix system.

**Note**
> Below examples assume that you have downloaded latest version of [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli/releases), extracted it into your projects root directory (my_project) and placed ojdbc8.jar and orai18n.jar files in utPLSQL-cli\lib directory.
> Below examples assume that you have downloaded latest version of [utPLSQL-cli](https://github.com/utPLSQL/utPLSQL-cli/releases) and extracted it into your projects root directory (my_project).
> The examples assume that you run the utPLSQL-cli from `my_project` directory.

Windows:
Expand Down
2 changes: 1 addition & 1 deletion docs/userguide/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ To grant utPLSQL to an individual user, execute scripts `source/create_user_gran
Example invocation:
```bash
cd source
sqlplus ut3_user/ut3_password@database @create_user_grants.sql ut3 hr
sqlplus ut3_owner_schema/ut3_password@database @create_user_grants.sql ut3 hr
sqlplus user/user_password@database @create_user_synonyms.sql ut3 hr
```

Expand Down
1 change: 0 additions & 1 deletion docs/userguide/running-unit-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ curl -Lk "${DOWNLOAD_URL}" -o utplsql-cli.zip
unzip -q utplsql-cli.zip
```

Keep in mind that you will need to download/provide Oracle JDBC driver separately, as it is not part of utPLSQL-cli due to licensing restrictions.

# ut.run

Expand Down
4 changes: 2 additions & 2 deletions examples/RunAllExamples.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PROMPT Run all examples
set echo off
set feedback off
set echo on
set feedback on
set linesize 1000

declare
Expand Down
4 changes: 2 additions & 2 deletions examples/RunDeveloperExamples.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PROMPT Run developer examples
Clear Screen
set echo off
set feedback off
set echo on
set feedback on
set linesize 1000

exec ut_ansiconsole_helper.color_enabled(true);
Expand Down
4 changes: 2 additions & 2 deletions examples/RunUserExamples.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PROMPT Run user examples
set echo off
set feedback off
set echo on
set feedback on
set linesize 1000

prompt Common examples from web
Expand Down
2 changes: 1 addition & 1 deletion examples/between_string/run_betwnstr_test_coverage.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set serveroutput on size unlimited format truncated
set feedback off
set termout off
spool coverage.html
exec ut.run(user, ut_coverage_html_reporter(a_project_name=>'Demo of between string function tests', a_include_object_list=>ut_varchar2_list('ut3.betwnstr')));
exec ut.run(user, ut_coverage_html_reporter(a_project_name=>'Demo of between string function tests', a_include_object_list=>ut_varchar2_list('betwnstr')));
spool off


Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Amongst many benefits it provides ability to:
* use many reporting formats simultaneously and save reports to files (publish)
* map your project source files and test files into database objects

Just download the [latest client](https://github.com/utPLSQL/utPLSQL-cli/releases/latest), download Oracle jdbc driver you are good to go.
Download the [latest client](https://github.com/utPLSQL/utPLSQL-cli/releases/latest) and are good to go.
See [project readme](https://github.com/utPLSQL/utPLSQL-cli/blob/develop/README.md) for details.


Expand Down
4 changes: 0 additions & 4 deletions source/core/session_context/ut_session_context.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ create or replace package body ut_session_context as
See the License for the specific language governing permissions and
limitations under the License.
*/
$IF $$SELF_TESTING_INSTALL $THEN
gc_context_name constant varchar2(30) := ut_utils.ut_owner()||'_INFO';
$ELSE
gc_context_name constant varchar2(30) := 'UT3_INFO';
$END

procedure set_context(a_name varchar2, a_value varchar2) is
begin
Expand Down
Loading