Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
933f41a
Added TAP reporter and synonyms
WayneNani Jul 10, 2025
c5f07a7
Larger variables to prevent failure during reporting
WayneNani Jul 10, 2025
4ed6837
Added TAP Reporter to install script
WayneNani Jul 11, 2025
5e656fe
Add TAP to expected reporters
WayneNani Jul 11, 2025
6f47bb9
Added simple test for TAP reporter
WayneNani Jul 14, 2025
641ef7d
Added failing test for TAP
WayneNani Jul 15, 2025
2500604
Added erroring Test for TAP reporter
WayneNani Jul 15, 2025
9d765a4
Added test for disabled TAP test
WayneNani Jul 16, 2025
ef7f811
Added boilerplate expression for shorter tests
WayneNani Jul 16, 2025
78cc772
Added skipped test with no reason
WayneNani Jul 18, 2025
1e78987
Add explicit spaces for correct indentation
WayneNani Jul 18, 2025
ee22669
Added test for multiple test outcomes in one go
WayneNani Jul 18, 2025
55d5b61
Added serverout for beforetest procedures
WayneNani Jul 18, 2025
e451e4b
Included print of serverout as comment
WayneNani Jul 21, 2025
fb9ef0b
Added suite name escaping
WayneNani Jul 21, 2025
f18981d
Included escaped test name
WayneNani Jul 26, 2025
f1c0f86
Included escaped skip reason
WayneNani Jul 26, 2025
33865dd
Added escaped comment test
WayneNani Jul 27, 2025
a477d68
Central use of comment procedure
WayneNani Jul 27, 2025
2e399fd
Comments shouldn't escape special characters
WayneNani Jul 29, 2025
3193f5b
Added TAP reporter to documentation
WayneNani Aug 2, 2025
707fadd
Added empty lines at the end
WayneNani Mar 16, 2026
7ddbacc
Added tests for contexts and suites
WayneNani Mar 17, 2026
3d38fbe
Added TAP subtests to documentation
WayneNani Mar 17, 2026
18af6b0
Added test for including context when it only contains skipped tests
WayneNani Mar 17, 2026
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
Prev Previous commit
Next Next commit
Added suite name escaping
  • Loading branch information
WayneNani committed Jul 21, 2025
commit fb9ef0badc83c3d90eb37d393add96d693b8f729
11 changes: 8 additions & 3 deletions source/reporters/ut_tap_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ create or replace type body ut_tap_reporter is
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: ' || coalesce(a_suite.description, a_suite.name));
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;
Expand Down Expand Up @@ -94,9 +99,9 @@ create or replace type body ut_tap_reporter is
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 - ' || l_suite_name);
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') || ' - ' || l_suite_name);
self.print_text(ut_ansiconsole_helper.red('not ok') || ' - ' || self.escape_special_chars(l_suite_name));
end if;

self.print_text(' ');
Expand Down
1 change: 1 addition & 0 deletions source/reporters/ut_tap_reporter.tps
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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),
Expand Down
71 changes: 65 additions & 6 deletions test/ut3_user/reporters/test_tap_reporter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,52 @@ create or replace package body test_tap_reporter as

gc_boilerplate_suitepath_expression constant varchar2(300) := 'TAP version 14\s*1..1\s*# Subtest: org\s{5}1..1\s{5}# Subtest: utplsql\s{9}1..1\s{9}# Subtest: tests\s{13}1..1\s{13}# Subtest: helpers\s{17}1..1\s{17}# Subtest: A suite for testing different outcomes from reporters';


procedure compile_tests as
pragma autonomous_transaction;
begin

execute immediate q'[
Comment thread
jgebal marked this conversation as resolved.
create or replace package test_tap_escaping as
--%suite(Some \ and # to be escaped)

--%test(Even more \\ and multiple ###)
procedure more_escaping;

--%test(Disabled test)
--%disabled(With \ and # in skip reason)
procedure not_skipping_escapes;
end test_tap_escaping;
]';

execute immediate q'[
create or replace package body test_tap_escaping as

procedure more_escaping as
begin
ut.expect(1).to_equal(1);
end more_escaping;


procedure not_skipping_escapes as
begin
ut.expect(10).to_equal(1);
end not_skipping_escapes;

end test_tap_escaping;
]';

end compile_tests;


procedure simple_succeeding_test as
l_output_data ut3_develop.ut_varchar2_list;
l_expected varchar2(32767);
begin
l_expected := gc_boilerplate_suitepath_expression || '\s{21}1..1\s{21}# <!beforeall!>\s{21}# Subtest: A description of some context\s{25}1..1\s{25}ok - passing_test\s{25}# <!beforeeach!>\s{25}# <!beforetest!>\s{25}# <!passing test!>\s{25}# <!aftertest!>\s{25}# <!aftereach!>\s{21}# <!afterall!>\sok - org\s*';

select *
bulk collect into l_output_data
bulk collect into l_output_data
from table(ut3_develop.ut.run('test_reporters.passing_test',ut3_develop.ut_tap_reporter()));

ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected);
Expand All @@ -22,7 +60,7 @@ create or replace package body test_tap_reporter as
l_expected := gc_boilerplate_suitepath_expression || q'[\s{21}1..1\s{21}# <!beforeall!>\s{21}not ok - a test with failing assertion\s{23}---\s{23}message: '"Fails as values are different"'\s{23}severity: fail\s{23}...\s{21}# <!beforeeach!>\s{21}# <!failing test!>\s{21}# <!aftereach!>\s{21}# <!afterall!>\snot ok - org\s*]';

