-
Notifications
You must be signed in to change notification settings - Fork 188
Add TAP reporter #1305
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
Add TAP reporter #1305
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
933f41a
Added TAP reporter and synonyms
WayneNani c5f07a7
Larger variables to prevent failure during reporting
WayneNani 4ed6837
Added TAP Reporter to install script
WayneNani 5e656fe
Add TAP to expected reporters
WayneNani 6f47bb9
Added simple test for TAP reporter
WayneNani 641ef7d
Added failing test for TAP
WayneNani 2500604
Added erroring Test for TAP reporter
WayneNani 9d765a4
Added test for disabled TAP test
WayneNani ef7f811
Added boilerplate expression for shorter tests
WayneNani 78cc772
Added skipped test with no reason
WayneNani 1e78987
Add explicit spaces for correct indentation
WayneNani ee22669
Added test for multiple test outcomes in one go
WayneNani 55d5b61
Added serverout for beforetest procedures
WayneNani e451e4b
Included print of serverout as comment
WayneNani fb9ef0b
Added suite name escaping
WayneNani f18981d
Included escaped test name
WayneNani f1c0f86
Included escaped skip reason
WayneNani 33865dd
Added escaped comment test
WayneNani a477d68
Central use of comment procedure
WayneNani 2e399fd
Comments shouldn't escape special characters
WayneNani 3193f5b
Added TAP reporter to documentation
WayneNani 707fadd
Added empty lines at the end
WayneNani 7ddbacc
Added tests for contexts and suites
WayneNani 3d38fbe
Added TAP subtests to documentation
WayneNani 18af6b0
Added test for including context when it only contains skipped tests
WayneNani 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
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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,124 @@ | ||
| create or replace type body ut_tap_reporter is | ||
|
|
||
|
|
||
| constructor function ut_tap_reporter(self in out nocopy ut_tap_reporter) return self as result is | ||
| begin | ||
| self.init($$plsql_unit); | ||
| self.lvl := 0; | ||
| return; | ||
| end ut_tap_reporter; | ||
|
|
||
| member procedure print_comment(self in out nocopy ut_tap_reporter, a_comment clob) as | ||
| begin | ||
| self.print_clob(regexp_replace(a_comment, '^', '# ', 1, 0, 'm')); | ||
| end print_comment; | ||
|
|
||
| member function escape_special_chars(self in out nocopy ut_tap_reporter, a_string_to_escape clob) return clob as | ||
| begin | ||
| return regexp_replace(a_string_to_escape, '([\\#])', '\\\1'); | ||
| end escape_special_chars; | ||
|
|
||
| overriding member procedure before_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite) as | ||
| begin | ||
| self.print_text('# Subtest: ' || self.escape_special_chars(coalesce(a_suite.description, a_suite.name))); | ||
| lvl := lvl + 2; | ||
| self.print_text('1..' || a_suite.items.count); | ||
| end before_calling_suite; | ||
|
|
||
|
|
||
| overriding member procedure after_calling_test(self in out nocopy ut_tap_reporter, a_test ut_test) as | ||
| l_message varchar2(4000); | ||
| l_test_name varchar2(4000) := self.escape_special_chars(coalesce(a_test.description, a_test.name)); | ||
|
|
||
| procedure print_failed_expectation(a_test ut_test) is | ||
| l_lines ut_varchar2_list; | ||
| l_failed boolean; | ||
| begin | ||
| if a_test.get_error_stack_traces().count = 0 then | ||
| -- If no error occurred, print failed expectation | ||
| l_lines := a_test.all_expectations(a_test.all_expectations.last).get_result_lines(); | ||
| l_failed := a_test.all_expectations(a_test.all_expectations.last).status >= ut_utils.gc_success; | ||
| if l_failed then | ||
| self.print_text('message: ''' || l_lines(1) || ''''); | ||
| self.print_text('severity: fail'); | ||
| end if; | ||
| else | ||
| -- Print multi-line YAML-String with implicit newline characters | ||
| self.print_text('message: |'); | ||
| self.lvl := self.lvl + 1; | ||
| self.print_text(ut_utils.table_to_clob(a_test.get_error_stack_traces())); | ||
| self.lvl := self.lvl - 1; | ||
| self.print_text('severity: error'); | ||
| end if; | ||
| end print_failed_expectation; | ||
|
|
||
| begin | ||
|
|
||
| if a_test.result = ut_utils.gc_disabled then | ||
| self.print_text('ok - ' || l_test_name || ' # SKIP'|| | ||
| case when a_test.disabled_reason is not null | ||
| then ': '|| self.escape_special_chars(a_test.disabled_reason) | ||
| else null | ||
| end ); | ||
| elsif a_test.result = ut_utils.gc_success then | ||
| self.print_text('ok - ' || l_test_name); | ||
| elsif a_test.result > ut_utils.gc_success then | ||
| if self.lvl = 0 then | ||
| self.print_text(ut_ansiconsole_helper.red('not ok') || ' - ' || l_test_name); | ||
| else | ||
| self.print_text('not ok - ' || l_test_name); | ||
| end if; | ||
| self.lvl := self.lvl + 1; | ||
| self.print_text('---'); | ||
| print_failed_expectation(a_test); | ||
| self.print_text('...'); | ||
| self.lvl := self.lvl - 1; | ||
| end if; | ||
|
|
||
| self.print_comment(a_test.get_serveroutputs); | ||
|
|
||
| end after_calling_test; | ||
|
|
||
| overriding member procedure after_calling_before_all(self in out nocopy ut_tap_reporter, a_executable in ut_executable) is | ||
| begin | ||
| if a_executable.serveroutput is not null and a_executable.serveroutput != empty_clob() then | ||
| self.print_comment(a_executable.serveroutput); | ||
| end if; | ||
| end after_calling_before_all; | ||
|
|
||
| overriding member procedure after_calling_after_all(self in out nocopy ut_tap_reporter, a_executable in ut_executable) is | ||
| begin | ||
| if a_executable.serveroutput is not null and a_executable.serveroutput != empty_clob() then | ||
| self.print_comment(a_executable.serveroutput); | ||
| end if; | ||
| end after_calling_after_all; | ||
|
|
||
| overriding member procedure after_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite) as | ||
| l_suite_name varchar2(4000) := coalesce(a_suite.description, a_suite.name); | ||
| begin | ||
| lvl := lvl - 2; | ||
| if lvl = 0 then | ||
| if a_suite.result = ut_utils.gc_success or a_suite.result = ut_utils.gc_disabled then | ||
| self.print_text('ok - ' || self.escape_special_chars(l_suite_name)); | ||
| elsif a_suite.result > ut_utils.gc_success then | ||
| self.print_text(ut_ansiconsole_helper.red('not ok') || ' - ' || self.escape_special_chars(l_suite_name)); | ||
| end if; | ||
|
|
||
| self.print_text(' '); | ||
| end if; | ||
|
|
||
| end after_calling_suite; | ||
|
|
||
| overriding member procedure before_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run) as | ||
| begin | ||
| self.print_text('TAP version 14'); | ||
| self.print_text('1..' || a_run.items.count); | ||
| self.print_text(' '); | ||
| end before_calling_run; | ||
|
|
||
| overriding member procedure after_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run) as | ||
| begin | ||
| self.lvl := 0; | ||
| end; | ||
| end; | ||
| / | ||
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,18 @@ | ||
| create or replace type ut_tap_reporter under ut_documentation_reporter( | ||
|
|
||
| constructor function ut_tap_reporter(self in out nocopy ut_tap_reporter) return self as result, | ||
| member procedure print_comment(self in out nocopy ut_tap_reporter, a_comment clob), | ||
| member function escape_special_chars(self in out nocopy ut_tap_reporter, a_string_to_escape clob) return clob, | ||
| overriding member procedure before_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite), | ||
|
|
||
| overriding member procedure after_calling_test(self in out nocopy ut_tap_reporter, a_test ut_test), | ||
|
|
||
| overriding member procedure after_calling_before_all (self in out nocopy ut_tap_reporter, a_executable in ut_executable), | ||
| overriding member procedure after_calling_after_all (self in out nocopy ut_tap_reporter, a_executable in ut_executable), | ||
| overriding member procedure before_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run), | ||
| overriding member procedure after_calling_suite(self in out nocopy ut_tap_reporter, a_suite ut_logical_suite), | ||
| overriding member procedure after_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run) | ||
|
|
||
| ) | ||
| not final | ||
| / |
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
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
Oops, something went wrong.
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.
In general, it's probably better to leave an empty newline at the end of each file.