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

Skip to content

Commit e3bd729

Browse files
committed
Merge branch 'develop' into docker
2 parents 0a95e1d + 9096940 commit e3bd729

124 files changed

Lines changed: 5056 additions & 310 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
2-
.gitattributes export-ignore
3-
.gitignore export-ignore
4-
.gitmodules export-ignore
5-
.travis.yml export-ignore
6-
7-
.travis export-ignore
8-
9-
^docs/* linguist-documentation
1+
.gitattributes export-ignore
2+
.gitignore export-ignore
3+
.gitmodules export-ignore
4+
.travis.yml export-ignore
5+
mkdocs.yml export-ignore
6+
.travis export-ignore
7+
sonar-project.properties export-ignore
8+
^tests/* export-ignore
9+
^development/* export-ignore
10+
^docs/* linguist-documentation

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
55
# User-specific stuff:
66
.idea/
7+
.sonar/
78
site/
89
pages/
910
release/

.travis.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
sudo: false
22
language: python
33

4+
addons:
5+
apt:
6+
packages:
7+
- unzip
8+
# Java8 Required for Sonar and SQLCL
9+
- oracle-java8-installer
10+
- oracle-java8-set-default
11+
sonarqube:
12+
token:
13+
secure: ${SONAR_TOKEN}
14+
branches:
15+
- develop
16+
- master
17+
18+
services:
19+
- docker
20+
421
env:
522
global:
623
- UT3_OWNER=ut3
@@ -24,15 +41,6 @@ env:
2441
- ORACLE_VERSION=$ORACLE_12cR1SE
2542
- ORACLE_VERSION=$ORACLE_11gR2XE
2643

27-
addons:
28-
apt:
29-
packages:
30-
- unzip
31-
- oracle-java8-set-default
32-
33-
services:
34-
- docker
35-
3644
cache:
3745
directories:
3846
- $CACHE_DIR
@@ -59,11 +67,13 @@ script:
5967
# - bash .travis/run_test_as_user.sh
6068
# - bash .travis/build_docs.sh
6169
# - bash .travis/push_docs_to_gh_pages.sh
70+
- sonar-scanner
71+
- bash .travis/coveralls_uploader.sh
6272

6373
deploy:
6474
provider: releases
6575
api_key: $github_api_token
66-
file:
76+
file:
6777
- utPLSQL$TRAVIS_TAG.zip
6878
- utPLSQL$TRAVIS_TAG.tar.gz
6979
skip_cleanup: true

.travis/coveralls_uploader.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var fs = require('fs');
2+
var request = require('request');
3+
const md5File = require('md5-file');
4+
5+
var url
6+
if (process.env.COVERALLS_URL_BASE) {
7+
url = process.env.COVERALLS_URL_BASE+'/api/v1/jobs';
8+
} else {
9+
url = 'https://coveralls.io/api/v1/jobs';
10+
}
11+
12+
fs.readFile('../tests/coverage.json',function (err,data) {
13+
if (err) {
14+
return console.log(err);
15+
}
16+
req = JSON.parse(data);
17+
req.service_job_id = process.env.TRAVIS_JOB_ID;
18+
req.service_name = 'travis-ci';
19+
if (process.env.COVERALLS_REPO_TOKEN) {
20+
req.repo_token = process.env.COVERALLS_REPO_TOKEN;
21+
}
22+
23+
for (var i in req.source_files) {
24+
req.source_files[i].source_digest = md5File.sync("../" + req.source_files[i].name);
25+
}
26+
27+
var requestStr = JSON.stringify(req);
28+
29+
request.post({url : url, form : { json:requestStr}}, function(err, response, body){process.stdout.write(body);});
30+
31+
});

.travis/coveralls_uploader.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh -e
2+
echo "coveralls_uploader"
3+
npm install request --save
4+
npm install --save md5-file
5+
cd "$(dirname "$(readlink -f "$0")")"
6+
exec node coveralls_uploader.js

client_source/sqlplus/ut_run.sql

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ Parameters:
7171
whenever sqlerror exit failure
7272
whenever oserror exit failure
7373
conn &1
74-
whenever sqlerror continue
75-
whenever oserror continue
7674

7775
set serveroutput on size unlimited format truncated
7876
set trimspool on
@@ -115,13 +113,16 @@ set define &
115113
*/
116114
@@define_params_variable.sql.tmp
117115

116+
117+
118118
var l_paths varchar2(4000);
119119
var l_color_enabled varchar2(5);
120120
var l_run_params_cur refcursor;
121121
var l_out_params_cur refcursor;
122122
/*
123-
* Parse parameters and returning as variables
123+
* Parse parameters and return them as variables
124124
*/
125+
set termout on
125126
declare
126127

