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

Skip to content

Commit 7037319

Browse files
authored
Merge pull request #492 from utPLSQL/feature/annotations_restructuring
Adding cache and restructuring annotations
2 parents 767b4bb + 4f5d870 commit 7037319

74 files changed

Lines changed: 2295 additions & 2122 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.

development/cleanup.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ drop user ${UT3_USER} cascade;
1515
begin
1616
for i in (
1717
select decode(owner,'PUBLIC','drop public synonym "','drop synonym "'||owner||'"."')|| synonym_name ||'"' drop_orphaned_synonym from dba_synonyms a
18-
where not exists (select null from dba_objects b where a.table_name=b.object_name and a.table_owner=b.owner )
19-
and a.table_owner <> 'SYS'
18+
where not exists (select 1 from dba_objects b where (a.table_name=b.object_name and a.table_owner=b.owner or b.owner='SYS' and a.table_owner=b.object_name) )
19+
and a.table_owner not in ('SYS','SYSTEM')
2020
) loop
21+
dbms_output.put_line(i.drop_orphaned_synonym);
2122
execute immediate i.drop_orphaned_synonym;
2223
end loop;
2324
end;

docs/userguide/annotations.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,26 @@ When processing the test suite `test_pkg` defined in [Example of annotated test
214214
rollback to savepoint 'beforeall'
215215
216216
```
217+
218+
# Annotation cache
219+
220+
utPLSQL needs to scan sources of package specifications to identify and parse annotations.
221+
To improve framework startup time, specially when dealing with database users owning large amount of packages the framework has build-in persistent cache for annotations.
222+
223+
Cache is checked for staleness and refreshed automatically on every run.
224+
The initial startup of utPLSQL for a schema will take longer than consecutive executions.
225+
226+
If you're in situation, where your database is controlled via CI/CD server and gets refreshed/wiped before each run of your tests,
227+
consider building upfront and creating the snapshot of our database after the cache was refreshed.
228+
229+
To build annotation cache without actually invoking any tests, call `ut_runner.rebuild_annotation_cache(a_object_owner, a_object_type)` sql block for every unit test owner that you want to have annotations cache prebuilt.
230+
231+
Example:
232+
```sql
233+
exec ut_runner.rebuild_annotation_cache('HR', 'PACKAGE');
234+
```
235+
236+
To purge annotations cache call:
237+
```sql
238+
exec ut_runner.purge_cache('HR', 'PACKAGE');
239+
```

examples/developer_examples/RunExampleTestAnnotationsParsingTimeHugePackage.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ set echo off
66
@@tst_pkg_huge.pks
77

88
declare
9-
l_suite ut_logical_suite;
9+
l_suites ut_suite_items;
1010
begin
11-
l_suite := ut_suite_manager.config_package(a_owner_name => USER,a_object_name => 'TST_PKG_HUGE');
11+
l_suites := ut_suite_manager.configure_execution_by_path(ut_varchar2_list(USER||'.TST_PKG_HUGE'));
1212
end;
1313
/
1414

old_tests/RunAll.sql

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ spool RunAll.log
1818
--Global setup
1919
@@helpers/ut_example_tests.pks
2020
@@helpers/ut_example_tests.pkb
21-
@@helpers/check_annotation_parsing.prc
2221
--@@helpers/cre_tab_ut_test_table.sql
2322
create table ut$test_table (val varchar2(1));
2423
@@helpers/ut_transaction_control.pck
@@ -38,19 +37,6 @@ create table ut$test_table (val varchar2(1));
3837
--Regular coverage excludes the framework
3938
exec ut_coverage.coverage_start_develop();
4039

41-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.IgnoreWrappedPackageAndDoesNotRaiseException.sql
42-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationMixedWithWrongBeforeProcedure.sql
43-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationNotBeforeProcedure.sql
44-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationParamsWithBrackets.sql
45-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageAndProcedureLevelAnnotations.sql
46-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotation.sql
47-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationAccessibleBy.sql
48-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationMultilineDeclare.sql
49-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithKeyValue.sql
50-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParsePackageLevelAnnotationWithMultilineComment.sql
51-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.spaceBeforeAnnotationParams.sql
52-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationWithWindowsNewline.sql
53-
@@lib/RunTest.sql ut_annotations/ut_annotations.parse_package_annotations.ParseProcedureAnnotationWithVeryLongName.sql
5440
@@lib/RunTest.sql ut_expectation_processor/who_called_expectation.parseStackTrace.sql
5541
@@lib/RunTest.sql ut_expectation_processor/who_called_expectation.parseStackTraceWith0x.sql
5642
@@ut_expectations/ut.expect.not_to_be_null.sql
@@ -284,7 +270,6 @@ spool off
284270
--Global cleanup
285271
--removing objects that should not be part of coverage report
286272
drop package ut_example_tests;
287-
drop procedure check_annotation_parsing;
288273
drop package ut_transaction_control;
289274
drop table ut$test_table;
290275
drop type department$;
@@ -341,8 +326,12 @@ begin
341326
'source/api/ut_runner.pks',
342327
'source/core/coverage',
343328
'source/core/types',
344-
'source/core/ut_annotations.pkb',
345-
'source/core/ut_annotations.pks',
329+
'source/core/annotations/ut_annotation_manager.pkb',
330+
'source/core/annotations/ut_annotation_manager.pks',
331+
'source/core/annotations/ut_annotation_parser.pkb',
332+
'source/core/annotations/ut_annotation_parser.pks',
333+
'source/core/annotations/ut_annotation_cache_manager.pkb',
334+
'source/core/annotations/ut_annotation_cache_manager.pks',
346335
'source/core/ut_expectation_processor.pkb',
347336
'source/core/ut_expectation_processor.pks',
348337
'source/core/ut_file_mapper.pkb',

old_tests/helpers/check_annotation_parsing.prc

Lines changed: 0 additions & 70 deletions
This file was deleted.

old_tests/helpers/test_reporters.pks

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ create or replace package test_reporters
22
as
33
--%suite(A suite for testing different outcomes from reporters)
44
--%suitepath(org.utplsql.utplsql.test)
5+
56
--%beforeall
67
procedure beforeall;
78

old_tests/ut_annotations/ut_annotations.parse_package_annotations.IgnoreWrappedPackageAndDoesNotRaiseException.sql

Lines changed: 0 additions & 22 deletions
This file was deleted.

old_tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationMixedWithWrongBeforeProcedure.sql

Lines changed: 0 additions & 47 deletions
This file was deleted.

old_tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationNotBeforeProcedure.sql

Lines changed: 0 additions & 42 deletions
This file was deleted.

old_tests/ut_annotations/ut_annotations.parse_package_annotations.ParseAnnotationParamsWithBrackets.sql

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)