select *
bulk collect into l_output_data
bulk collect into l_output_data
from table(ut3_develop.ut.run('test_reporters.failing_test',ut3_develop.ut_tap_reporter()));

ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected);
Expand All @@ -36,7 +74,7 @@ create or replace package body test_tap_reporter as
l_expected := gc_boilerplate_suitepath_expression || q'[\s{21}1..1\s{21}# <!beforeall!>\s{21}not ok - a test raising unhandled exception\s{23}---\s{23}message: |\s{25ORA-06502: .*\s{25}ORA-06512: at line [[:digit:]]+\s{23}severity: error\s{23}...\s{21}# <!beforeeach!>\s{21}# <!erroring test!>\s{21}# <!aftereach!>\s{21}# <!afterall!>\snot ok - org\s*]';

select *
bulk collect into l_output_data
bulk collect into l_output_data
from table(ut3_develop.ut.run('test_reporters.erroring_test',ut3_develop.ut_tap_reporter()));

ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected);
Expand All @@ -50,7 +88,7 @@ create or replace package body test_tap_reporter as
l_expected := gc_boilerplate_suitepath_expression || q'[\s{21}1..1\s{21}# <!beforeall!>\s{21}ok - a disabled test # SKIP: Disabled for testing purpose\s{21}# <!afterall!>\sok - org\s*]';

select *
bulk collect into l_output_data
bulk collect into l_output_data
from table(ut3_develop.ut.run('test_reporters.disabled_test',ut3_develop.ut_tap_reporter()));

ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected);
Expand All @@ -64,7 +102,7 @@ create or replace package body test_tap_reporter as
l_expected := gc_boilerplate_suitepath_expression || q'[\s{21}1..1\s{21}# <!beforeall!>\s{21}ok - a disabled test with no reason # SKIP\s{21}# <!afterall!>\sok - org\s*]';

select *
bulk collect into l_output_data
bulk collect into l_output_data
from table(ut3_develop.ut.run('test_reporters.disabled_test_no_reason',ut3_develop.ut_tap_reporter()));

ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected);
Expand All @@ -78,10 +116,31 @@ create or replace package body test_tap_reporter as
l_expected := q'[TAP version 14\s*1..1\s*# Subtest: org.*# Subtest: A suite.*\s{21}1..5\s{21}# <!beforeall!>\s{21}# Subtest: A desc.*\s{25}1..1\s{25}ok - passing_test\s{25}# <!beforeeach!>\s{25}# <!beforet.*\s{25}# <!aftereach!>\s{21}not ok - a test w.*\s{23}---\s{23}message:.*\s{21}# <!beforeeach!>.*\s{21}# <!aftereach!>not ok - a test rai.*\s{23}---\s{23}message: |.*ok - a disabled test # SKIP: Disabled for testing purpose.*ok - a dis.* # SKIP\s{21}# <!afterall!>\snot ok - org\s*]';

select *
bulk collect into l_output_data
bulk collect into l_output_data
from table(ut3_develop.ut.run('test_reporters',ut3_develop.ut_tap_reporter()));

ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_match(l_expected, 'n');
end multiple_tests_different_outcome;


procedure escape_suite_name as
l_output_data ut3_develop.ut_varchar2_list;
l_expected varchar2(32767);
begin
l_expected := q'[%# Subtest: Some \\ and \# to be escaped%ok - Some \\ and \# to be escaped%]';

select *
bulk collect into l_output_data
from table(ut3_develop.ut.run('test_tap_escaping.more_escaping',ut3_develop.ut_tap_reporter()));

ut.expect(ut3_tester_helper.main_helper.table_to_clob(l_output_data)).to_be_like(l_expected);
end escape_suite_name;


procedure drop_help_tests as
pragma autonomous_transaction;
begin
execute immediate 'drop package test_tap_escaping';
end drop_help_tests;
end test_tap_reporter;
/
10 changes: 10 additions & 0 deletions test/ut3_user/reporters/test_tap_reporter.pks
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ create or replace package test_tap_reporter as
--%suite(ut_tap_reporter)
--%suitepath(utplsql.test_user.reporters)

--%beforeall
procedure compile_tests;

--%test(Simple succeeding test)
procedure simple_succeeding_test;

Expand All @@ -21,5 +24,12 @@ create or replace package test_tap_reporter as
--%test(Multiple tests with different outcome)
procedure multiple_tests_different_outcome;

--%test(Escape special characters in suite name)
procedure escape_suite_name;


--%afterall
procedure drop_help_tests;

end test_tap_reporter;
Comment thread
jgebal marked this conversation as resolved.
/