From 3830360975f86db04a9d154e6236401044cc2220 Mon Sep 17 00:00:00 2001 From: Pazus Date: Sun, 21 May 2017 17:12:04 +0300 Subject: [PATCH 1/2] fixed failed expectation source code line reporting because 12c reports with procedure name --- source/core/ut_expectation_processor.pkb | 9 +++- tests/RunAll.sql | 1 + ...ation_reporter.ProducesExpectedOutputs.sql | 48 +++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/ut_reporters/ut_documentation_reporter.ProducesExpectedOutputs.sql diff --git a/source/core/ut_expectation_processor.pkb b/source/core/ut_expectation_processor.pkb index 677e79680..773fafb7b 100644 --- a/source/core/ut_expectation_processor.pkb +++ b/source/core/ut_expectation_processor.pkb @@ -127,9 +127,14 @@ create or replace package body ut_expectation_processor as l_line_no integer; l_owner varchar2(1000); l_object_name varchar2(1000); - c_expectation_search_pattern constant varchar2(50) := '(.*\.UT_EXPECTATION[A-Z0-9#_$]*\s)+(.*)\s'; + --c_expectation_search_pattern constant varchar2(50) := '(.*\.UT_EXPECTATION_RESULT\s)(.*\.UT_EXPECTATION[A-Z0-9#_$]*\.*\s)+(.*)\s'; + + -- in 12.2 format_call_stack reportes not only package name, but also the procedure name + -- when 11g and 12c reports only package name + c_expectation_search_pattern constant varchar2(500) := '(.*\.UT_EXPECTATION_RESULT\s+)(.*\.UT_EXPECTATION[A-Z0-9#_$]*(\.\w+)?.*\s+)+(.*)\s'; begin - l_caller_stack_line := regexp_substr( c_call_stack, c_expectation_search_pattern, 1, 1, 'm', 2); + --dbms_output.put_line(c_call_stack); + l_caller_stack_line := regexp_substr( c_call_stack, c_expectation_search_pattern, 1, 1, 'm', 4); l_line_no := to_number( regexp_substr(l_caller_stack_line,'^\dx[0-9a-f]+\s+(\d+)',subexpression => 1) ); l_caller_type_and_name := substr( l_caller_stack_line, 23 ); if l_caller_stack_line like '%.%' then diff --git a/tests/RunAll.sql b/tests/RunAll.sql index cad9e3035..2229f19ab 100644 --- a/tests/RunAll.sql +++ b/tests/RunAll.sql @@ -125,6 +125,7 @@ exec ut_coverage.coverage_start_develop(); @@lib/RunTest.sql ut_reporters/ut_coverage_sonar_reporter.AcceptsFileMapping.sql @@lib/RunTest.sql ut_reporters/ut_coverage_sonar_reporter.BuildsSonarCoverageReport.sql +@@lib/RunTest.sql ut_reporters/ut_documentation_reporter.ProducesExpectedOutputs.sql @@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.AcceptsFileMapping.sql @@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql @@lib/RunTest.sql ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql diff --git a/tests/ut_reporters/ut_documentation_reporter.ProducesExpectedOutputs.sql b/tests/ut_reporters/ut_documentation_reporter.ProducesExpectedOutputs.sql new file mode 100644 index 000000000..b26d32805 --- /dev/null +++ b/tests/ut_reporters/ut_documentation_reporter.ProducesExpectedOutputs.sql @@ -0,0 +1,48 @@ +declare + l_output_data ut_varchar2_list; + l_output varchar2(32767); + l_expected varchar2(32767); +begin + l_expected := q'[% +%passing_test +% +% +% +% +% +%a test with failing assertion (FAILED - 1) +% +% +% +%a test raising unhandled exception (FAILED - 2) +% +% +% +%a disabled test (IGNORED) +% +%Failures:% +%1)%failing_test +%"Fails as values are different" +%Actual: 1 (number) was expected to equal: 2 (number) +%at "%.TEST_REPORTERS%", line% +%2)%erroring_test +%ORA-06502% +%ORA-06512% +Finished % +4 tests, 1 failed, 1 errored%]'; + + --act + select * + bulk collect into l_output_data + from table(ut.run('test_reporters',ut_documentation_reporter())); + + l_output := ut_utils.table_to_clob(l_output_data); + + --assert + if l_output like l_expected then + :test_result := ut_utils.tr_success; + else + dbms_output.put_line('Actual:"'||l_output||'"'); + end if; +end; +/ From 1d6da239ea52b87ffa64c94f16c5dd8fc403780d Mon Sep 17 00:00:00 2001 From: Pazus Date: Mon, 29 May 2017 21:17:59 +0300 Subject: [PATCH 2/2] addressed reviewer comments --- source/core/ut_expectation_processor.pkb | 5 +---- tests/RunAll.sql | 2 +- ...mentation_reporter.providesCorrectLineFromStacktrace.sql} | 0 3 files changed, 2 insertions(+), 5 deletions(-) rename tests/ut_reporters/{ut_documentation_reporter.ProducesExpectedOutputs.sql => ut_documentation_reporter.providesCorrectLineFromStacktrace.sql} (100%) diff --git a/source/core/ut_expectation_processor.pkb b/source/core/ut_expectation_processor.pkb index 773fafb7b..aad7d0964 100644 --- a/source/core/ut_expectation_processor.pkb +++ b/source/core/ut_expectation_processor.pkb @@ -126,14 +126,11 @@ create or replace package body ut_expectation_processor as l_caller_type_and_name varchar2(4000); l_line_no integer; l_owner varchar2(1000); - l_object_name varchar2(1000); - --c_expectation_search_pattern constant varchar2(50) := '(.*\.UT_EXPECTATION_RESULT\s)(.*\.UT_EXPECTATION[A-Z0-9#_$]*\.*\s)+(.*)\s'; - + l_object_name varchar2(1000); -- in 12.2 format_call_stack reportes not only package name, but also the procedure name -- when 11g and 12c reports only package name c_expectation_search_pattern constant varchar2(500) := '(.*\.UT_EXPECTATION_RESULT\s+)(.*\.UT_EXPECTATION[A-Z0-9#_$]*(\.\w+)?.*\s+)+(.*)\s'; begin - --dbms_output.put_line(c_call_stack); l_caller_stack_line := regexp_substr( c_call_stack, c_expectation_search_pattern, 1, 1, 'm', 4); l_line_no := to_number( regexp_substr(l_caller_stack_line,'^\dx[0-9a-f]+\s+(\d+)',subexpression => 1) ); l_caller_type_and_name := substr( l_caller_stack_line, 23 ); diff --git a/tests/RunAll.sql b/tests/RunAll.sql index 7ab616630..32d57a40b 100644 --- a/tests/RunAll.sql +++ b/tests/RunAll.sql @@ -129,7 +129,7 @@ exec ut_coverage.coverage_start_develop(); @@lib/RunTest.sql ut_reporters/ut_coverage_sonar_reporter.AcceptsFileMapping.sql @@lib/RunTest.sql ut_reporters/ut_coverage_sonar_reporter.BuildsSonarCoverageReport.sql -@@lib/RunTest.sql ut_reporters/ut_documentation_reporter.ProducesExpectedOutputs.sql +@@lib/RunTest.sql ut_reporters/ut_documentation_reporter.providesCorrectLineFromStacktrace.sql @@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.AcceptsFileMapping.sql @@lib/RunTest.sql ut_reporters/ut_sonar_test_reporter.ProducesExpectedOutputs.sql @@lib/RunTest.sql ut_reporters/ut_teamcity_reporter.ProducesExpectedOutputs.sql diff --git a/tests/ut_reporters/ut_documentation_reporter.ProducesExpectedOutputs.sql b/tests/ut_reporters/ut_documentation_reporter.providesCorrectLineFromStacktrace.sql similarity index 100% rename from tests/ut_reporters/ut_documentation_reporter.ProducesExpectedOutputs.sql rename to tests/ut_reporters/ut_documentation_reporter.providesCorrectLineFromStacktrace.sql