-
Notifications
You must be signed in to change notification settings - Fork 189
Implemented the runner to execute suites/tests by path #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9abe809
Implemented the runner to execute suites/tests by path
Pazus 9624fb7
fixed example
Pazus 8a6f642
fixed tests
Pazus 4ca671e
addressed review comments
Pazus 382d67c
actualized example packages to use `ut.expect` syntax
Pazus 2660ab1
bug fix.
Pazus 5a5ae8d
step...
Pazus 6860168
step
Pazus cebe94c
added tests for the runner
Pazus e04dba8
Merge remote-tracking branch 'remotes/upstream/version3' into feature…
Pazus 40554c9
Clear the error msg
Pazus 829833b
fix the RunAll.sql script
Pazus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
step...
- Loading branch information
commit 5a5ae8d06850ef531f9dc4fb18bbbffb52afdf74
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -338,9 +338,11 @@ create or replace package body ut_suite_manager is | |
|
|
||
| function get_schema_suites(a_schema_name in varchar2) return tt_schema_suits is | ||
| begin | ||
| if not g_schema_suites.exists(a_schema_name) then | ||
| config_schema(a_schema_name); | ||
| end if; | ||
| -- Currently cache invalidation on DDL is not implemented so schema is rescaned each time | ||
| --if not g_schema_suites.exists(a_schema_name) then | ||
| -- config_schema(a_schema_name); | ||
| --end if; | ||
| config_schema(a_schema_name); | ||
|
|
||
| return g_schema_suites(a_schema_name); | ||
| end get_schema_suites; | ||
|
|
@@ -360,19 +362,17 @@ create or replace package body ut_suite_manager is | |
| end loop; | ||
| end if; | ||
| end validate_paths; | ||
|
|
||
| procedure run(a_paths in ut_varchar2_list, a_reporter in ut_reporter) is | ||
| procedure configure_execution_by_path(a_paths in ut_varchar2_list, a_objects_to_run out nocopy ut_objects_list) is | ||
| l_paths ut_varchar2_list; | ||
| l_path varchar2(32767); | ||
| l_schema varchar2(4000); | ||
| l_objects_to_run ut_objects_list := ut_objects_list(); | ||
| l_schema_suites tt_schema_suits; | ||
| l_index varchar2(4000 char); | ||
| l_suite ut_test_suite; | ||
| l_suite_path varchar2(4000); | ||
| l_root_suite_name varchar2(4000); | ||
| l_reporter ut_reporter := a_reporter; | ||
|
|
||
|
|
||
| function clean_paths(a_paths ut_varchar2_list) return ut_varchar2_list is | ||
| l_paths ut_varchar2_list := ut_varchar2_list(); | ||
| begin | ||
|
|
@@ -383,8 +383,8 @@ create or replace package body ut_suite_manager is | |
| l_paths := set(l_paths); | ||
| return l_paths; | ||
| end clean_paths; | ||
|
|
||
| procedure set_skipped_flag(a_suite in out nocopy ut_test_object, a_path varchar2) is | ||
| procedure skip_by_path(a_suite in out nocopy ut_test_object, a_path varchar2) is | ||
| l_root constant varchar2(32767) := regexp_substr(a_path, '\w+'); | ||
| l_rest_path constant varchar2(32767) := regexp_substr(a_path, '\.(.+)', subexpression => 1); | ||
| l_item ut_test_object; | ||
|
|
@@ -404,7 +404,7 @@ create or replace package body ut_suite_manager is | |
| --l_object_name := regexp_substr(l_object_name,'\w+$'); -- temporary fix. seems like suite have suitepath in object_name | ||
| if regexp_like(l_object_name, l_root, modifier => 'i') then | ||
|
|
||
| set_skipped_flag(l_item, l_rest_path); | ||
| skip_by_path(l_item, l_rest_path); | ||
| l_items.extend; | ||
| l_items(l_items.count) := l_item; | ||
|
|
||
|
|
@@ -418,12 +418,14 @@ create or replace package body ut_suite_manager is | |
| raise_application_error(-20203, 'Suite note found'); | ||
| end if; | ||
| end if; | ||
| end set_skipped_flag; | ||
| end skip_by_path; | ||
|
|
||
| begin | ||
| l_paths := clean_paths(a_paths); | ||
|
|
||
| validate_paths(l_paths); | ||
|
|
||
| a_objects_to_run := ut_objects_list(); | ||
|
|
||
| -- current implementation operates only on a single path | ||
| -- to be improved later | ||
| for i in 1 .. l_paths.count loop | ||
|
|
@@ -436,8 +438,8 @@ create or replace package body ut_suite_manager is | |
| -- run whole schema | ||
| l_index := l_schema_suites.first; | ||
| while l_index is not null loop | ||
| l_objects_to_run.extend; | ||
| l_objects_to_run(l_objects_to_run.count) := l_schema_suites(l_index); | ||
| a_objects_to_run.extend; | ||
| a_objects_to_run(a_objects_to_run.count) := l_schema_suites(l_index); | ||
| l_index := l_schema_suites.next(l_index); | ||
| end loop; | ||
| else | ||
|
|
@@ -464,24 +466,31 @@ create or replace package body ut_suite_manager is | |
|
|
||
| l_suite := l_schema_suites(l_root_suite_name); | ||
|
|
||
| set_skipped_flag(l_suite, regexp_substr(l_suite_path, '\.(.+)', subexpression => 1)); | ||
| skip_by_path(l_suite, regexp_substr(l_suite_path, '\.(.+)', subexpression => 1)); | ||
|
|
||
| l_objects_to_run.extend; | ||
| l_objects_to_run(l_objects_to_run.count) := l_suite; | ||
| a_objects_to_run.extend; | ||
| a_objects_to_run(a_objects_to_run.count) := l_suite; | ||
|
|
||
| end if; | ||
|
|
||
| end loop; | ||
| end configure_execution_by_path; | ||
|
|
||
| procedure run(a_paths in ut_varchar2_list, a_reporter in ut_reporter) is | ||
| l_objects_to_run ut_objects_list; | ||
| l_reporter ut_reporter := a_reporter; | ||
| ut_running_suite ut_test_suite; | ||
| begin | ||
| configure_execution_by_path(a_paths,l_objects_to_run); | ||
|
|
||
| if l_objects_to_run.count > 0 then | ||
| l_reporter.before_run(a_suites => l_objects_to_run); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice. |
||
| for i in 1 .. l_objects_to_run.count loop | ||
| declare | ||
| ut_running_suite ut_test_suite := treat(l_objects_to_run(i) as ut_test_suite); | ||
| begin | ||
| ut_running_suite.do_execute(l_reporter); | ||
| l_objects_to_run(i) := ut_running_suite; | ||
| end; | ||
|
|
||
| ut_running_suite := treat(l_objects_to_run(i) as ut_test_suite); | ||
| ut_running_suite.do_execute(l_reporter); | ||
| l_objects_to_run(i) := ut_running_suite; | ||
|
|
||
| end loop; | ||
| l_reporter.after_run(a_suites => l_objects_to_run); | ||
| end if; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| create or replace package test_package_1 is | ||
|
|
||
| --%suite | ||
| --%suitepackage(tests) | ||
|
|
||
| gv_glob_val number; | ||
|
|
||
| --%setup | ||
| procedure global_setup; | ||
|
|
||
| --%teardown | ||
| procedure global_teardown; | ||
|
|
||
| --%test | ||
| procedure test1; | ||
|
|
||
| --%test | ||
| --%testsetup(test2_setup) | ||
| --%testteardown(test2_teardown) | ||
| procedure test2; | ||
|
|
||
| procedure test2_setup; | ||
|
|
||
| procedure test2_teardown; | ||
|
|
||
| end test_package_1; | ||
| / | ||
| create or replace package body test_package_1 is | ||
|
|
||
| gv_var_1 number; | ||
|
|
||
| gv_var_1_temp number; | ||
|
|
||
| procedure global_setup is | ||
| begin | ||
| gv_var_1 := 1; | ||
| gv_glob_val := 1; | ||
| end; | ||
|
|
||
| procedure global_teardown is | ||
| begin | ||
| gv_var_1 := 0; | ||
| gv_glob_val := 0; | ||
| end; | ||
|
|
||
| procedure test1 is | ||
| begin | ||
| ut.expect(gv_var_1).to_equal(1); | ||
| end; | ||
|
|
||
| procedure test2 is | ||
| begin | ||
| ut.expect(gv_var_1).to_equal(2); | ||
| end; | ||
|
|
||
| procedure test2_setup is | ||
| begin | ||
| gv_var_1_temp := gv_var_1; | ||
| gv_var_1 := 2; | ||
| end; | ||
|
|
||
| procedure test2_teardown is | ||
| begin | ||
| gv_var_1 := gv_var_1_temp; | ||
| gv_var_1_temp := null; | ||
| end; | ||
|
|
||
| end test_package_1; | ||
| / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| create or replace package test_package_2 is | ||
|
|
||
| --%suite | ||
| --%suitepackage(tests.test_package_1) | ||
|
|
||
| gv_glob_val varchar2(1); | ||
|
|
||
| --%setup | ||
| procedure global_setup; | ||
|
|
||
| --%teardown | ||
| procedure global_teardown; | ||
|
|
||
| --%test | ||
| procedure test1; | ||
|
|
||
| --%test | ||
| --%testsetup(test2_setup) | ||
| --%testteardown(test2_teardown) | ||
| procedure test2; | ||
|
|
||
| procedure test2_setup; | ||
|
|
||
| procedure test2_teardown; | ||
|
|
||
| end test_package_2; | ||
| / | ||
| create or replace package body test_package_2 is | ||
|
|
||
| gv_var_1 varchar2(1); | ||
|
|
||
| gv_var_1_temp varchar2(1); | ||
|
|
||
| procedure global_setup is | ||
| begin | ||
| gv_var_1 := 'a'; | ||
| gv_glob_val := 'z'; | ||
| end; | ||
|
|
||
| procedure global_teardown is | ||
| begin | ||
| gv_var_1 := 'n'; | ||
| gv_glob_val := 'n'; | ||
| end; | ||
|
|
||
| procedure test1 is | ||
| begin | ||
| ut.expect(gv_var_1).to_equal('a'); | ||
| end; | ||
|
|
||
| procedure test2 is | ||
| begin | ||
| ut.expect(gv_var_1).to_equal('b'); | ||
| end; | ||
|
|
||
| procedure test2_setup is | ||
| begin | ||
| gv_var_1_temp := gv_var_1; | ||
| gv_var_1 := 'b'; | ||
| end; | ||
|
|
||
| procedure test2_teardown is | ||
| begin | ||
| gv_var_1 := gv_var_1_temp; | ||
| gv_var_1_temp := null; | ||
| end; | ||
|
|
||
| end test_package_2; | ||
| / |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better to extract the find/filter logic into separate procedure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel such separation won't work for multiple pathes provided as be each next path you won't simply add new object to the list, rather you will enable objects in current list to execute... I'd like to postepone this refactoring a bit until it became clear for multi-path approach. But I agree it is needed