127128
type t_call_param is record (
@@ -139,6 +140,29 @@ declare
139140
l_run_cursor_sql varchar2(32767);
140141
l_out_cursor_sql varchar2(32767);
141142

143+
function is_reporter(a_reporter_name varchar2) return varchar2 is
144+
l_reporter_name varchar2(4000);
145+
l_dummy integer;
146+
l_owner varchar2(4000);
147+
e_invalid_object exception;
148+
e_not_a_reporter exception;
149+
pragma exception_init (e_invalid_object,-44002);
150+
pragma exception_init (e_not_a_reporter,-6550);
151+
begin
152+
l_reporter_name := upper(dbms_assert.simple_sql_name(a_reporter_name));
153+
-- a report is a valid reporter if it can be assigned as element of ut_reporters collection
154+
execute immediate
155+
'declare
156+
r ut_reporters;
157+
begin
158+
r := ut_reporters('||l_reporter_name||'());
159+
end;';
160+
return l_reporter_name;
161+
exception
162+
when e_not_a_reporter or e_invalid_object then
163+
raise_application_error(-20000, 'Invalid reporter name specified: '||a_reporter_name);
164+
end;
165+
142166
function parse_reporting_params(a_params ut_varchar2_list) return tt_call_params is
143167
l_default_call_param t_call_param;
144168
l_call_params tt_call_params := tt_call_params();
@@ -159,7 +183,7 @@ declare
159183
l_call_params.extend;
160184
l_call_params(l_call_params.last) := l_default_call_param;
161185
if param.param_type = 'f' then
162-
l_call_params(l_call_params.last).ut_reporter_name := dbms_assert.simple_sql_name(param.param_value);
186+
l_call_params(l_call_params.last).ut_reporter_name := is_reporter(param.param_value);
163187
end if;
164188
l_force_out_to_screen := false;
165189
end if;
@@ -241,7 +265,7 @@ begin
241265
end if;
242266
end;
243267
/
244-
268+
set termout off
245269

246270
/*
247271
* Generate runner script
@@ -316,7 +340,7 @@ spool off
316340
*/
317341
set define #
318342
--try running on windows
319-
$ start sqlplus ##1 @run_in_backgroung.sql.tmp
343+
$ start /min sqlplus ##1 @run_in_backgroung.sql.tmp
320344
--try running on linus/unix
321345
! sqlplus ##1 @run_in_backgroung.sql.tmp &
322346
set define &

docs/userguide/annotations.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,20 @@ end test_pkg;
7272
| `%aftereach` | Procedure | Denotes that the annotated procedure should be executed after each `%test` method in the current suite. |
7373
| `%beforetest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed before the annotated `%test` procedure. |
7474
| `%aftertest(<procedure_name>)` | Procedure | Denotes that mentioned procedure should be executed after the annotated `%test` procedure. |
75-
| `%rollback(<type>)` | Package/procedure | Configure transaction control behaviour (type). Supported values: `auto`(default) - rollback to savepoint (before the test/suite setup) is issued after each test/suite teardown; `manual` - rollback is never issued automatically. Property can be overridden for child element (test in suite) |
75+
| `%rollback(<type>)` | Package/procedure | Configure transaction control behaviour (type). Supported values: `auto`(default) - A savepoint is created before invocation of each "before block" is and a rollback to specific savepoint is issued after each "after" block; `manual` - rollback is never issued automatically. Property can be overridden for child element (test in suite) |
7676
| `%disabled` | Package/procedure | Used to disable a suite or a test |
7777

78+
# Using automatic rollbacks in tests
79+
By default, every test is isolated from other tests using savepoint.
80+
This solution is suitable for use-cases, where the code that is getting tested as well as the unit tests themselves do not use transaction control commands (commit/rollback).
81+
In general, your unit tests should not use transaction control as long as the core you are testing is not using it too.
82+
Keeping the transactions uncommitted allows your changes to be isolated and the execution of tests is not impacting others that might be using a shared (integration) development database.
83+
84+
If however you're in situation, where the code you are testing, is using transaction control (like ETL code is usually doing), then your tests should not use the default rollback(auto)
85+
You should make sure that thr entire suitepath all the way to the root is using manual transaction control in that case.
86+
87+
In some cases it is needed to perform DDL in setup/teardown. It is recommended to move such DDL statements to a procedure with pragma autonomous_transaction to eliminate implicit commit of the main session.
88+
7889
# Suitepath concept
7990
It is very likely that the application for which you are going to introduce tests consists of many different packages or procedures/functions. Usually procedures can be logically grouped inside a package, there also might be several logical groups of procedure in a single package or even packages themselves might relate to a common module.
8091

@@ -148,3 +159,4 @@ A `%suitepath` can be provided in tree ways:
148159
* schema - execute all test in the schema
149160
* [schema]:suite1[.suite2][.suite3]...[.procedure] - execute all tests in all suites from suite1[.suite2][.suite3]...[.procedure] path. If schema is not provided, then current schema is used. Example: `:all.rooms_tests`.
150161
* [schema.]package[.procedure] - execute all tests in the test package provided. The whole hierarchy of suites in the schema is build before, all before/after hooks of partn suites for th provided suite package are executed as well. Example: `tests.test_contact.test_last_name_validator` or simply `test_contact.test_last_name_validator` if `tests` is the current schema.
162+

0 commit comments

Comments
 (0)