diff --git a/.github/DISCUSSION_TEMPLATE/README.md b/.github/DISCUSSION_TEMPLATE/README.md deleted file mode 100644 index f6c0905f4..000000000 --- a/.github/DISCUSSION_TEMPLATE/README.md +++ /dev/null @@ -1,150 +0,0 @@ -# GitHub Discussions β€” setup guide for utPLSQL/utPLSQL - -This folder contains the discussion category form templates that power structured -GitHub Discussions for the utPLSQL project. - ---- - -## File β†’ category mapping - - - -| File | Category name to create in GitHub | Format | Who can post | -|------------------------|-----------------------------------|-----------------------|--------------------------------| -| `announcements.yml` | πŸ“’ Announcements | Announcement | Maintainers only | -| `rfcs-design.yml` | πŸ’‘ RFCs & Design | Open-ended discussion | Everyone | -| `architecture.yml` | πŸ— Architecture | Open-ended discussion | Everyone | -| `release-planning.yml` | πŸ—“ Release Planning | Open-ended discussion | Maintainers only (recommended) | -| `q-a.yml` | ❓ Q&A | Question / Answer | Everyone | -| `show-and-tell.yml` | πŸ”¬ Show & Tell | Open-ended discussion | Everyone | -| `contributors.yml` | 🀝 Contributors | Open-ended discussion | Everyone | -| `general.yml` | πŸ’¬ General | Open-ended discussion | Everyone | - -> **Polls** are a built-in GitHub Discussions type and do not support YAML templates. -> Create a πŸ—³ Polls category manually (type: Poll) β€” no template file needed. - ---- - -## Step-by-step setup - -### 1. Enable Discussions -Go to **Settings β†’ Features** and check **Discussions**. - -### 2. Create the categories -Go to **Discussions β†’ Categories β†’ ✏️ Edit categories** (gear icon). - -Create each category listed in the table above. -**Order matters** β€” drag to set the display order shown below: - -1. πŸ“’ Announcements -2. πŸ’‘ RFCs & Design -3. πŸ— Architecture -4. πŸ—“ Release Planning -5. ❓ Q&A -6. πŸ”¬ Show & Tell -7. 🀝 Contributors -8. πŸ—³ Polls -9. πŸ’¬ General - -### 3. Commit the templates -Copy all `.yml` files from this folder into `.github/DISCUSSION_TEMPLATE/` in -the **default branch** (usually `develop` for utPLSQL). - -``` -.github/ -└── DISCUSSION_TEMPLATE/ - β”œβ”€β”€ announcements.yml - β”œβ”€β”€ rfcs-design.yml - β”œβ”€β”€ architecture.yml - β”œβ”€β”€ release-planning.yml - β”œβ”€β”€ q-a.yml - β”œβ”€β”€ show-and-tell.yml - β”œβ”€β”€ contributors.yml - └── general.yml -``` - -### 4. Configure category permissions - -| Category | Setting | -|------------------|--------------------------------------------------| -| Announcements | Set to **Maintainers only** in category settings | -| Release Planning | Recommended: **Maintainers only** | -| All others | Open to all | - -### 5. Create the welcome pinned post - -Create a first discussion in **Announcements** titled -**"Welcome to utPLSQL Discussions β€” how to use this space"** - -Suggested body: - -```markdown -## Welcome πŸ‘‹ - -This is the place for design discussions, feature proposals, and community -conversation around utPLSQL. - -### Where to post - -| I want to… | Use | -|---|---| -| Propose a new feature or behaviour change | πŸ’‘ RFCs & Design | -| Discuss internal architecture | πŸ— Architecture | -| Ask a usage / how-to question | ❓ Q&A | -| Share a CI pipeline, integration, or tip | πŸ”¬ Show & Tell | -| Ask about contributing / development setup | 🀝 Contributors | -| Vote on priorities | πŸ—³ Polls | -| Anything else | πŸ’¬ General | - -### Discussions vs Issues - -**Discussions** are for ideas that are still open, need input, or require consensus. -**Issues** are for well-scoped work that someone can pick up and implement. - -A maintainer will convert a Discussion to an Issue once scope is agreed. - -### Real-time chat - -For quick questions: [utPLSQL Slack](https://utplsql.slack.com) -For decisions that need a permanent record: post here. -``` - -Pin this post from the discussion's `…` menu β†’ **Pin discussion**. - -### 6. Update the README - -Add a Discussions badge to the project README: - -```markdown -[![GitHub Discussions](https://img.shields.io/github/discussions/utPLSQL/utPLSQL)](https://github.com/utPLSQL/utPLSQL/discussions) -``` - -And add a short paragraph in the "Community" or "Contributing" section pointing -to Discussions as the place for design proposals. - ---- - -## Operating guidelines - -### Discussion β†’ Issue conversion rule - -| Category | Convert when… | -|---------------|----------------------------------------------------------------------| -| RFCs & Design | Consensus reached, scope is defined | -| Architecture | Breaking change formally agreed by maintainers | -| Q&A | A confirmed bug surfaces in the thread | -| Contributors | A gap in docs or tooling is identified that can be filed as an issue | - -Use the **"Create issue from discussion"** button (available in the discussion's sidebar). - -### Housekeeping - -- Lock **Announcements** threads after 30 days. -- Close **Polls** after 14 days; post a summary comment with the result before closing. -- Label cross-references: apply the same labels used on issues - (`enhancement`, `breaking-change`, `coverage`, `oracle-version`, etc.) - to discussions for consistent search. diff --git a/.github/DISCUSSION_TEMPLATE/announcements.yml b/.github/DISCUSSION_TEMPLATE/announcements.yml deleted file mode 100644 index 262746e11..000000000 --- a/.github/DISCUSSION_TEMPLATE/announcements.yml +++ /dev/null @@ -1,54 +0,0 @@ -title: "[Announcement] " -labels: ["announcement"] -body: - - type: markdown - attributes: - value: | - > **Maintainers only.** This category is restricted to project maintainers. - > Announcements are pinned and locked after 30 days. - - - type: dropdown - id: announcement_type - attributes: - label: Announcement type - options: - - New release - - Release candidate / pre-release - - Roadmap update - - Deprecation notice - - Security advisory - - Community / governance update - - Other - validations: - required: true - - - type: input - id: version - attributes: - label: Version (if applicable) - placeholder: "e.g. 3.2.0" - validations: - required: false - - - type: textarea - id: body - attributes: - label: Announcement body - description: | - Write the full announcement here. - For releases, include: highlights, breaking changes, upgrade notes, and a link to the full changelog. - validations: - required: true - - - type: textarea - id: links - attributes: - label: Key links - description: Release tag, changelog, migration guide, Docker image, CLI download, etc. - placeholder: | - - Release: https://github.com/utPLSQL/utPLSQL/releases/tag/v… - - Changelog: … - - Docker: … - - CLI: … - validations: - required: false diff --git a/.github/DISCUSSION_TEMPLATE/architecture.yml b/.github/DISCUSSION_TEMPLATE/architecture.yml deleted file mode 100644 index f3df8e29c..000000000 --- a/.github/DISCUSSION_TEMPLATE/architecture.yml +++ /dev/null @@ -1,100 +0,0 @@ -title: "[Architecture] " -labels: ["architecture", "design"] -body: - - type: markdown - attributes: - value: | - ## Architecture discussion - Use this template for internal design decisions: changes to the suite-loading mechanism, - the coverage engine, DDL trigger behaviour, reporter infrastructure, or any - cross-cutting concern that affects the internals of utPLSQL. - - This category is primarily for **contributors and maintainers**. - If you want to propose a user-facing feature, use **RFCs & Design** instead. - - - type: input - id: title_short - attributes: - label: Component / area - description: Which internal component or subsystem does this discussion concern? - placeholder: "e.g. Suite loader, Coverage engine, Annotation parser, Event system" - validations: - required: true - - - type: textarea - id: context - attributes: - label: Context and current design - description: Briefly describe how the relevant part works today. - validations: - required: true - - - type: textarea - id: problem - attributes: - label: Problem or design question - description: What specific decision needs to be made, or what limitation needs to be addressed? - validations: - required: true - - - type: textarea - id: options - attributes: - label: Options under consideration - description: | - List the design options you are weighing. For each option describe: - - How it works - - Pros - - Cons - - Impact on Oracle compatibility - placeholder: | - **Option A β€” …** - How: … - Pros: … - Cons: … - - **Option B β€” …** - How: … - Pros: … - Cons: … - validations: - required: true - - - type: textarea - id: preferred - attributes: - label: Preferred direction (if any) - description: If you already lean toward one option, say so and why. Leave blank if genuinely open. - validations: - required: false - - - type: dropdown - id: breaking - attributes: - label: Does this introduce a breaking change? - options: - - "No" - - "Yes β€” public API change (ut_runner, ut packages, annotations)" - - "Yes β€” output/reporter format change" - - "Yes β€” internal package change (no public API impact)" - - "Unsure" - validations: - required: true - - - type: textarea - id: migration - attributes: - label: Migration / compatibility notes - description: If breaking, describe the migration path for users and downstream integrations. - validations: - required: false - - - type: checkboxes - id: checklist - attributes: - label: Checklist - options: - - label: I have reviewed the existing architecture docs and source - required: true - - label: Relevant unit / integration tests have been considered - required: false diff --git a/.github/DISCUSSION_TEMPLATE/bug-triage.yml b/.github/DISCUSSION_TEMPLATE/bug-triage.yml new file mode 100644 index 000000000..7a5da8d73 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/bug-triage.yml @@ -0,0 +1,69 @@ +title: "[Bug?] " +labels: ["bug-triage"] +body: + - type: markdown + attributes: + value: | + Use this category if you think you have found a bug in the utPLSQL framework and want to discuss it before a formal issue is opened. + + Once a maintainer confirms the bug, they will open an issue and link it back here. You do not need to open an issue yourself. + + If you are certain it is a bug and can provide a reliable reproduction, you may open an issue directly instead. + + - type: input + id: utplsql-version + attributes: + label: utPLSQL version + placeholder: "e.g. 3.1.13" + validations: + required: true + + - type: input + id: oracle-version + attributes: + label: Oracle Database version + placeholder: "e.g. 19c, 21c" + validations: + required: true + + - type: input + id: os + attributes: + label: Operating system + placeholder: "e.g. Linux, Windows Server 2019" + validations: + required: false + + - type: textarea + id: description + attributes: + label: What did you observe? + description: Describe the unexpected behaviour. Include any error messages or stack traces. + render: text + validations: + required: true + + - type: textarea + id: expected + attributes: + label: What did you expect? + description: Describe what you expected to happen instead. + validations: + required: true + + - type: textarea + id: reproduction + attributes: + label: Reproduction case + description: Paste the minimal PL/SQL needed to reproduce the problem. The simpler, the better. + render: sql + validations: + required: false + + - type: textarea + id: investigation + attributes: + label: What have you investigated so far? + description: Any findings from your own debugging that might help narrow this down. + validations: + required: false diff --git a/.github/DISCUSSION_TEMPLATE/contributing.yml b/.github/DISCUSSION_TEMPLATE/contributing.yml new file mode 100644 index 000000000..31a213cbb --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/contributing.yml @@ -0,0 +1,43 @@ +title: "" +labels: ["contributing"] +body: + - type: markdown + attributes: + value: | + Use this category if you are working on or considering a contribution to the utPLSQL framework codebase and have questions about the internals, development setup, testing approach, or contribution process. + + Before posting, it is worth checking: + - [CONTRIBUTING.md](https://github.com/utPLSQL/utPLSQL/blob/develop/CONTRIBUTING.md) + - [Development setup guide](https://github.com/utPLSQL/utPLSQL/blob/develop/development/README.md) + + - type: dropdown + id: topic + attributes: + label: Topic + options: + - Development environment setup + - Understanding the codebase + - Test writing and running locally + - CI / build pipeline + - Pull request process + - Architectural question + - Other + validations: + required: true + + - type: textarea + id: question + attributes: + label: Question or topic + description: Describe what you are working on and what you need help with. + validations: + required: true + + - type: textarea + id: context + attributes: + label: Relevant code or context + description: Paste any relevant code, configuration, or error output here. + render: sql + validations: + required: false diff --git a/.github/DISCUSSION_TEMPLATE/contributors.yml b/.github/DISCUSSION_TEMPLATE/contributors.yml deleted file mode 100644 index 6325961de..000000000 --- a/.github/DISCUSSION_TEMPLATE/contributors.yml +++ /dev/null @@ -1,56 +0,0 @@ -title: "[Contributors] " -labels: ["contributors"] -body: - - type: markdown - attributes: - value: | - ## Contributors - Questions about **contributing to utPLSQL** β€” development environment setup, - the test suite, pull request process, coding conventions, or anything else - that helps you get your first (or next) contribution merged. - - **Useful links before posting:** - - [CONTRIBUTING.md](../../blob/develop/CONTRIBUTING.md) - - [Development environment setup](../../blob/develop/docs/development/developer-guide.md) - - [Open issues labelled `good first issue`](../../issues?q=is%3Aopen+label%3A%22good+first+issue%22) - - - type: dropdown - id: topic - attributes: - label: Topic - options: - - Dev environment / Docker setup - - Running the test suite locally - - Understanding the codebase - - PR review process - - Coding conventions / style - - Good first issue β€” looking for guidance - - Release process - - Documentation contribution - - Other - validations: - required: true - - - type: textarea - id: question - attributes: - label: Question or request - description: What do you need help with? - validations: - required: true - - - type: textarea - id: context - attributes: - label: What you have tried - description: Steps already taken, error messages, links to relevant code, etc. - validations: - required: false - - - type: input - id: os - attributes: - label: Host OS / environment - placeholder: "e.g. macOS 14, Windows 11, Ubuntu 22.04, Docker on Linux" - validations: - required: false diff --git a/.github/DISCUSSION_TEMPLATE/feature-requests.yml b/.github/DISCUSSION_TEMPLATE/feature-requests.yml new file mode 100644 index 000000000..b07a043b5 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/feature-requests.yml @@ -0,0 +1,61 @@ +title: "[Feature] " +labels: ["feature-request"] +body: + - type: markdown + attributes: + value: | + Use this category for feature ideas specific to the utPLSQL framework: new matchers, annotation behaviour, reporter output, suite control, coverage, or installation. + + > For ideas that affect multiple components or the project direction overall, use [org-level Feature Requests](https://github.com/orgs/utPLSQL/discussions/categories/feature-requests) instead. + + A maintainer will mark this discussion as answered once the proposal is accepted or declined. + If accepted, a maintainer will convert it to an issue for implementation tracking -- you do not need to open an issue yourself. + + - type: textarea + id: problem + attributes: + label: Problem or motivation + description: What problem does this feature solve? What is the current limitation or pain point? + validations: + required: true + + - type: textarea + id: proposal + attributes: + label: Proposed solution + description: Describe the feature you have in mind. Include examples of how it would be used, ideally with PL/SQL annotation or API examples. + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: Alternatives or workarounds considered + description: Have you found any alternative approaches or partial workarounds? + validations: + required: false + + - type: dropdown + id: area + attributes: + label: Framework area + options: + - Annotations + - Matchers + - Reporters + - Suite / test control + - Coverage + - Transaction control + - Installation / upgrade + - Performance + - Other + validations: + required: true + + - type: input + id: utplsql-version + attributes: + label: utPLSQL version you are using + placeholder: "e.g. 3.1.13" + validations: + required: false diff --git a/.github/DISCUSSION_TEMPLATE/general.yml b/.github/DISCUSSION_TEMPLATE/general.yml deleted file mode 100644 index 0e3b8d100..000000000 --- a/.github/DISCUSSION_TEMPLATE/general.yml +++ /dev/null @@ -1,28 +0,0 @@ -title: "" -labels: ["general"] -body: - - type: markdown - attributes: - value: | - ## General discussion - For open-ended conversations that don't fit another category: - project direction, community topics, suggestions, or anything else. - - If your post turns out to be a feature proposal, a maintainer may move it to - **RFCs & Design**. If it is a question about using utPLSQL, consider posting - in **Q&A** instead so a helpful answer can be marked. - - - type: textarea - id: body - attributes: - label: What's on your mind? - validations: - required: true - - - type: textarea - id: context - attributes: - label: Additional context - description: Background, links, related issues or discussions. - validations: - required: false diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml index e4ff1d452..30b372760 100644 --- a/.github/DISCUSSION_TEMPLATE/q-a.yml +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -17,25 +17,18 @@ body: > If this turns out to be a **bug**, a maintainer will convert this discussion into an Issue. - type: input - id: utplsql_version + id: utplsql-version attributes: label: utPLSQL version placeholder: "e.g. 3.1.13" validations: required: true - - type: dropdown - id: oracle_version + - type: input + id: oracle-version attributes: - label: Oracle version - options: - - Oracle 11g - - Oracle 12c - - Oracle 18c - - Oracle 19c - - Oracle 21c - - Oracle 23c / 23ai - - Other / unsure + label: Oracle Database version + placeholder: "e.g. 19c, 21c" validations: required: true @@ -43,7 +36,7 @@ body: id: question attributes: label: Question - description: Describe what you are trying to do and what you have tried so far. + description: Describe what you are trying to do and what you have already tried. validations: required: true @@ -59,29 +52,10 @@ body: required: false - type: textarea - id: expected - attributes: - label: Expected behaviour - validations: - required: false - - - type: textarea - id: actual - attributes: - label: Actual behaviour / error - validations: - required: false - - - type: dropdown - id: install_method + id: output attributes: - label: Installation method - options: - - utPLSQL-cli - - SQL*Plus script - - Docker / utPLSQL-docker - - Liquibase / Flyway - - Other - - N/A + label: Actual output or error + description: Paste any error messages or unexpected output here. + render: text validations: required: false diff --git a/.github/DISCUSSION_TEMPLATE/release-planning.yml b/.github/DISCUSSION_TEMPLATE/release-planning.yml deleted file mode 100644 index 5663d7613..000000000 --- a/.github/DISCUSSION_TEMPLATE/release-planning.yml +++ /dev/null @@ -1,90 +0,0 @@ -title: "[Release] v" -labels: ["release-planning"] -body: - - type: markdown - attributes: - value: | - ## Release planning discussion - Use this template to discuss the scope of an upcoming release: - what goes in, what gets deferred, and what the acceptance criteria are. - - **Maintainers:** pin this discussion and link it from the corresponding GitHub Milestone. - - - type: input - id: version - attributes: - label: Target version - placeholder: "e.g. 3.2.0" - validations: - required: true - - - type: dropdown - id: release_type - attributes: - label: Release type - options: - - Major (breaking changes) - - Minor (new features, backward-compatible) - - Patch (bug fixes only) - validations: - required: true - - - type: textarea - id: goals - attributes: - label: Release goals - description: What are the 2–4 key things this release should achieve? - placeholder: | - 1. - 2. - 3. - validations: - required: true - - - type: textarea - id: scope_in - attributes: - label: In scope (proposed issues / PRs) - description: | - Link the GitHub Issues and PRs targeted for this release. - Use the format: `- [ ] #123 β€” short description` - placeholder: | - - [ ] #123 β€” ... - - [ ] #456 β€” ... - validations: - required: false - - - type: textarea - id: scope_out - attributes: - label: Out of scope / explicitly deferred - description: Issues that were considered but will not be included β€” and why. - validations: - required: false - - - type: input - id: target_date - attributes: - label: Target release date (approximate) - placeholder: "e.g. 2025-Q2" - validations: - required: false - - - type: textarea - id: oracle_matrix - attributes: - label: Oracle version test matrix - description: Which Oracle versions must pass CI before this release ships? - placeholder: | - - [ ] Oracle 19c - - [ ] Oracle 21c - - [ ] Oracle 23ai - validations: - required: false - - - type: textarea - id: notes - attributes: - label: Additional notes - validations: - required: false diff --git a/.github/DISCUSSION_TEMPLATE/rfcs-design.yml b/.github/DISCUSSION_TEMPLATE/rfcs-design.yml deleted file mode 100644 index 32c0a33c7..000000000 --- a/.github/DISCUSSION_TEMPLATE/rfcs-design.yml +++ /dev/null @@ -1,88 +0,0 @@ -title: "[RFC] " -labels: ["rfc", "design"] -body: - - type: markdown - attributes: - value: | - ## Request for Comments β€” design proposal - Use this template to propose a new feature, a change to existing behaviour, or a significant refactoring. - Once there is consensus and a clear scope, a maintainer will convert this discussion into one or more GitHub Issues. - - **Before posting:** search existing RFCs and open issues to avoid duplicates. - - - type: input - id: summary - attributes: - label: Summary - description: One sentence β€” what are you proposing? - placeholder: "Add support for ..." - validations: - required: true - - - type: textarea - id: problem - attributes: - label: Problem / motivation - description: What problem does this solve? Who is affected and how often? - placeholder: | - Currently, when ... it is not possible to ... - This forces users to ... - validations: - required: true - - - type: textarea - id: proposal - attributes: - label: Proposed solution - description: Describe the solution in as much detail as you have. Pseudo-code, SQL, or PL/SQL snippets are welcome. - placeholder: | - ```sql - -- example of the proposed API - ``` - validations: - required: true - - - type: textarea - id: alternatives - attributes: - label: Alternatives considered - description: What other approaches did you look at? Why did you rule them out? - validations: - required: false - - - type: textarea - id: breaking - attributes: - label: Breaking-change impact - description: | - Does this change affect existing annotations, package APIs, or test output formats? - List affected public symbols (ut_runner, ut, annotations, reporters …). - validations: - required: false - - - type: dropdown - id: oracle_versions - attributes: - label: Oracle version relevance - description: Which Oracle versions does this apply to? - multiple: true - options: - - All supported versions - - Oracle 11g - - Oracle 12c - - Oracle 18c - - Oracle 19c - - Oracle 21c - - Oracle 23c / 23ai - validations: - required: true - - - type: checkboxes - id: checklist - attributes: - label: Checklist - options: - - label: I have searched existing discussions and issues for duplicates - required: true - - label: I am willing to help implement or review this feature - required: false diff --git a/.github/DISCUSSION_TEMPLATE/show-and-tell.yml b/.github/DISCUSSION_TEMPLATE/show-and-tell.yml deleted file mode 100644 index 4443c5de6..000000000 --- a/.github/DISCUSSION_TEMPLATE/show-and-tell.yml +++ /dev/null @@ -1,79 +0,0 @@ -title: "[Show & Tell] " -labels: ["show-and-tell"] -body: - - type: markdown - attributes: - value: | - ## Show & Tell - Share how you are using utPLSQL in the wild β€” CI pipelines, IDE integrations, - custom reporters, coverage setups, framework wrappers, or anything else the - community might learn from. - - Posts here are a great source of real-world examples for the documentation. - - - type: input - id: title_short - attributes: - label: What are you sharing? - placeholder: "e.g. utPLSQL + GitHub Actions CI pipeline for Oracle 23ai" - validations: - required: true - - - type: dropdown - id: category - attributes: - label: Category - multiple: true - options: - - CI/CD integration - - IDE / SQL client integration - - Custom reporter - - Code coverage setup - - Framework wrapper / helper library - - Docker / containerised testing - - Annotation patterns - - Performance / large test suite - - Other - validations: - required: true - - - type: textarea - id: description - attributes: - label: Description - description: Describe what you built or configured and why it might be useful to others. - validations: - required: true - - - type: textarea - id: snippet - attributes: - label: Code or configuration snippet - description: Paste the most relevant excerpt. Link to a repo or Gist if you have one. - render: yaml - validations: - required: false - - - type: input - id: utplsql_version - attributes: - label: utPLSQL version used - placeholder: "e.g. 3.1.13" - validations: - required: false - - - type: input - id: oracle_version - attributes: - label: Oracle version - placeholder: "e.g. Oracle 19c" - validations: - required: false - - - type: textarea - id: links - attributes: - label: Links - description: Repository, blog post, documentation page, etc. - validations: - required: false diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b3e52a19a..77cbe1c25 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -13,20 +13,21 @@ A clear and concise description of what the bug is. **Provide version info** Information about utPLSQL and Database version, ```sql -set serveroutput on -declare - l_version varchar2(255); - l_compatibility varchar2(255); -begin - dbms_utility.db_version( l_version, l_compatibility ); - dbms_output.put_line( l_version ); - dbms_output.put_line( l_compatibility ); -end; -/ -select substr(ut.version(),1,60) as ut_version from dual; -select * from v$version; +with + function version_compatibility return varchar2 as + l_ver varchar2(100); + l_comp varchar2(100); + begin + dbms_utility.db_version(l_ver, l_comp); + return l_comp; + end; +select product, version, version_full, version_compatibility, + sys_context('userenv', 'current_edition_name') active_edition, + substr(dbms_utility.port_string,1,60) as cpu_type_and_os + from product_component_version; + select * from nls_session_parameters; -select substr(dbms_utility.port_string,1,60) as port_string from dual; + ``` **Information about client software** diff --git a/.github/scripts/create_test_grants.sh b/.github/scripts/create_test_grants.sh new file mode 100755 index 000000000..d92c02d99 --- /dev/null +++ b/.github/scripts/create_test_grants.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -ev + +# Grants on $UT3_DEVELOP_SCHEMA needed for testing. Must be re-applied whenever $UT3_DEVELOP_SCHEMA is reinstalled. +time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +set feedback off +whenever sqlerror exit failure rollback + +-------------------------------------------------------------------------------- +PROMPT Adding back create-trigger privilege to $UT3_DEVELOP_SCHEMA for testing +grant administer database trigger to $UT3_DEVELOP_SCHEMA; + +-------------------------------------------------------------------------------- +PROMPT Granting $UT3_DEVELOP_SCHEMA code to UT3_TESTER + +begin + for i in ( + select object_name from all_objects t + where t.object_type in ('PACKAGE','TYPE') + and owner = '$UT3_DEVELOP_SCHEMA' + and generated = 'N' + and object_name not like 'SYS%') + loop + execute immediate 'grant execute on $UT3_DEVELOP_SCHEMA."'||i.object_name||'" to UT3_TESTER'; + end loop; +end; +/ + +PROMPT Granting $UT3_DEVELOP_SCHEMA tables to UT3_TESTER + +begin + for i in ( select table_name from all_tables t where owner = '$UT3_DEVELOP_SCHEMA' and nested = 'NO' and iot_name is null) + loop + execute immediate 'grant select on $UT3_DEVELOP_SCHEMA.'||i.table_name||' to UT3_TESTER'; + end loop; +end; +/ +exit +SQL diff --git a/.github/scripts/create_test_users.sh b/.github/scripts/create_test_users.sh index fff44f1bd..41051e33d 100755 --- a/.github/scripts/create_test_users.sh +++ b/.github/scripts/create_test_users.sh @@ -8,42 +8,16 @@ time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL set feedback off whenever sqlerror exit failure rollback --------------------------------------------------------------------------------- -PROMPT Adding back create-trigger privilege to $UT3_DEVELOP_SCHEMA for testing -grant administer database trigger to $UT3_DEVELOP_SCHEMA; - -------------------------------------------------------------------------------- PROMPT Creating UT3_TESTER - Power-user for testing internal framework code create user UT3_TESTER identified by "ut3" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; grant create session, create procedure, create type, create table to UT3_TESTER; -grant execute on dbms_lock to UT3_TESTER; - -PROMPT Granting $UT3_DEVELOP_SCHEMA code to UT3_TESTER - -begin - for i in ( - select object_name from all_objects t - where t.object_type in ('PACKAGE','TYPE') - and owner = '$UT3_DEVELOP_SCHEMA' - and generated = 'N' - and object_name not like 'SYS%') - loop - execute immediate 'grant execute on $UT3_DEVELOP_SCHEMA."'||i.object_name||'" to UT3_TESTER'; - end loop; -end; -/ +# Editioning is enable on test users to validate that utPLSQL works well with editioned schema +alter user UT3_TESTER enable editions; -PROMPT Granting $UT3_DEVELOP_SCHEMA tables to UT3_TESTER - -begin - for i in ( select table_name from all_tables t where owner = '$UT3_DEVELOP_SCHEMA' and nested = 'NO' and iot_name is null) - loop - execute immediate 'grant select on $UT3_DEVELOP_SCHEMA.'||i.table_name||' to UT3_TESTER'; - end loop; -end; -/ +grant execute on dbms_lock to UT3_TESTER; -------------------------------------------------------------------------------- @@ -52,23 +26,21 @@ PROMPT Creating UT3_USER - minimal privileges user for API testing create user UT3_USER identified by "ut3" default tablespace $UT3_TABLESPACE quota unlimited on $UT3_TABLESPACE; grant create session, create procedure, create type, create table to UT3_USER; +# Editioning is enable on test users to validate that utPLSQL works well with editioned schema +alter user UT3_USER enable editions; + PROMPT Grants for starting a debugging session from UT3_USER grant debug connect session to UT3_USER; grant debug any procedure to UT3_USER; begin - \$if dbms_db_version.version <= 11 \$then - null; -- no addition action necessary - \$else - -- necessary on 12c or higher - dbms_network_acl_admin.append_host_ace ( - host =>'*', - ace => sys.xs\$ace_type( - privilege_list => sys.xs\$name_list('JDWP') , - principal_name => 'UT3_USER', - principal_type => sys.xs_acl.ptype_db - ) - ); - \$end + dbms_network_acl_admin.append_host_ace ( + host =>'*', + ace => sys.xs\$ace_type( + privilege_list => sys.xs\$name_list('JDWP') , + principal_name => 'UT3_USER', + principal_type => sys.xs_acl.ptype_db + ) + ); end; / @@ -113,3 +85,5 @@ create user ut3_execute_any_proc_user identified by ut3; grant create session, create procedure, execute any procedure to ut3_execute_any_proc_user; exit SQL + +"${SCRIPT_DIR}/create_test_grants.sh" diff --git a/.github/scripts/detect_changes_since_last_publish.sh b/.github/scripts/detect_changes_since_last_publish.sh new file mode 100755 index 000000000..818ff89dc --- /dev/null +++ b/.github/scripts/detect_changes_since_last_publish.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# Detects what has changed since the last publish, so that builds of unchanged code +# (e.g. scheduled builds) do not produce new commits on develop and gh-pages branches. +# +# Outputs (written to $GITHUB_OUTPUT): +# project_changed - true when there are new commits since the last project version update commit +# docs_changed - true when documentation sources changed since the last deployment of documentation to gh-pages + +VERSION_COMMIT_MESSAGE='Updated project version after build [skip ci]' +DOCS_PATHS="docs mkdocs.yml" +DOCS_VERSION="develop" + +if [[ "$(git log -1 --format=%s HEAD)" == "${VERSION_COMMIT_MESSAGE}" ]]; then + echo "No new commits since last project version update." + project_changed=false +else + echo "New commits found since last project version update." + project_changed=true +fi + +# mike commits to gh-pages with message: "Deployed to with MkDocs and mike " +git fetch --quiet origin gh-pages +last_deployed_sha=$(git log -1 --format=%s --grep="^Deployed [0-9a-f]* to ${DOCS_VERSION} with MkDocs" origin/gh-pages | sed -nE "s/^Deployed ([0-9a-f]+) to .*/\1/p") + +if [[ -z "${last_deployed_sha}" ]] || ! git cat-file -e "${last_deployed_sha}^{commit}" 2>/dev/null; then + echo "Commit of last '${DOCS_VERSION}' documentation deployment not found." + docs_changed=true +elif git diff --quiet "${last_deployed_sha}" HEAD -- ${DOCS_PATHS}; then + echo "No documentation changes since last '${DOCS_VERSION}' documentation deployment from commit ${last_deployed_sha}." + docs_changed=false +else + echo "Documentation changed since last '${DOCS_VERSION}' documentation deployment from commit ${last_deployed_sha}." + docs_changed=true +fi + +echo "project_changed=${project_changed}" >> $GITHUB_OUTPUT +echo "docs_changed=${docs_changed}" >> $GITHUB_OUTPUT diff --git a/.github/scripts/get_published_docs_version.sh b/.github/scripts/get_published_docs_version.sh new file mode 100755 index 000000000..f0a78dcbc --- /dev/null +++ b/.github/scripts/get_published_docs_version.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Returns the version shown on the badge of documentation, as originally published for a release. +# Used when rebuilding documentation of older releases, so that the rebuild does not alter version badges. +# Usage: .github/scripts/get_published_docs_version.sh +# +# Version is taken from the first deployment of the release documentation to gh-pages. +# If not found, it is derived from the release tag and BUILD_NO file, the same way as done by release process. +# Returns nothing if version cannot be determined. + +version=$1 +[[ -n "${version}" ]] || { echo "Release tag not provided" >&2; exit 1; } + +# mike commits to gh-pages with message: "Deployed to with MkDocs and mike " +first_deployment=$(git log origin/gh-pages --format=%H -F --grep=" to ${version} with MkDocs" | tail -1) +if [[ -n "${first_deployment}" ]]; then + docs_version=$(git show "${first_deployment}:${version}/index.html" 2>/dev/null | sed -nE 's/.*img\.shields\.io\/badge\/version-([^"]*)-blue\.svg.*/\1/p' | head -1) + # "-" is escaped as "--" in shields.io badge + docs_version=${docs_version//--/-} +fi + +if [[ -z "${docs_version}" ]]; then + build_no=$(git show "tags/${version}:BUILD_NO" 2>/dev/null | tr -d '[:space:]') + if [[ -n "${build_no}" ]]; then + docs_version=$(echo ${version} | sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${build_no}\4/") + fi +fi + +echo ${docs_version} diff --git a/.github/scripts/install.sh b/.github/scripts/install.sh index 46750b89c..5f034951c 100755 --- a/.github/scripts/install.sh +++ b/.github/scripts/install.sh @@ -19,3 +19,13 @@ set verify off alter session set plsql_optimize_level=0; @${INSTALL_FILE} $UT3_DEVELOP_SCHEMA $UT3_DEVELOP_SCHEMA_PASSWORD SQL + +#Enable editioning on the UT3_DEVELOP schema +time "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <<-SQL +whenever sqlerror exit failure rollback +set feedback off +set verify off + +alter user $UT3_DEVELOP_SCHEMA enable editions; +exit +SQL diff --git a/.github/scripts/install_utplsql_release.sh b/.github/scripts/install_utplsql_release.sh index e50718c7b..b9e23d214 100755 --- a/.github/scripts/install_utplsql_release.sh +++ b/.github/scripts/install_utplsql_release.sh @@ -43,7 +43,6 @@ fi "$SQLCLI" sys/$ORACLE_PWD@//$CONNECTION_STR AS SYSDBA <> $GITHUB_ENV echo "UTPLSQL_VERSION=${version}" >> $GITHUB_ENV -echo UTPLSQL_BUILD_VERSION=$(echo ${version} | sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${build_no}\4/") >> $GITHUB_ENV - +echo "UTPLSQL_BUILD_VERSION=${build_version}" >> $GITHUB_ENV +# Documentation of released versions includes build number +echo "UTPLSQL_DOCS_VERSION=${build_version}" >> $GITHUB_ENV diff --git a/.github/scripts/set_version_numbers_env.sh b/.github/scripts/set_version_numbers_env.sh index c61639bf9..8fc31279d 100755 --- a/.github/scripts/set_version_numbers_env.sh +++ b/.github/scripts/set_version_numbers_env.sh @@ -6,3 +6,5 @@ version=$(.github/scripts/get_project_version.sh) echo "UTPLSQL_BUILD_NO=${build_no}" >> $GITHUB_ENV echo "UTPLSQL_VERSION=${version}" >> $GITHUB_ENV echo UTPLSQL_BUILD_VERSION=$(echo ${version} | sed -E "s/(v?[0-9]+\.)([0-9]+\.)([0-9]+)(-.*)?/\1\2\3\.${build_no}\4/") >> $GITHUB_ENV +# Documentation of development versions does not include build number, so that it only changes when version changes +echo "UTPLSQL_DOCS_VERSION=${version}" >> $GITHUB_ENV diff --git a/.github/scripts/update_changelog.sh b/.github/scripts/update_changelog.sh new file mode 100755 index 000000000..011c08819 --- /dev/null +++ b/.github/scripts/update_changelog.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Updates CHANGELOG.md by prepending a new section for the release. +# +# Required environment variables: +# RELEASE_TAG - e.g. v3.2.3 +# RELEASE_BODY - markdown release notes +# RELEASE_DATE - ISO-8601 date string (only the first 10 chars are used) +# TARGET_BRANCH - branch to push the updated changelog to + +set -euo pipefail + +python3 - <<'PYEOF' +import os + +tag = os.environ['RELEASE_TAG'] +body = os.environ['RELEASE_BODY'].strip() +date = os.environ['RELEASE_DATE'][:10] + +new_section = f"## [{tag}] - {date}\n\n{body}\n\n---\n\n" + +with open('CHANGELOG.md', 'r') as f: + content = f.read() + +marker = '\n---\n' +pos = content.index(marker) + len(marker) +updated = content[:pos] + '\n' + new_section + content[pos:] + +with open('CHANGELOG.md', 'w') as f: + f.write(updated) + +print(f"Added {tag} to CHANGELOG.md") +PYEOF + +git add CHANGELOG.md +git commit -m "Add release notes for ${RELEASE_TAG} to CHANGELOG.md [skip ci]" +git push origin HEAD:"${TARGET_BRANCH}" diff --git a/.github/scripts/update_docs_version.sh b/.github/scripts/update_docs_version.sh new file mode 100755 index 000000000..fa2e2c27a --- /dev/null +++ b/.github/scripts/update_docs_version.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Updates version badge in documentation files. +# Usage: .github/scripts/update_docs_version.sh +# e.g. .github/scripts/update_docs_version.sh v3.2.4.4600 + +docs_version=$1 +[[ -n "${docs_version}" ]] || { echo "Documentation version not provided"; exit 1; } + +# "-" needs to be escaped as "--" in shields.io badge +find docs -type f -name '*.md' -exec sed -i -r "s/(badge\/version-).*(-blue\.svg)/\1${docs_version//-/--}\2/" {} \; +echo Documentation files updated with version: ${docs_version} diff --git a/.github/scripts/update_project_version.sh b/.github/scripts/update_project_version.sh index 66e45125a..bb59528cb 100755 --- a/.github/scripts/update_project_version.sh +++ b/.github/scripts/update_project_version.sh @@ -9,7 +9,7 @@ find source -type f -name '*' -exec sed -i -r "s/${UTPLSQL_VERSION_PATTERN}/${UT echo Source files updated with version tag: ${UTPLSQL_BUILD_VERSION} echo Update version in documentation files -find docs -type f -name '*.md' -exec sed -i -r "s/(badge\/version-).*(-blue\.svg)/\1${UTPLSQL_BUILD_VERSION/-/--}\2/" {} \; +.github/scripts/update_docs_version.sh "${UTPLSQL_DOCS_VERSION}" echo Update of sonar-project.properties sonar.projectVersion sed -i -r "s/(sonar\.projectVersion=).*?/\1${UTPLSQL_VERSION}/" sonar-project.properties diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c77c486c..f97880a48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,8 +4,16 @@ on: branches-ignore: [ main ] pull_request: branches: [ develop ] + schedule: + - cron: '0 8 * * 5' # run scheduled at 8:00 AM every Friday + timezone: "Europe/Nicosia" workflow_dispatch: + inputs: + force_docs_publish: + description: 'Publish develop documentation even if no documentation changes were detected' + type: boolean + default: false concurrency: ${{github.ref}} defaults: @@ -15,25 +23,26 @@ defaults: jobs: build: - name: Build and test on ${{matrix.db_version_name}} DB + name: Build and test on ${{matrix.db.db_version_name}} DB runs-on: ubuntu-latest timeout-minutes: 90 env: - ORACLE_VERSION: ${{matrix.oracle-version}} - ORACLE_SID: ${{matrix.oracle-sid}} - CONNECTION_STR: ${{ format( '127.0.0.1:1521/{0}', matrix.oracle-sid ) }} + ORACLE_VERSION: ${{matrix.db.oracle-version}} + ORACLE_SID: ${{matrix.db.oracle-sid}} + CONNECTION_STR: ${{ format( '127.0.0.1:1521/{0}', matrix.db.oracle-sid ) }} ORACLE_PASSWORD: oracle - DOCKER_VOLUME: ${{matrix.docker-volume}} + DOCKER_VOLUME: ${{matrix.db.docker-volume}} + HAS_SONAR_TOKEN: ${{ secrets.SONAR_TOKEN != '' }} strategy: fail-fast: false matrix: - include: + # The DB versions are values of a matrix key, not `include` entries, because `exclude` can't remove `include` entries. + db: - id: 1 - db_version_name: '19se' - oracle-sid: 'ORCLCDB' - oracle-version: "utplsqlv3/oracledb:19c-se2-small" - check-coding-style: true - validate-utplsql-uninstall: true + db_version_name: '19.20-ee' + oracle-sid: 'UTPLSQL' + oracle-version: "utplsqlv3/oracledb:19.20-utplsql" + run-sonar-scanner: true - id: 2 db_version_name: '21XE' oracle-sid: 'XE' @@ -43,19 +52,22 @@ jobs: oracle-sid: 'FREEPDB1' oracle-version: "gvenzl/oracle-free:23-slim-faststart" fips-enabled: true - run-sonar-scanner: true + check-coding-style: true + validate-utplsql-uninstall: true + exclude: + # Pull requests from forks can't access secrets, so they can't pull the private utplsqlv3 19.20-ee image. + - db: + id: ${{ github.event.pull_request.head.repo.fork == true && 1 || 0 }} services: html_checker: image: ghcr.io/validator/validator:latest options: >- -p 8888:8888 oracle: - image: ${{matrix.oracle-version}} + image: ${{matrix.db.oracle-version}} env: ORACLE_PASSWORD: oracle - credentials: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASSWORD }} + credentials: ${{ secrets.DOCKER_USER && fromJSON( format( '{{"username":"{0}","password":"{1}"}}', secrets.DOCKER_USER, secrets.DOCKER_PASSWORD ) ) || fromJSON( '{}' ) }} volumes: - ${{github.workspace}}:/utPLSQL ports: @@ -90,7 +102,7 @@ jobs: - name: Enable FIPS 140 on Oracle DB id: enable-fips - if: ${{ matrix.fips-enabled == true }} + if: ${{ matrix.db.fips-enabled == true }} run: | docker exec oracle bash -c " echo \"ALTER SYSTEM SET DBFIPS_140=TRUE SCOPE=SPFILE; @@ -133,17 +145,17 @@ jobs: run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install.sh - name: Check code style - if: ${{ matrix.check-style == true }} + if: ${{ matrix.db.check-coding-style == true }} id: check-coding-style run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle "$SQLCLI" ${UT3_DEVELOP_SCHEMA}/${UT3_DEVELOP_SCHEMA_PASSWORD}@//${CONNECTION_STR} @/utPLSQL/development/utplsql_style_check.sql - name: Validate utPLSQL uninstall - if: ${{ matrix.validate-utplsql-uninstall == true }} + if: ${{ matrix.db.validate-utplsql-uninstall == true }} id: validate-uninstall run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/uninstall_validate_utplsql.sh - name: Reinstall utPLSQL - if: ${{ matrix.validate-utplsql-uninstall == true }} + if: ${{ matrix.db.validate-utplsql-uninstall == true }} id: reinstall-utplsql run: docker exec -w /utPLSQL ${DOCKER_ENV} oracle .github/scripts/install.sh @@ -183,7 +195,7 @@ jobs: if: ${{ always() && steps.run-tests.outcome == 'failure' }} uses: actions/upload-artifact@v4 with: - name: my-artifact$-${{matrix.db_version_name}} + name: my-artifact$-${{matrix.db.db_version_name}} path: ${{github.workspace}}/database-diag #End Needed to diagnose occasional failures of DB on test runs @@ -196,7 +208,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos files: ./cobertura.xml - flags: ${{matrix.db_version_name}} + flags: ${{matrix.db.db_version_name}} fail_ci_if_error: true # optional (default = false) - name: Publish unit test results @@ -207,14 +219,14 @@ jobs: - name: SonarCloud Scan id: sonar - if: ${{ always() && matrix.run-sonar-scanner == true }} + if: ${{ always() && matrix.db.run-sonar-scanner == true && env.HAS_SONAR_TOKEN == 'true' }} uses: SonarSource/sonarqube-scan-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} with: args: > - -Dsonar.buildString=${{ format( '{0}.{1}', env.UTPLSQL_BUILD_VERSION, matrix.id ) }} + -Dsonar.buildString=${{ format( '{0}.{1}', env.UTPLSQL_BUILD_VERSION, matrix.db.id ) }} -Dsonar.plsql.jdbc.url=${{ format( 'jdbc:oracle:thin:@//localhost:1521/{0}', env.ORACLE_SID ) }} -Dsonar.plsql.jdbc.driver.path=${{ format( '{0}/ojdbc8.jar', env.OJDBC_HOME ) }} @@ -244,32 +256,42 @@ jobs: env-file: .github/variables/.env - uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action - - name: Set buid version number env variables + - name: Detect changes since last publish + id: detect-changes + run: .github/scripts/detect_changes_since_last_publish.sh + + - name: Set build version number env variables id: set-build-version-number-vars + if: steps.detect-changes.outputs.project_changed == 'true' run: .github/scripts/set_version_numbers_env.sh - name: Update project version & build number in source code and documentation id: update-project-version + if: steps.detect-changes.outputs.project_changed == 'true' run: .github/scripts/update_project_version.sh - name: Push version update to repository id: push-version-number-update + if: steps.detect-changes.outputs.project_changed == 'true' run: | git add sonar-project.properties VERSION BUILD_NO source/* docs/* git commit -m 'Updated project version after build [skip ci]' git push --quiet origin HEAD:${CI_ACTION_REF_NAME} - name: Setup git config + if: steps.detect-changes.outputs.docs_changed == 'true' || inputs.force_docs_publish run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" - name: Build and publish documentation + if: steps.detect-changes.outputs.docs_changed == 'true' || inputs.force_docs_publish run: | pip install mkdocs pip install mkdocs-git-revision-date-localized-plugin pip install mkdocs-material pip install git+https://github.com/jimporter/mike.git + pip install mkdocs-git-committers-plugin-2 mike deploy -p develop dispatch: diff --git a/.github/workflows/rebuild_docs.yml b/.github/workflows/rebuild_docs.yml new file mode 100644 index 000000000..835ae5947 --- /dev/null +++ b/.github/workflows/rebuild_docs.yml @@ -0,0 +1,67 @@ +name: Rebuild older docs versions +on: + workflow_dispatch: + inputs: + versions: + description: 'Space-separated list of versions to rebuild (e.g. "v3.1.14 v3.1.13")' + required: true + default: 'v.3.2.3 v3.2.2 v3.2.01 v3.1.14 v3.1.13 v3.1.12 v3.1.11 v3.1.10 v3.1.9 v3.1.8 v3.1.6 v3.1.5 v3.1.4 v3.1.3 v3.1.2 v3.1.1 v3.1.0 v3.0.4 v3.0.3 v3.0.2 v3.0.1 v3.0.0 v3.0.0-beta' + +defaults: + run: + shell: bash + +jobs: + rebuild: + name: Rebuild documentation for older versions + concurrency: publish + runs-on: ubuntu-latest + timeout-minutes: 30 + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + + steps: + - name: πŸ” API_TOKEN_GITHUB + if: env.API_TOKEN_GITHUB == '' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: echo "API_TOKEN_GITHUB=${GITHUB_TOKEN}" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ env.API_TOKEN_GITHUB }} + + - uses: c-py/action-dotenv-to-setenv@v5 + with: + env-file: .github/variables/.env + + - uses: FranzDiebold/github-env-vars-action@v2.8.0 + + - name: Install mkdocs stack + run: | + pip install mkdocs + pip install mkdocs-git-revision-date-localized-plugin + pip install mkdocs-material + pip install git+https://github.com/jimporter/mike.git + pip install mkdocs-git-committers-plugin-2 + + - name: Rebuild specified versions + run: | + git fetch --quiet origin gh-pages + for VERSION in ${{ inputs.versions }}; do + echo "=== Rebuilding $VERSION ===" + git checkout "tags/${VERSION}" -- docs/ + # Use the current look and feel (colors, footer, top bar) for every version; + # tags released since the restyling carry their own, older copies of these files + git checkout HEAD -- docs/stylesheets docs/overrides + # Keep the version badge as originally published with the release + DOCS_VERSION=$(.github/scripts/get_published_docs_version.sh "${VERSION}") + if [[ -n "${DOCS_VERSION}" ]]; then + .github/scripts/update_docs_version.sh "${DOCS_VERSION}" + else + echo "Published documentation version for ${VERSION} not found, version badge left unchanged" + fi + mike deploy -p "${VERSION}" + git checkout HEAD -- docs/ mkdocs.yml + done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b5d59463..7b28424a0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,33 +15,40 @@ jobs: concurrency: upload runs-on: ubuntu-latest timeout-minutes: 60 + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + RELEASE_BODY: ${{ github.event.release.body }} + RELEASE_DATE: ${{ github.event.release.published_at }} + RELEASE_URL: ${{ github.event.release.html_url }} + TARGET_BRANCH: ${{ github.event.release.target_commitish }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ env.API_TOKEN_GITHUB }} - uses: c-py/action-dotenv-to-setenv@v5 with: env-file: .github/variables/.env - uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action + - name: Update CHANGELOG.md with release notes + run: .github/scripts/update_changelog.sh + - name: Set build version number env variables run: .github/scripts/set_release_version_numbers_env.sh - name: Update project version & build number in source code and documentation run: .github/scripts/update_project_version.sh - - name: Setup git config - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - - name: Build and publish documentation run: | pip install mkdocs pip install mkdocs-git-revision-date-localized-plugin pip install mkdocs-material pip install git+https://github.com/jimporter/mike.git + pip install mkdocs-git-committers-plugin-2 mike deploy -p -u ${UTPLSQL_VERSION} latest mkdocs build --clean -f mkdocs_offline.yml rm -rf docs/* @@ -53,15 +60,24 @@ jobs: run: | git archive --prefix=utPLSQL/ -o utPLSQL.zip --format=zip HEAD git archive --prefix=utPLSQL/ -o utPLSQL.tar.gz --format=tar.gz HEAD - md5sum utPLSQL.zip --tag > utPLSQL.zip.md5 - md5sum utPLSQL.tar.gz --tag > utPLSQL.tar.gz.md5 + sha256sum utPLSQL.zip --tag > utPLSQL.zip.sha256 + sha256sum utPLSQL.tar.gz --tag > utPLSQL.tar.gz.sha256 - name: Release uses: softprops/action-gh-release@v1 with: files: | utPLSQL.zip - utPLSQL.zip.md5 + utPLSQL.zip.sha256 utPLSQL.tar.gz - utPLSQL.tar.gz.md5 + utPLSQL.tar.gz.sha256 + + - name: Announce release in org discussions and on utplsql.github.io + uses: utPLSQL/.github/actions/announce-release@v1 + with: + project-name: utPLSQL + tag: ${{ github.event.release.tag_name }} + discussion-token: ${{ secrets.API_TOKEN_GITHUB }} + site-token: ${{ secrets.API_TOKEN_GITHUB }} + site-category: utplsql-core diff --git a/.github/workflows/test_publishing.yml b/.github/workflows/test_publishing.yml new file mode 100644 index 000000000..4c86d2da8 --- /dev/null +++ b/.github/workflows/test_publishing.yml @@ -0,0 +1,55 @@ +name: Test publishing +on: + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + + upload_artifacts: + name: Upload archives + concurrency: upload + runs-on: ubuntu-latest + timeout-minutes: 60 + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + RELEASE_TAG: "v3.2.3" + RELEASE_BODY: | + ## What's Changed + * Fix issue with `UT_TAP_REPORTER` on Oracle 23.26 by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1359 + * Fixed support for camelCase in context `--%name` annotation. by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1361 + * utPLSQL can be installed in editioned schema. by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1362 + * Removed coveralls reporter by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1363 + * Clarify behavior of before/after procedures in suitepath by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1364 + * `throws` can reference exception without schema or package name by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1365 + * `throws` works with uninitialized exception variables by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1366 + + + **Full Changelog**: https://github.com/utPLSQL/utPLSQL/compare/v3.2.2...v.3.2.3 + RELEASE_DATE: "2026-07-10 08:30:22" + RELEASE_URL: "https://github.com/utPLSQL/utPLSQL/releases/tag/v3.2.3" + TARGET_BRANCH: "develop" + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ env.API_TOKEN_GITHUB }} + - uses: c-py/action-dotenv-to-setenv@v5 + with: + env-file: .github/variables/.env + - uses: FranzDiebold/github-env-vars-action@v2.8.0 #https://github.com/marketplace/actions/github-environment-variables-action + +# - name: Update CHANGELOG.md with release notes +# run: .github/scripts/update_changelog.sh + + - name: Publish release post to utplsql.github.io + uses: utPLSQL/.github/actions/announce-release@v1 + with: + project-name: utPLSQL + tag: ${{ env.RELEASE_TAG }} + site-token: ${{ secrets.API_TOKEN_GITHUB }} + site-category: utplsql-core + diff --git a/.gitignore b/.gitignore index be442d164..be0e26a77 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ development/*.jar *.log # exclusions based on artifacts created via actions documented in CONTRIBUTING.md -test/dummy.sql coverage.html_assets/ coverage.html coverage.json diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..85f8cd5b1 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,66 @@ +# Agent instructions + +## Project context + +This repository contains utPLSQL, a unit-testing framework for Oracle PL/SQL. +Preserve compatibility with the Oracle versions and public APIs supported by +the project. + +## Before making changes + +- Read `CONTRIBUTING.md` and follow its coding standards, engineering + principles, refactoring guidance, and testing requirements. +- Inspect the relevant package specification, package body, and tests before + editing. +- Keep changes focused on the requested behavior. +- Check whether the change touches CBAC, SQL macros, install order, or supported + Oracle versions. Follow the relevant guidance in `CONTRIBUTING.md`. + +## PL/SQL changes + +- Treat package specifications and documented behavior as public interfaces. +- Match the naming, formatting, and error-handling patterns in nearby code. +- Add or update tests for behavior changes, following existing test patterns. +- Do not introduce a new data representation or change public interfaces unless + the task calls for it. + +## Performance work + +- Compare results using the same Oracle version, environment, and workload. +- Report the measurements and conditions used. Do not present an unmeasured + performance improvement as established. + +## Security and quality + +- For security-sensitive changes, consider input validation, dynamic SQL, + schema and object name handling, and privilege boundaries. Follow the + existing security patterns in the relevant code. +- If you identify a possible security vulnerability, follow the repository's + private security-reporting process, if one is documented. Do not disclose it + in a public issue or pull request. +- If the project's CI runs SonarQube or SonarCloud, report its result when + available. Do not introduce new Sonar requirements or claim a scan passed + unless it was run. + +## Local environment and safety + +- Treat `development/env.sh` as local configuration. Do not commit it or expose + its credentials in output. +- Treat the directory configured by `UTPLSQL_DIR` as a read-only upstream + reference for self-testing. Do not make feature changes there; make them + under `source/` and `test/`. `development/refresh_sources.sh` deletes and + recreates the configured directory. +- Before running database tests, check that the local environment is configured + as described in `CONTRIBUTING.md`. +- Do not remove or recreate the local database container without explicit + authorization, because doing so deletes its contents. +- Do not edit generated version strings in `source/`, `VERSION`, or `BUILD_NO`. + +## Verification + +- Use commands documented in `CONTRIBUTING.md`; do not guess at project + commands. +- Run the narrowest relevant checks first. +- Report which relevant checks you ran and their results. If a check could not + be run, say which one and why. +- Do not claim a check passed unless it was actually run. diff --git a/BUILD_NO b/BUILD_NO index dd37b7287..ae6d06456 100644 --- a/BUILD_NO +++ b/BUILD_NO @@ -1 +1 @@ -4414 +4670 diff --git a/CHANGELOG.md b/CHANGELOG.md index f75662f75..faf1f504a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,36 @@ Releases are available on the [GitHub Releases page](https://github.com/utPLSQL/ --- +## [v.3.2.3] - 2026-07-10 + +## What's Changed +* Fix issue with `UT_TAP_REPORTER` on Oracle 23.26 by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1359 +* Fixed support for camelCase in context `--%name` annotation. by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1361 +* utPLSQL can be installed in editioned schema. by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1362 +* Removed coveralls reporter by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1363 +* Clarify behavior of before/after procedures in suitepath by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1364 +* `throws` can reference exception without schema or package name by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1365 +* `throws` works with uninitialized exception variables by @jgebal in https://github.com/utPLSQL/utPLSQL/pull/1366 + + +**Full Changelog**: https://github.com/utPLSQL/utPLSQL/compare/v3.2.2...v.3.2.3 + +--- + + +## [v3.2.2] - 2026-05-24 + +## What's Changed +* Filtering by tags fixed for schemas containing suite-paths and contexts by @jgebal in [1325](https://github.com/utPLSQL/utPLSQL/pull/1325) +* Fixed issue with reporter failing to initialize by @jgebal in [1354](https://github.com/utPLSQL/utPLSQL/pull/1354) +* Fixed issue with duplicate sources from dba_source by @jgebal in [1355](https://github.com/utPLSQL/utPLSQL/pull/1355) +* Allow HTML coverage on FIPS-enabled DB by @jgebal in [1356](https://github.com/utPLSQL/utPLSQL/pull/1356) + + +**Full Changelog**: https://github.com/utPLSQL/utPLSQL/compare/v3.2.01...v3.2.2 + +--- + ## [v3.2.01] - 2026-04-22 ## Important diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index b90e5e80e..000000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,76 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at utplsql@utplsql.org. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3cac5c86f..c5df712aa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,8 @@ # How to contribute The following are the guidelines everyone should use to contribute to utPLSQL. -Changes are welcome from all members of the Community. +Changes are welcome from all members of the Community. +Not able to contribute code? You can also support the project through [sponsorship](https://www.utplsql.org/sponsorship.html). # Getting Started @@ -30,26 +31,106 @@ Changes are welcome from all members of the Community. * Arguments to procedures and functions will start with `a_`, an Example would be procedure `is_valid(a_owner_name varchar2)` * Object types and packages will start with `ut_` * Local variables `l_` + * Local constants `c_` * Global variables `g_` * Global Constants start with `gc_` * Types in packages, objects start with `t_` * Nested Tables start with `tt_` * varchar2 lengths are set in characters not bytes +* Comments should not be added to explain what the code does; the code itself should make that clear. Use a comment to give the reason for the code, or background that isn't obvious from the code or easy to find with an internet search, and only where it adds real value. +* Every source file carries the Apache license header. +* Don't edit version strings (`v3.x.x.xxxx`) in `source/`, `VERSION` or `BUILD_NO` by hand. CI rewrites them (`.github/scripts/update_project_version.sh`). + +# Engineering principles + +Every change (PL/SQL, SQL, install scripts, GitHub workflows, tooling) should follow these principles of Extreme Programming (XP): + +- **KISS – Keep It Simple, Stupid**: choose the simplest solution that works and is easy to read; no clever constructs where a plain one will do. +- **DRY – Don't Repeat Yourself**: every piece of knowledge has one authoritative place. Reuse existing packages, types and helpers (`ut_utils` first) instead of copying logic. In GitHub workflows, define a value once and reference it. +- **YAGNI – You Aren't Gonna Need It**: implement only what the task needs now. No speculative parameters, options, columns, abstractions or "future" code paths. + +Where they apply to PL/SQL and SQL, also follow the **SOLID** principles. Apply only the ones that fit; don't force them onto plain SQL scripts: + +- **S – Single Responsibility Principle**: a package, procedure or type has one cohesive purpose and one reason to change. Split packages that mix unrelated concerns; keep procedures short and focused. +- **O – Open/Closed Principle**: extend behavior without modifying working code, for example by adding a new reporter as a subtype of `ut_reporter_base`, or a new matcher as a subtype of `ut_matcher`, instead of adding another branch to a big `if`/`case`. +- **L – Liskov Substitution Principle**: object type subtypes (`under`) must be usable wherever their base type is expected, without changing the expected behavior of the base type's methods. +- **I – Interface Segregation Principle**: keep package specifications small and focused, so callers depend only on what they use. Expose a function in a package spec only if something needs it, and prefer a thin facade over a large catch-all package. +- **D – Dependency Inversion Principle**: depend on package specifications and abstract base types, not on implementation details (package bodies, concrete subtypes, table structures of other modules). Call other modules through their public spec. + +Every new functionality should be covered with tests, following the testing pyramid or the testing diamond. + +## Refactoring + +Before each refactoring step: +- **Check test coverage first.** Make sure existing tests cover the logic being refactored, including its edge cases and error paths. If they don't, add the missing tests and see them pass against the current code before changing it. +- **Find tests that the change would break.** Look for tests that call the procedures, functions or types being moved, merged or removed. Where you can, rewrite those tests to call a higher-level procedure or function that keeps its contract. The tests then check behaviour rather than internal structure, and still pass after the refactoring. + +# Code based access control and SQL macros + +Some framework packages run with invoker rights (`authid current_user`) and still read and change the framework's cache tables. +They do it through the code based access control (CBAC) role `_cbac_modify_objects_role`, which [ut3_cbac_modify_objects_role_grants.sql](source/ut3_cbac_modify_objects_role_grants.sql) grants to those packages. +Users calling the framework get no privileges on the tables. The rules below were verified on Oracle 19.20, 21 XE and 23 Free. + +## Packages with the CBAC role + +- **Grants:** a package that needs the role gets a `grant ... to package` line in the grants script. The objects its SQL uses (tables, types, other packages) are granted to the role in the same script. +- **Qualify framework objects:** in the SQL of these packages, qualify framework objects with the SQL*Plus substitution variable `&&ut3_owner.`, which `install.sql` sets. The code runs as the invoking user, so unqualified names would resolve in that user's schema. When you compile such a body by hand, run `define ut3_owner=ut3_develop` first. +- **Install order:** `install.sql` installs the package specs, then runs the grants script, then installs the bodies. A body that expands a SQL macro needs the role when it compiles; in the other order it fails with `ORA-62565` / `PLS-00201`. +- **Recreating a spec drops the grant:** `create or replace package` removes the package's CBAC role grant, while `create or replace package body` keeps it. After changing such a spec by hand, rerun the grants script as SYS, or run `development/refresh_ut3.sh`. + +## SQL macros + +- **Table macros only.** utPLSQL is compatible with Oracle 19c (RU 19.20) or later, so table macros are available everywhere it runs. +- **Separate definer rights package:** a macro doesn't compile in an invoker rights package (`PLS-00782`). Macros live in their own `authid definer` packages, such as `ut_annotation_cache_macros` and `ut_suite_cache_macros`. +- **Two grants needed for macro package:** one to the CBAC role in the grants script, and one to the framework users in [create_grants.sql](source/create_grants.sql). +- **Qualify framework objects in the macro text** with `&&ut3_owner.`. The text is expanded into the caller's statement, which runs with invoker rights. +- **Don't use argument values in the macro body.** The body sees an argument's value only when the caller passes a literal; binds and PL/SQL variables arrive as NULL. So the body can't branch on an argument or build SQL from it. Put conditions into the returned text instead, for example `(a_value is null or col > a_value)`. +- **No macro inside a `WITH` clause** (`ORA-64630`). Call the macro from the main query or one of its subqueries. A CTE can be passed as a table argument. +- **No collection columns in a table argument** (`ORA-62558`). Pass a CTE that selects only scalar columns. +- **No `all_objects` in a CTE of a statement that calls a macro.** The statement compiles but fails at run time with `ORA-00942`. Use `all_objects` in the main query instead. +- **Recompile with `alter package ... compile body`.** `dbms_utility.compile_schema` can't recompile a body that expands a macro in static SQL (`ORA-62565`). +- **Test on 19c, 21 XE and 23 Free.** The privilege checks for macros differ between versions. # Configuring local environment Your local environment can be of any flavor (Unix/Linux/Windows/Mac). -At minimum, you need to have Oracle database 19c accessible for the project and SYS account access to install and develop utPLSQL. +At minimum, you need to have Oracle database 19c (we use Release Update 19.20 or later) accessible for the project and SYS account access to install and develop utPLSQL. -We use four different database accounts (users) for development process. +We use five different database accounts (users) for development process. * `ut3` - holds latest released version of utPLSQL. This schema holds the testing framework used for self-testing of utPLSQL development. * `ut3_develop` - holds the version of utPLSQL of your current branch. This is the schema you will be working on. * `ut3_tester` - holds unit test packages for development of utPLSQL. * `ut3_user` - used for testing accessibility to schema names with special characters. * `ut3_tester_helper` - elevated privileges user, used for creating and dropping objects in other schemas during test run. +## Local database in a disposable Docker container + +We use, and recommend, a disposable Docker container with Oracle Database Free, built from [gvenzl/oci-oracle-free](https://github.com/gvenzl/oci-oracle-free/tree/main), using image `gvenzl/oracle-free:slim-faststart`. +The container needs no setup and can be thrown away and recreated whenever you need a clean database. +`ORACLE_PASSWORD` sets the SYS password. Use the same value for `ORACLE_PWD` in `development/env.sh`, and connect to `127.0.0.1:1521/FREEPDB1`. + +Run the container in background: +```bash +docker run -d --name utplsql-db -p 1521:1521 -e ORACLE_PASSWORD=oracle gvenzl/oracle-free:slim-faststart +``` + +Stop the container: +```bash +docker stop utplsql-db +``` + +Restart the container (database content is kept): +```bash +docker restart utplsql-db +``` + +Recreate the container (database content is lost): +```bash +docker rm -f utplsql-db && docker run -d --name utplsql-db -p 1521:1521 -e ORACLE_PASSWORD=oracle gvenzl/oracle-free:slim-faststart +``` +The database is ready to use once `docker logs utplsql-db` shows `DATABASE IS READY TO USE!`. ## Get started with development @@ -86,7 +167,7 @@ You might have to adjust the following lines in `development/env.sh`: ```bash export SQLCLI=sql # For sqlcl client #export SQLCLI=sqlplus # For sqlplus client -export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string +export CONNECTION_STR=127.0.0.1:1521/FREEPDB1 # Adjust the connect string export ORACLE_PWD=oracle # Adjust your local SYS password ``` @@ -106,12 +187,12 @@ The below script is fetching latest release version from utPLSQL repository. Lat ### That's it You now have the following: -- sources from `develop` branch of your fork of utPLSQL repository in `utPLSQL/ut3_latest_release` directory -- sources from `main` branch of utPLSQL/utPLSQL repository in `utPLSQL/ut3_latest_release` directory +- sources from your fork of utPLSQL repository in `utPLSQL` directory +- sources from utPLSQL/utPLSQL repository (branch set by `SELFTESTING_BRANCH` in `development/env.sh`) in `utPLSQL/utPLSQL_latest_release` directory - binaries of `utplsql-cli` in `utPLSQL/utPLSQL-cli` directory - database users created -- your current branch of utPLSQL deployed into `ut3` schema -- utPLSQL released version deployed to `ut3_latest_release` +- your current branch of utPLSQL deployed into `ut3_develop` schema +- utPLSQL released version deployed into `ut3` schema At any time, if you need to refresh your database, the below scripts might be helpful. @@ -121,7 +202,7 @@ At any time, if you need to refresh your database, the below scripts might be he development/cleanup.sh ``` -## Reinstalling utPLSQL development in `ut3` schema +## Reinstalling utPLSQL development in `ut3_develop` schema ```bash development/refresh_ut3.sh diff --git a/LICENSE b/LICENSE index 640d46628..0cc83a7bb 100644 --- a/LICENSE +++ b/LICENSE @@ -187,9 +187,9 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2016 - 2019 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..d60241743 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,31 @@ +# Security Policy + +## Supported versions + +Security fixes are considered for the latest supported release. See the +[utPLSQL releases](https://github.com/utPLSQL/utPLSQL/releases) for the latest +version. + +| Version | Supported | +| --- | --- | +| Latest release | Yes | +| Older releases | No; update to the latest release and check whether the issue persists. | + +## Reporting a vulnerability + +Please report suspected security vulnerabilities privately. **Do not** disclose +them in a public GitHub issue, discussion, or pull request. + +Use GitHub's [Report a vulnerability feature](https://github.com/utPLSQL/utPLSQL/security/advisories/new) +for the utPLSQL repository. + +Include, if possible: + +- The affected utPLSQL version and Oracle Database version. +- A description of the potential impact. +- Steps or a proof of concept to reproduce the issue. +- Any suggested mitigation. + +The maintainers will acknowledge the report and coordinate any investigation, +fix, and disclosure with the reporter. Please allow time to investigate before +making the issue public. diff --git a/SPONSORS.md b/SPONSORS.md new file mode 100644 index 000000000..ad75d347c --- /dev/null +++ b/SPONSORS.md @@ -0,0 +1,14 @@ +# Sponsors + +utPLSQL is free and open source under the Apache 2.0 license. Sponsorship funds its maintenance and development. +To become a sponsor, see [utplsql.org/sponsorship](https://www.utplsql.org/sponsorship.html). + +This file is the complete archive of current and past sponsors. The up-to-date recognition lists are on the [sponsors page](https://www.utplsql.org/sponsors.html). + +## Current sponsors + +None yet. + +## Past sponsors + +- [Redgate](https://www.red-gate.com/hub/events/open-source-projects) (2019) diff --git a/VERSION b/VERSION index 48e1527d1..19db2fb66 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.2.01-develop +v3.2.4-develop diff --git a/development/cleanup.sh b/development/cleanup.sh index d36f21540..54c23b408 100755 --- a/development/cleanup.sh +++ b/development/cleanup.sh @@ -1,7 +1,7 @@ #!/bin/bash #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" . ./development/env.sh @@ -28,6 +28,7 @@ drop user ut3_no_extra_priv_user cascade; drop user ut3_select_catalog_user cascade; drop user ut3_select_any_table_user cascade; drop user ut3_execute_any_proc_user cascade; +drop role ${UT3_DEVELOP_SCHEMA}_cbac_modify_objects_role; set serveroutput on begin diff --git a/development/install.sh b/development/install.sh index 468bafd38..22a3166b2 100755 --- a/development/install.sh +++ b/development/install.sh @@ -1,7 +1,7 @@ #!/bin/bash #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" . ./development/env.sh diff --git a/development/refresh_sources.sh b/development/refresh_sources.sh index 87869d581..36dd20b47 100755 --- a/development/refresh_sources.sh +++ b/development/refresh_sources.sh @@ -1,7 +1,7 @@ #!/bin/bash #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" . ./development/env.sh diff --git a/development/refresh_ut3.sh b/development/refresh_ut3.sh index 827af827d..5fff37e81 100755 --- a/development/refresh_ut3.sh +++ b/development/refresh_ut3.sh @@ -1,14 +1,24 @@ #!/bin/bash +set -e #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" . development/env.sh cd source +"${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA @uninstall ${UT3_DEVELOP_SCHEMA} + +# Same install steps as .github/scripts/install.sh, without recreating the user or public synonyms "${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<-SQL -@uninstall ${UT3_DEVELOP_SCHEMA} +whenever sqlerror exit failure rollback +alter session set plsql_optimize_level=0; @install ${UT3_DEVELOP_SCHEMA} +@create_grants ${UT3_DEVELOP_SCHEMA} PUBLIC +@install_ddl_trigger ${UT3_DEVELOP_SCHEMA} exit SQL + +# Reinstall dropped the grants on ${UT3_DEVELOP_SCHEMA} objects +../.github/scripts/create_test_grants.sh diff --git a/development/releasing.md b/development/releasing.md index ac2091632..9b3f464a1 100644 --- a/development/releasing.md +++ b/development/releasing.md @@ -1,28 +1,27 @@ -## Release process +# Release process -To create a release follow the below steps +To create a release, follow the below steps. ## Release preparation - Create a **draft** of a Release with a new tag number `vX.Y.X` sourced from the `develop` branch on [github releases page](https://github.com/utPLSQL/utPLSQL/releases) - Populate release description using the `Generate release notes` button - Review the auto-generated release notes and update tem if needed + - Add this line at the end of the release notes: `This release was made possible by our sponsors: https://www.utplsql.org/sponsors.html` (a link, not a list of names, so it always shows who is current) - Optionally, split the default `## What's Changed` list into `## New features`, `## Enhancements`, `## Bug fixes`. See previous release notes for details ## Performing a release - Publish [the previously prepared](#release-preparation) release draft. - - Wait for the [Github Actions `Release`](https://github.com/utPLSQL/utPLSQL/actions/workflows/release.yml) process to complete successfully. The process will upload release artifacts (`zip` and `tar.gz` files along with `md5`) - - After Release build was completed successfully, merge the `develop` branch into `main` branch. At this point, main branch and release tag should be at the same commit version and artifacts should be uploaded into Github release. - - Increase the version number in the `VERSION` file on `develop` branch to open start next release version. - - Clone `utplsql.githug.io` project and: - - Add a new announcement about next version being released in `docs/_posts`. Use previous announcements as a template. Make sure to set date, time and post title properly. - - Add the post to list in `mkdocs.yml` file in root directory of that repository. - - Add the link to the post at the beginning of the `docs/index.md` file. - - Send the announcement on Twitter(X) accoiunt abut utPLSQL release. - -The following will happen: - - When a Github release is published, a new tag is added in on the repository and a release build is executed - - With Release action, the documentation for new release is published on `utplsql.github.io` and installation archives are added to the release. + - Wait for the [Github Actions `Release`](https://github.com/utPLSQL/utPLSQL/actions/workflows/release.yml) process to complete successfully. The process will do the following: + - create a new tag + - generate html documentation to be included in the release file. + - publish documentation for the new version into utPLSQL site + - upload release artifacts (`zip` and `tar.gz` files along with `sha256` files) + - update the CHANGELOG.md file with the release details + - publish an announcement about the release in the utPLSQL Organization Discussions + - publish a release post on utplsql.github.io (new post in `docs/announcements/posts`) + - both announcements are created by the shared [announce-release action](https://github.com/utPLSQL/.github/tree/main/actions/announce-release), also used by utPLSQL-cli, utPLSQL-maven-plugin and utPLSQL-java-api + - After the release process is finished, manually increase the version number in the `VERSION` file on `develop` branch to start the next release version. + - Send an announcement about the release on:Twitter(X), BlueSky, LinkedIn account about the utPLSQL release. # Note: -The utPLSQL installation files are uploaded by the release build process as release artifacts (separate `zip` and `tar.gz` files). The release artifacts include HTML documentation generated from MD files, sources and tests diff --git a/docs/about/authors.md b/docs/about/authors.md deleted file mode 100644 index 687c6cfaa..000000000 --- a/docs/about/authors.md +++ /dev/null @@ -1,26 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) - -### utPLSQL v3 Major Contributors - -**Listed Alphabetically** - -| Name | GitHub account -| ---------------- | -------------- -| David Pyke | [Shoelace](https://github.com/Shoelace) -| Jacek Gebal | [jgebal](https://github.com/jgebal) -| Lukasz Wasylow | [lwasylow](https://github.com/lwasylow/) -| Pavel Kaplya | [Pazus](https://github.com/Pazus) -| Robert Love | [rlove](https://github.com/rlove) -| Samuel Nitsche | [pesse](https://github.com/pesse/) -| Vinicius Avellar | [viniciusam](https://github.com/viniciusam/) - - - -Many thanks to all the [contributors](https://github.com/utPLSQL/utPLSQL/graphs/contributors) - -### Special thanks to prior major contributors - -- Steven Feuerstein - Original Author of utPLSQL v1 and v2 -- Chris Rimmer -- Patrick Barel -- Paul Walker diff --git a/docs/about/license.md b/docs/about/license.md deleted file mode 100644 index 6567b5db7..000000000 --- a/docs/about/license.md +++ /dev/null @@ -1,13 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) - -# Version Information - -**utPLSQL version 3** is licensed under -[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) - -External code used in the development of this project, but is not required for use. - -| Tool | License | Purpose | -| ---- | --------| --------| -| [mkDocs](http://www.mkdocs.org/) | [BSD](http://www.mkdocs.org/about/license/) | Produce HTML version of documentation | - diff --git a/docs/about/project-details.md b/docs/about/project-details.md deleted file mode 100644 index df666731f..000000000 --- a/docs/about/project-details.md +++ /dev/null @@ -1,18 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) - -# utPLSQL Project Details - -[![chat](http://img.shields.io/badge/GitHub_Project-Active-blue.svg)](https://github.com/utPLSQL/utPLSQL) -[![license](http://img.shields.io/badge/license-apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) -[![GitHub Discussions](https://img.shields.io/github/discussions/utPLSQL/utPLSQL)](https://github.com/utPLSQL/utPLSQL/discussions) -[![twitter](https://img.shields.io/twitter/follow/utPLSQL.svg?style=social&label=Follow)](https://twitter.com/utPLSQL) - - -utPLSQL is open source project [hosted on GitHub](https://github.com/utPLSQL/utPLSQL). - -Contributions, help and constructive feedback is always appreciated. - -If you are interested in helping please read our [contributing guide](https://github.com/utPLSQL/utPLSQL/blob/develop/CONTRIBUTING.md) - - - diff --git a/docs/about/support.md b/docs/about/support.md deleted file mode 100644 index f27ee0c1e..000000000 --- a/docs/about/support.md +++ /dev/null @@ -1,7 +0,0 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) - -# How to get support - -- Look into [utPLSQL github discussions](https://github.com/utPLSQL/utPLSQL/discussions) to find support, ask questions and share ideas -- If needed open a new [issue on github](https://github.com/utPLSQL/utPLSQL/issues) for bugs or feature requests - diff --git a/docs/compare_version2_to_3.md b/docs/compare_version2_to_3.md index 5f53e41d4..121fafc59 100644 --- a/docs/compare_version2_to_3.md +++ b/docs/compare_version2_to_3.md @@ -37,7 +37,6 @@ There is a [migration tool](https://github.com/utPLSQL/utPLSQL-v2-v3-migration) | **Code Coverage Reporting** | No | Yes | | Html Coverage Report | No | Yes | | Sonar XML Coverage Report | No | Yes | -| Coveralls Json Coverage Report | No | Yes | | Framework Transaction Control | No | Yes - Annotations1 | | **Test Output** | | | | Real-time test execution progress reporting | No | Yes | diff --git a/docs/images/supported_by_redgate_100.png b/docs/images/supported_by_redgate_100.png deleted file mode 100644 index ea9f93ac5..000000000 Binary files a/docs/images/supported_by_redgate_100.png and /dev/null differ diff --git a/docs/index.md b/docs/index.md index 6ae326c1c..c0b531359 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,9 +1,11 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) ## What is utPLSQL utPLSQL is a Unit Testing framework for Oracle PL/SQL. -The framework follows industry standards and best patterns of modern Unit Testing frameworks like [JUnit](http://junit.org/junit4/) and [RSpec](http://rspec.info/) +The framework follows industry standards and best patterns of modern Unit Testing frameworks like [JUnit](https://junit.org/) and [RSpec](https://rspec.info/). + +See [About](https://www.utplsql.org/about.html) for project history, contributors and stewardship. ## Demo project @@ -11,18 +13,18 @@ Have a look at [utPLSQL demo project](https://github.com/utPLSQL/utPLSQL-demo-pr - sample code and tests - demo of deployment automation that leverages: - - Flyway / Liquidbase for scripting and deployment of DB changes + - Flyway / Liquibase for scripting and deployment of DB changes - Docker container with Oracle XE Database - GitHub Actions and Azure Pipelines to orchestrate the deployment and testing process - - utPLSQL framework for writhing, execution of tests as well as reporting test results and code coverage - - [Sonar]((https://sonarcloud.io/project/overview?id=utPLSQL:utPLSQL-demo-project).) for code quality gate, test results and code coverage reporting + - utPLSQL framework for writing and executing tests, as well as reporting test results and code coverage + - [Sonar](https://sonarcloud.io/project/overview?id=utPLSQL:utPLSQL-demo-project) for code quality gate, test results and code coverage reporting ## Three steps With just three simple steps you can define and run your unit tests for PLSQL code. 1. Install the utPLSQL framework -2. Create Unit Tests to for the code +2. Create unit tests for the code 3. Run the tests Here is how you can simply create tested code, unit tests and execute the tests using SQL Developer diff --git a/docs/overrides/main.html b/docs/overrides/main.html new file mode 100644 index 000000000..fdfe1a3be --- /dev/null +++ b/docs/overrides/main.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{# + Sub-repository template override. + Loads the shared utPLSQL.org top navigation bar from the central org site. + The topbar.js file is the single source of truth β€” update nav links there only. +#} + +{% block extrahead %} + {{ super() }} + + +{% endblock %} diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index 7f05ab831..ff7721882 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -1,12 +1,64 @@ [data-md-color-scheme="default"] { - --md-primary-fg-color: #2f8bff; - --md-accent-fg-color: #1f5db0; - --md-accent-fg-color--transparent: #1f5db0; + --md-primary-fg-color: #1565c0; /* link + header colour: 5.8:1 with white text */ + --md-typeset-a-color: #1565c0; /* link = header colour: 5.8:1 */ + --md-accent-fg-color: #1e88e5; /* hover: lighter than the link, 3.7:1 */ + --md-accent-fg-color--transparent: rgba(30, 136, 229, .1); + --md-default-fg-color--light: hsla(0, 0%, 0%, .64); /* muted text 6.7:1 */ } [data-md-color-scheme="slate"] { - --md-hue: 200; - --md-primary-fg-color: #2f8bff; - --md-accent-fg-color: #1f5db0; - --md-accent-fg-color--transparent: #1f5db0; + --md-hue: 215; + --md-primary-fg-color: #1565c0; /* header background keeps the brand blue */ + --md-accent-fg-color: #3578cc; /* hover: darker than the link, 3.6:1 */ + --md-accent-fg-color--transparent: rgba(53, 120, 204, .1); + --md-default-fg-color: hsla(var(--md-hue), 15%, 90%, .90); /* body ~10:1 */ + --md-default-fg-color--light: hsla(var(--md-hue), 15%, 90%, .68); /* muted 6.5:1 */ + --md-code-hl-keyword-color: hsl(219, 80%, 72%); +} + +/* Material sets the dark link colour per primary colour with higher specificity */ +[data-md-color-scheme="slate"][data-md-color-primary] { + --md-typeset-a-color: #4a90e2; /* link: header blue lightened just enough to read on dark, 4.8:1 */ +} + +/* Footer: make the sponsor and cookie links stand out from the copyright text */ +.md-copyright a.footer-sponsor { + display: inline-flex; + overflow: hidden; + margin: 0 .4rem; + font-size: .65rem; + font-weight: 600; + line-height: 1; + color: #fff; + text-decoration: none; + vertical-align: middle; + border-radius: .2rem; +} + +.footer-sponsor__label, +.footer-sponsor__name { + padding: .3rem .5rem; +} + +.footer-sponsor__label { + background: #555; +} + +.footer-sponsor__name { + background: #ea4aaa; +} + +.md-copyright a.footer-sponsor:hover { + color: #fff; + opacity: .85; +} + +.md-copyright a.footer-cookies { + color: var(--md-footer-fg-color); + text-decoration: underline; + text-underline-offset: .15em; +} + +.md-copyright a.footer-cookies:hover { + color: var(--md-accent-fg-color); } diff --git a/docs/userguide/advanced_data_comparison.md b/docs/userguide/advanced_data_comparison.md index 76d90bc30..50e2bbd0d 100644 --- a/docs/userguide/advanced_data_comparison.md +++ b/docs/userguide/advanced_data_comparison.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) # Advanced data comparison diff --git a/docs/userguide/annotations.md b/docs/userguide/annotations.md index fd51fec8f..13ed97a23 100644 --- a/docs/userguide/annotations.md +++ b/docs/userguide/annotations.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) Annotations are used to configure tests and suites in a declarative way similar to modern OOP languages. This way, test configuration is stored along with the test logic inside the test package. No additional configuration files or tables are needed for test cases. The annotation names are based on popular testing frameworks such as JUnit. @@ -23,8 +23,8 @@ In below example we have a `suite` annotation with `Stuff) -- we should name thi Do not place comments within annotation line to avoid unexpected behaviors. -**Note:** ->Annotations are interpreted only in the package specification and are case-insensitive. We strongly recommend using lower-case annotations as described in this documentation. +!!! note + Annotations are interpreted only in the package specification and are case-insensitive. We strongly recommend using lower-case annotations as described in this documentation. There are two distinct types of annotations, identified by their location in package. - package annotations @@ -151,15 +151,13 @@ The `--%suite` annotation denotes PLSQL package as a unit test suite. It accepts an optional description that will be visible when running the tests. When description is not provided, package name is displayed on report. -**Note** ->Package is considered a test-suite only when package specification contains the `--%suite` annotation at the package level. -> ->Some annotations like `--%suite`, `--%test` and `--%displayname` accept parameters. The parameters for annotations need to be placed in brackets. -Values for parameters should be provided without any quotation marks. -If the parameters are placed without brackets or with incomplete brackets, they will be ignored. -> ->Example: `--%suite(The name of suite without closing bracket` ->Example: `--%suite The name of suite without brackets` +!!! note + Package is considered a test-suite only when package specification contains the `--%suite` annotation at the package level. + Some annotations like `--%suite`, `--%test` and `--%displayname` accept parameters. The parameters for annotations need to be placed in brackets. + Values for parameters should be provided without any quotation marks. + If the parameters are placed without brackets or with incomplete brackets, they will be ignored. + Example: `--%suite(The name of suite without closing bracket` + Example: `--%suite The name of suite without brackets` Suite package without description. @@ -459,7 +457,7 @@ Finished in .005868 seconds ### Beforeall -There are two possible ways to use the `--%beforeall` annotation. +There are two possible ways to use the `--%beforeall` annotation. As a procedure level annotation: ```sql linenums="1" @@ -545,7 +543,7 @@ Finished in .012292 seconds ``` In the below example a combination pacakge and procedure level `--%beforeall` annotations is used. -The order of execution of the beforeall procedures is determined by the annotation position in package. +The execution order of the `--%beforeall` procedures is determined by the annotation position in the package. All of the `--%beforeall` procedures get invoked before any test is executed in a suite. ```sql linenums="1" create or replace package test_package as @@ -672,6 +670,8 @@ Finished in .012158 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 2 warning(s) ``` +!!! note "Suite scope" + The `--%beforeall` procedrues in parent suite package are always part of all suite packages that are children on the suitepath. ### Afterall @@ -759,6 +759,10 @@ Finished in .014161 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` +!!! note "Suite scope" + The `--%afterall` procedrues in parent suite package are always part of all suite packages that are children on the suitepath. + + ### Beforeeach The procedure annotated as `--%beforeeach` is getting executed before each test in a suite. @@ -868,6 +872,9 @@ Finished in .014683 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` +!!! note "Package scope" + Unlike `--%beforeall`, the `--%beforeeach` annotation is only applicable within the scope of current test suite package. The `--%beforeeach` annotations from parent suite package are ignored. + See [beforeall](#Beforeall) for more examples. ### Aftereach @@ -977,6 +984,9 @@ Finished in .018115 seconds 2 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s) ``` +!!! note "Package scope" + Unlike `--%afterall`, the `--%aftereach` annotation is only applicable within the scope of current test suite package. The `--%aftereach` annotations from parent suite package are ignored. + See [beforeall](#Beforeall) for more examples. ### Beforetest @@ -1694,6 +1704,10 @@ end test_payment_set_off; When you execute tests for your application, the framework constructs a test suite for each test package. Then it combines suites into grouping suites by the `--%suitepath` annotation value so that the fully qualified path to the `recognize_by_num` procedure is `USER:payments.test_payment_recognition.test_recognize_by_num`. If any of its expectations fails then the test is marked as failed, also the `test_payment_recognition` suite, the parent suite `payments` and the whole run is marked as failed. The test report indicates which expectation has failed on the payments module. The payments recognition submodule is causing the failure as `recognize_by_num` has not met the expectations of the test. Grouping tests into modules and submodules using the `--%suitepath` annotation allows you to logically organize your project's flat structure of packages into functional groups. +!!! note "Suitepath limits" + - A suitepath can have at most 20 levels (elements separated by dots), for example `org.utplsql.example` has 3. Suites with a deeper suitepath are not run and not listed. + - The full path of every suite item (suitepath, package, contexts and test name) can be at most 1000 characters long. Longer paths raise an error when the suites are built. + An additional advantage of such grouping is the fact that every element level of the grouping can be an actual unit test package containing a common module level setup for all of the submodules. So in addition to the packages mentioned above you could have the following package. ```sql linenums="1" create or replace package payments as @@ -1715,6 +1729,8 @@ When executing tests, `path` for executing tests can be provided in three ways: * [schema]:suite1[.suite2][.suite3]...[.procedure] - execute all tests by `suitepath` in all suites on path suite1[.suite2][.suite3]...[.procedure]. If schema is not provided, then the current schema is used. Example: `:all.rooms_tests` * [schema.]package[.procedure] - execute all tests in the specified test package. The whole hierarchy of suites in the schema is built before all before/after hooks or part suites for the provided suite package are executed as well. Example: `tests.test_contact.test_last_name_validator` or simply `test_contact.test_last_name_validator` if `tests` is the current schema. +!!! note + Only the `beforeall` and `afterall` hooks of the parent suite are executed for the suite package. The `beforeeach` and `aftereach` hooks of the suite package are not executed. ### Rollback @@ -1740,12 +1756,12 @@ Doing so allows your tests to use the framework's automatic transaction control When you are testing code that performs explicit or implicit commits, you may set the test procedure to run as an autonomous transaction with `pragma autonomous_transaction`. Keep in mind that when your test runs as autonomous transaction it will not see the data prepared in a setup procedure unless the setup procedure committed the changes. -**Note** -> The `--%suitepath` annotation, when used, must be provided with a value of path. -> The path in suitepath cannot contain spaces. Dot (.) identifies individual elements of the path. -> -> Example: `--%suitepath(org.utplsql.core.utils)` -> +!!! note + The `--%rollback(manual)` annotation is only relevant for suites that use shared setup/cleanup with beforeall, + The `--%suitepath` annotation, when used, must be provided with a value of path. + The path in suitepath cannot contain spaces. Dot (.) identifies individual elements of the path. + Example: `--%suitepath(org.utplsql.core.utils)` + ### Throws @@ -1753,11 +1769,11 @@ Keep in mind that when your test runs as autonomous transaction it will not see The `--%throws` annotation allows you to specify a list of exceptions as one of: - number literals - example `--%throws(-20134)` -- variables of type exception defined in a package specification - example `--%throws(exc_pkg.c_exception_No_variable)` -- variables of type number defined in a package specification - example `--%throws(exc_pkg.c_some_exception)` +- variables of type `exception` defined in a package specification - example `--%throws(exc_pkg.c_exception_no_variable)` +- variables or constants of containing a valid negative exception number defined in a package specification - example `--%throws(exc_pkg.c_some_exception)` - [predefined oracle exceptions](https://docs.oracle.com/en//database/oracle/oracle-database/19/lnpls/predefined-exceptions.html) - example `--%throws(no_data_found)` -The annotation is ignored, when no valid arguments are provided. Examples of invalid annotations `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`. +The annotation is ignored when no valid arguments are provided. Examples of invalid annotations `--%throws()`,`--%throws`, `--%throws(abe, 723pf)`. If `--%throws` annotation is specified with arguments and no exception is raised, the test is marked as failed. @@ -1768,22 +1784,30 @@ The framework will raise a warning, when `--%throws` annotation has invalid argu Annotation `--%throws(7894562, operaqk, -=1, -20496, pow74d, posdfk3)` will be interpreted as `--%throws(-20496)`. Please note that `NO_DATA_FOUND` exception is a special case in Oracle. To capture it use `NO_DATA_FOUND` named exception or `-1403` exception No. - + +Syntax: `--%throws( [[schema.]package.]exception [, ... ])` + +The exception name can be provided with or without the schema and package name. The package name is required only when the exception variable is located in another package than the unit test package. The schema name is required only when the exception variable is located in a package in another schema. + Example: ```sql linenums="1" create or replace package exc_pkg is c_e_option1 constant number := -20200; c_e_option2 constant varchar2(10) := '-20201'; - c_e_option3 number := -20202; - - e_option4 exception; - pragma exception_init(e_option4, -20203); + c_e_option3 integer := -20202; + e_initialized_exception exception; + pragma exception_init(e_initialized_exception, -20203); + + e_uninitialized_exception exception; end; / create or replace package example_pgk as + e_local_exception exception; + e_local_exception_num constant integer := -20123; + --%suite(Example Throws Annotation) --%test(Throws one of the listed exceptions) @@ -1814,10 +1838,22 @@ create or replace package example_pgk as --%throws(exc_pkg.c_e_option3) procedure raised_option3_exception; - --%test(Throws package exception option4) - --%throws(exc_pkg.e_option4) - procedure raised_option4_exception; + --%test(Throws exception associated with exception number) + --%throws(exc_pkg.e_initialized_exception) + procedure raised_initialized_exception; + + --%test(Throws uninitialized exception) + --%throws(exc_pkg.e_uninitialized_exception) + procedure raised_uninitialized_exception; + --%test(Throws exception local to unit tests package) + --%throws(e_local_exception) + procedure raised_local_exception; + + --%test(Throws exception local to unit tests package with exception number) + --%throws(e_local_exception_num) + procedure raised_local_exception_num; + --%test(Raise name exception) --%throws(DUP_VAL_ON_INDEX) procedure raise_named_exc; @@ -1828,6 +1864,7 @@ create or replace package example_pgk as end; / + create or replace package body example_pgk is procedure raised_one_listed_exception is begin @@ -1864,11 +1901,28 @@ create or replace package body example_pgk is raise_application_error(exc_pkg.c_e_option3, 'Test error'); end; - procedure raised_option4_exception is + procedure raised_initialized_exception is begin - raise exc_pkg.e_option4; + raise exc_pkg.e_initialized_exception; end; + procedure raised_uninitialized_exception is + begin + raise exc_pkg.e_uninitialized_exception; + end; + + procedure raised_local_exception is + pragma autonomous_transaction; + begin + raise e_local_exception; + end; + + procedure raised_local_exception_num is + pragma autonomous_transaction; + begin + raise_application_error(e_local_exception_num, 'Test error'); + end; + procedure raise_named_exc is begin raise DUP_VAL_ON_INDEX; @@ -1887,48 +1941,55 @@ exec ut3.ut.run('example_pgk'); Running the test will give report: ``` Example Throws Annotation - Throws one of the listed exceptions [.002 sec] - Throws different exception than expected [.002 sec] (FAILED - 1) - Throws different exception than listed [.003 sec] (FAILED - 2) - Gives failure when an exception is expected and nothing is thrown [.002 sec] (FAILED - 3) - Throws package exception option1 [.003 sec] - Throws package exception option2 [.002 sec] - Throws package exception option3 [.002 sec] - Throws package exception option4 [.002 sec] - Raise name exception [.002 sec] - Invalid throws annotation [.002 sec] - + Throws one of the listed exceptions [,026 sec] + Throws different exception than expected [,009 sec] (FAILED - 1) + Throws different exception than listed [,014 sec] (FAILED - 2) + Gives failure when an exception is expected and nothing is thrown [,016 sec] (FAILED - 3) + SUCCESS + Actual: 1 (number) was expected to equal: 1 (number) + Throws package exception option1 [,007 sec] + Throws package exception option2 [,008 sec] + Throws package exception option3 [,007 sec] + Throws exception associated with exception number [,006 sec] + Throws uninitialized exception [,006 sec] + Throws exception local to unit tests package [,009 sec] + Throws exception local to unit tests package with exception number [,011 sec] + Raise name exception [,006 sec] + Invalid throws annotation [,004 sec] + Failures: - + 1) raised_different_exception Actual: -20143 was expected to equal: -20144 ORA-20143: Test error - ORA-06512: at "UT3.EXAMPLE_PGK", line 9 - ORA-06512: at "UT3.EXAMPLE_PGK", line 9 - ORA-06512: at line 6 - + ORA-06512: at "UT3_TESTER.EXAMPLE_PGK", line 9 + ORA-06512: at "UT3_TESTER.EXAMPLE_PGK", line 9 + ORA-06512: at line 7 + 2) raised_unlisted_exception Actual: -20143 was expected to be one of: (-20144, -1, -20145) ORA-20143: Test error - ORA-06512: at "UT3.EXAMPLE_PGK", line 14 - ORA-06512: at "UT3.EXAMPLE_PGK", line 14 - ORA-06512: at line 6 - + ORA-06512: at "UT3_TESTER.EXAMPLE_PGK", line 14 + ORA-06512: at "UT3_TESTER.EXAMPLE_PGK", line 14 + ORA-06512: at line 7 + 3) nothing_thrown Expected one of exceptions (-20459, -20136, -20145) but nothing was raised. - - + + Warnings: - - 1) example_pgk + + 1) example_pgk.raised_one_listed_exception Invalid parameter value "bad" for "--%throws" annotation. Parameter ignored. - at "UT3.EXAMPLE_PGK.RAISED_ONE_LISTED_EXCEPTION", line 6 + at package "UT3_TESTER.EXAMPLE_PGK.RAISED_ONE_LISTED_EXCEPTION", line 8 + 2) example_pgk "--%throws" annotation requires a parameter. Annotation ignored. - at "UT3.EXAMPLE_PGK.BAD_THROWS_ANNOTATION", line 42 - -Finished in .025784 seconds -10 tests, 3 failed, 0 errored, 0 disabled, 2 warning(s) + at package "UT3_TESTER.EXAMPLE_PGK.BAD_THROWS_ANNOTATION", line 57 + +Finished in ,138276 seconds +13 tests, 3 failed, 0 errored, 0 disabled, 2 warning(s) + ``` ## Order of execution diff --git a/docs/userguide/best-practices.md b/docs/userguide/best-practices.md index c9f08eab5..ff7e26fdb 100644 --- a/docs/userguide/best-practices.md +++ b/docs/userguide/best-practices.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) The following are best practices we at utPLSQL have learned about PL/SQL and Unit Testing. diff --git a/docs/userguide/coverage.md b/docs/userguide/coverage.md index 03cb8bfd3..6dd9a233c 100644 --- a/docs/userguide/coverage.md +++ b/docs/userguide/coverage.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) utPLSQL comes with a built-in coverage reporting engine. The code coverage reporting combines data from package DBMS_PROFILER and DBMS_PLSQL_CODE_COVERAGE. Code coverage is gathered for the following source types: @@ -22,7 +22,6 @@ To obtain information about code coverage for unit tests, run utPLSQL with one o The following code coverage reporters are supplied with utPLSQL: * `ut_coverage_html_reporter` - generates a HTML coverage report providing summary and detailed information on code coverage. The HTML reporter is based on the open-source [simplecov-html](https://github.com/colszowka/simplecov-html) reporter for Ruby. It includes source code of the code that was covered (if the code is accessible for test user) -* `ut_coveralls_reporter` - generates a [Coveralls compatible JSON](https://coveralls.zendesk.com/hc/en-us/articles/201774865-API-Introduction) coverage report providing detailed information on code coverage with line numbers. This coverage report is designed to be consumed by cloud services like [Coveralls](https://coveralls.io) * `ut_coverage_sonar_reporter` - generates a [Sonar Compatible XML](https://docs.sonarqube.org/latest/analysis/generic-test/) coverage report providing detailed information on code coverage with line numbers. This coverage report is designed to be consumed by services like [SonarQube](https://www.sonarqube.org/) and [SonarCloud](https://about.sonarcloud.io/) * `ut_coverage_cobertura_reporter` - generates a basic Cobertura coverage (http://cobertura.sourceforge.net/xml/coverage-04.dtd) report providing detailed information on code coverage with line numbers. This coverage report is designed to be consumed by services like TFS and Jenkins. Check this link for an example of XML generated by Java: https://raw.githubusercontent.com/jenkinsci/cobertura-plugin/master/src/test/resources/hudson/plugins/cobertura/coverage-with-data.xml @@ -141,19 +140,49 @@ end; #### Filtering objects in coverage reports -Multiple parameters can be used to define the scope of coverage report. +By default, coverage is reported on all objects of the schema(s) described above. Several parameters narrow the scope of the coverage report. +You can describe the scope with lists of names, or with regular expressions that match names. -- `a_source_file_mappings ( ut_file_mappings )` - map of filenames to database objects. It is used for file-based coverage - see below. -- `a_include_schema_expr ( varchar(4000) )` - string of regex expression of schemas to be included in the coverage report. Case-insensitive. -- `a_include_object_expr ( varchar(4000) )` - string of regex expression of objects ( without schema name ) to be included in the coverage report. Case-insensitive. -- `a_exclude_schema_expr ( varchar(4000) )` - string of regex expression of schemas to be excluded from the coverage report. Case-insensitive. -- `a_exclude_object_expr ( varchar(4000) )` - string of regex expression of objects ( without schema name ) to be excluded from the coverage report. Case-insensitive. -- `a_coverage_schemes ( ut_varchar2_list )` - List of database schema names to gather coverage on. -- `a_include_objects ( ut_varchar2_list )` - list of `[object_owner.]object_name` to be included in the coverage report. -- `a_exclude_objects ( ut_varchar2_list )` - list of `[object_owner.]object_name` to be excluded from the coverage report. +| Parameter | Type | Meaning | +|-------------------------|----------------------|------------------------------------------------------------------------------------------------------| +| `a_coverage_schemes` | `ut_varchar2_list` | schemas to gather coverage on | +| `a_include_objects` | `ut_varchar2_list` | `[object_owner.]object_name` to be included in the coverage report | +| `a_exclude_objects` | `ut_varchar2_list` | `[object_owner.]object_name` to be excluded from the coverage report | +| `a_include_schema_expr` | `varchar2(4000)` | regular expression, schemas whose name matches are included in the coverage report | +| `a_include_object_expr` | `varchar2(4000)` | regular expression, objects whose name (without schema name) matches are included in the report | +| `a_exclude_schema_expr` | `varchar2(4000)` | regular expression, schemas whose name matches are excluded from the coverage report | +| `a_exclude_object_expr` | `varchar2(4000)` | regular expression, objects whose name (without schema name) matches are excluded from the report | +| `a_source_file_mappings`| `ut_file_mappings` | map of filenames to database objects, used for file-based coverage - see [Project based Coverage](#project-based-coverage) | + +Use lists when the scope is a handful of known objects. Use regular expressions when the scope follows a naming convention, +for example all schemas that start with `APP_`, or all objects that end with `_TMP`. +A rule written once as a regular expression also covers the objects and schemas that are created later. You may specify both _include_ and _exclude_ options to gain more control over what needs to be included / excluded from the coverage report. +An object is reported when it passes the include filters and does not match any of the exclude filters. + +##### Regular expressions + +- The expression is evaluated by Oracle `REGEXP_LIKE`. It is **case-insensitive**, so `app_` matches `APP_ORDERS`. +- A schema expression is matched against the schema name. An object expression is matched against the object name **without** the schema name. +- The expression is **not anchored**. `util` matches `UT_UTILS`, `UTIL_TRAINING` and `ERROR_UTIL_2`. + Use `^` to match from the beginning of the name and `$` to match up to the end, for example `^app_` or `_tmp$`. +- When both an include schema expression and an include object expression are specified, an object must match both. + +##### Which parameters are used when several are given + +| If you specify | utPLSQL ignores | +|-----------------------------------------------------------------|-----------------------------------------------------------| +| `a_source_file_mappings` | all other include/exclude parameters | +| `a_include_schema_expr` or `a_include_object_expr` | `a_include_objects` (and associated `a_coverage_schemes`) | +| `a_exclude_schema_expr` or `a_exclude_object_expr` | `a_exclude_objects` (and associated `a_coverage_schemes`) | +Everything else can be combined. In particular: + +- include expressions can be combined with exclude expressions and with `a_exclude_objects`, +- `a_exclude_schema_expr` and `a_exclude_object_expr` can be used together, +- without include parameters, coverage is gathered on the schemas described in [Setting coverage schema(s)](#setting-coverage-schemas) + and the exclude parameters remove objects from that scope. !!! warning "Important note" @@ -161,158 +190,158 @@ You may specify both _include_ and _exclude_ options to gain more control over w - if `a_source_file_mappings` is defined then all include/exclude parameters are ignored (see section below for usage of `a_source_file_mappings` parameter )
- else if `a_include_schema_expr` or `a_include_object_expr` parameter is specified then parameters `a_coverage_schemes` and `a_include_objects` are ignored
- else if `a_include_objects` is specified then the coverage is gathered only on specified database objects.
- - if `a_coverage_schemes` is specified then those schemas are used for objects in `a_include_objects` without schema name
- - if `a_coverage_schemes` is not specified then schema from paths (`a_paths`) parameter are used for objects in `a_include_objects` without schema name
+ - if `a_coverage_schemes` is specified then those schemas are used for objects without schema name in `a_include_objects` and `a_exclude_objects`
+ - if `a_coverage_schemes` is not specified then schema from paths (`a_paths`) parameter are used for objects without schema name in `a_include_objects` and `a_exclude_objects`
- else if, only the `a_coverage_schemes` is specified then the coverage is gathered only on specified database schemas
- else if no coverage specific parameters are provided coverage is gathered on all schemas specified in paths passed to run procedure
- else if no paths were specified, the coverage is gathered on current schema of the session running the tests -The exclude parameters are not mutually-exclusive and can be mixed together. All of exclude parameters are always applied. +##### Examples -Example: Limiting coverage by schema regex. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_include_schema_expr => '^ut3_develop' - ); -end; -``` -Will result in showing coverage for all schemas that match regular expression `^ut3_develop` +The examples use a system split into schemas `app_orders` and `app_billing` that contain the application code, +and schemas `app_orders_test` and `app_billing_test` that contain the unit tests. -Example: Limiting coverage by schema regex with parameter `a_include_objects` ignored. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_include_schema_expr => '^ut3_develop', a_include_objects => ut_varchar2_list( 'ut3_tester_helper.regex_dummy_cov' ) - ); -end; -``` -Will result in showing coverage for all schemas that match regular expression `^ut3_develop`. +###### Filtering by lists of names -Example: Limiting coverage by object regex. +Example: Limiting coverage by object name, for tested code located in the same schema as the unit tests. ```sql linenums="1" begin ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_include_object_expr => 'regex123' + a_include_objects=>ut_varchar2_list('award_bonus') ); end; ``` -Will result in showing coverage for all objects that name match regular expression `regex123`. +Executes all tests in schemas: `user_1` and `user_2`. Coverage will only be reported on objects `user_1.award_bonus`, `user_2.award_bonus` -Example: Limiting coverage by object regex with parameter `a_include_objects` ignored. -```sql linenums="1" -begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_include_object_expr => 'utl', a_include_objects => ut_varchar2_list( 'user_2.utils_package' ) - ); -end; -``` -Will result in showing coverage for all objects that name match regular expression `utl`. -Example: Limiting coverage by excluding schema with regex. +Example: Limiting coverage by object name, for tested code located in different schemas than the unit tests. ```sql linenums="1" begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_exclude_schema_expr => 'er_1$' + ut.run( + 'unit_test_schema', ut_coverage_html_reporter(), + a_coverage_schemes => ut_varchar2_list('user_1','user_2'), + a_include_objects => ut_varchar2_list('award_bonus', 'betwnstr') ); end; ``` -Will result in showing coverage for objects in all schema except schemas that are matching regular expression `er_1$` +Executes all tests in schema `unit_test_schema`. Coverage will only be reported on objects `user_1.award_bonus`, `user_2.award_bonus`, `user_1.betwnstr`, `user_2.betwnstr`. +Objects that do not exist in the database but were specified in `a_include_objects` will be ignored. -Example: Limiting coverage by excluding schema with regex and excluding specific object. +Example: Limiting coverage by object owner and name. ```sql linenums="1" begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_exclude_schema_expr => 'er_1$', a_exclude_objects => ut_varchar2_list( 'user_2.utils_package' ) + ut.run( + 'unit_test_schema', ut_coverage_html_reporter(), + a_include_objects => ut_varchar2_list('user_1.award_bonus','user_2.betwnstr') ); end; ``` -Will result in showing coverage for objects in all schemas except schemas that are matching regular expression `er_1$` -Will also exclude object `user_2.utils_package` from coverage report +Executes all tests in schema `unit_test_schema`. Coverage will only be reported on objects `user_1.award_bonus`, `user_2.betwnstr` + +The `a_exclude_objects` can be used in the same way as `a_include_objects`. -Example: Limiting coverage by excluding objects with regex. +Example: Excluding objects from coverage report by providing a list of object owner/name to be excluded. ```sql linenums="1" begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_exclude_object_expr => 'utl' + ut.run( + 'unit_test_schema.test_award_bonus', ut_coverage_html_reporter(), + a_exclude_objects => ut_varchar2_list('ut3_user.betwnstr') ); end; ``` -Will result in showing coverage for all objects that name is not matching regular expression `utl`. +Executes test `test_award_bonus` in schema `unit_test_schema`. Coverage will be reported on all objects in schema `ut3_user` except the `betwnstr` object. + +###### Filtering by regular expressions -Example: Limiting coverage by excluding objects with regex with parameter `a_exclude_objects` ignored. +Example: Tests are located in other schemas than the application code. Report coverage on the application schemas, selected by a pattern. ```sql linenums="1" begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_exclude_object_expr => 'utl', a_exclude_objects => ut_varchar2_list( 'user_2.utils_package' ) + ut.run( + ut_varchar2_list('app_orders_test','app_billing_test'), ut_coverage_html_reporter(), + a_include_schema_expr => '^app_(orders|billing)$' ); end; ``` -Will result in showing coverage for all objects that name is not matching regular expression `utl`. -Will also exclude object `user_2.utils_package` from coverage report - +Executes all tests in schemas `app_orders_test` and `app_billing_test`. +Coverage will be reported on all objects in the schemas `app_orders` and `app_billing`, even though those schemas are not mentioned in the paths. +Any other schema whose name matches the expression is reported as well. -Example: Limiting coverage by object name, for tested code located in the same schema as the unit tests. +Example: Include all application schemas and exclude the test schemas, using one include and one exclude expression. ```sql linenums="1" begin - ut.run(ut_varchar2_list('user_1','user_2'), ut_coverage_html_reporter(), - a_include_objects=>ut_varchar2_list('award_bonus') + ut.run( + ut_varchar2_list('app_orders_test','app_billing_test'), ut_coverage_html_reporter(), + a_include_schema_expr => '^app_', + a_exclude_schema_expr => '_test$' ); end; ``` -Executes all tests in schemas: `user_1` and `user_2`. Coverage will only be reported on objects `user_1.award_bonus`, `user_2.award_bonus` - +Coverage will be reported on all schemas whose name starts with `app_` except the ones whose name ends with `_test`. +When a new schema `app_shipping` is created, it is included without any change to the call. -Example: Limiting coverage by object name, for tested code located in different schemas than the unit tests. +Example: Report coverage on one functional area of a schema, identified by a naming convention. ```sql linenums="1" begin ut.run( - 'unit_test_schema', ut_coverage_html_reporter(), - a_coverage_schemes => ut_varchar2_list('user_1','user_2'), - a_include_objects => ut_varchar2_list('award_bonus', 'betwnstr') + 'app_orders_test', ut_coverage_html_reporter(), + a_include_schema_expr => '^app_orders$', + a_include_object_expr => '^(ord|invoice)_' ); end; ``` -Executes all tests in schema `unit_test_schema`. Coverage will only be reported on objects `user_1.award_bonus`, `user_2.award_bonus`, `user_1.betwnstr`, `user_2.betwnstr`. -Objects that do not exist in the database but were specified in `a_include_objects` will be ignored. +Coverage will be reported only on objects in schema `app_orders` whose name starts with `ord_` or `invoice_`. -Example: Limiting coverage by object owner and name. +Example: Keep generated and temporary objects out of the coverage report. ```sql linenums="1" begin ut.run( - 'unit_test_schema', ut_coverage_html_reporter(), - a_include_objects => ut_varchar2_list('user_1.award_bonus','user_2.betwnstr') + 'app_orders_test', ut_coverage_html_reporter(), + a_coverage_schemes => ut_varchar2_list('app_orders'), + a_exclude_object_expr => '(_tmp|_gen)$' ); end; ``` -Executes all tests in schema `unit_test_schema`. Coverage will only be reported on objects `user_1.award_bonus`, `user_2.betwnstr` +There is no include expression, so coverage is gathered on the schema `app_orders` given in `a_coverage_schemes`. +Objects whose name ends with `_tmp` or `_gen` are left out. -The `a_exclude_objects` can be used in the same way as `a_include_objects`. - -Example: Excluding objects from coverage report by providing a list of object owner/name to be excluded. +Example: Use an expression for the bulk of the scope and a list for the exceptions. ```sql linenums="1" begin ut.run( - 'unit_test_schema.test_award_bonus', ut_coverage_html_reporter(), - a_exclude_objects => ut_varchar2_list('ut3_user.betwnstr') + 'app_orders_test', ut_coverage_html_reporter(), + a_include_schema_expr => '^app_orders$', + a_exclude_objects => ut_varchar2_list('app_orders.ord_legacy') ); end; ``` -Executes test `test_award_bonus` in schema `unit_test_schema`. Coverage will be reported on all objects in schema `ut3_user` except the `betwnstr` object. +Coverage will be reported on all objects in schema `app_orders` except for `ord_legacy`. +The list can be used with an include expression. It would be ignored if an exclude expression was given too. + +!!! note + An include object expression used **without** an include schema expression is not limited to the schemas of your tests. + It is applied to the objects of all schemas visible to the user running the tests, for example `a_include_object_expr => '^ord_'` + also reports objects named `ord_...` in other schemas. Add `a_include_schema_expr` to keep the scope where you want it. !!! note Filtering using `a_include_objects` and `a_exclude_objects` is only applicable when gathering coverage for a schema. Those filters are not applied when reporting coverage on project files. + The same is true for the expression parameters. !!! note When running coverage on schema objects, all source code of package bodies, functions, procedures, type bodies and triggers that were not executed will be reported as having 0% code coverage and all source code lines will show as uncovered. This is different from the behavior when gathering coverage on project files. +##### Using the filters from utPLSQL-cli and the Maven plugin + +The filter options described above are available in [utPLSQL-cli](https://www.utplsql.org/utPLSQL-cli.html) +and in the [utPLSQL-maven-plugin](https://www.utplsql.org/utPLSQL-maven-plugin.html), and the same rules apply +(which options are ignored when several are given, how expressions are matched, and that the filters are not applied when coverage is gathered on project files). +See the documentation of those tools for the list of supported options and their names. ### Project based Coverage -utPLSQL provides reporters that produce reports consumable by external tools like `Sonar`/`SonarCloud` & `Coveralls`. +utPLSQL provides reporters that produce reports consumable by external tools like `Sonar`/`SonarCloud`. -Services like Sonar, Coveralls and others perform analysis based on source code in project files. +Services like Sonar and others perform analysis based on source code in project files. They are abstracted from database, schema names, packages, procedures and functions, and operate on a more generic concept of project source code. To be able to effectively use reporters dedicated for those tools, utPLSQL provides functionality for mapping database object names to project files. @@ -320,7 +349,7 @@ To be able to effectively use reporters dedicated for those tools, utPLSQL provi There are a few significant differences when running coverage on project files compared to running coverage on schema(s). - Coverage is only reported on objects that were successfully mapped to project files. -- Project files (database objects) that were not executed at all are not reported as fully uncovered. It is up to the consumer (Sonar/Coveralls) to determine if project file should be considered as 0% coverage or just ignored. +- Project files (database objects) that were not executed at all are not reported as fully uncovered. It is up to the consumer (Sonar) to determine if project file should be considered as 0% coverage or just ignored. In order to successfully use coverage on project files, those files must be mapped to database objects. diff --git a/docs/userguide/exception-reporting.md b/docs/userguide/exception-reporting.md index 1e892215d..f3faf2847 100644 --- a/docs/userguide/exception-reporting.md +++ b/docs/userguide/exception-reporting.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) utPLSQL is responsible for handling exceptions wherever they occur in the test run. The framework is trapping most of the exceptions so that the test execution is not affected by individual tests or test packages throwing an exception. The framework provides a full stacktrace for every exception that was thrown. The reported stacktrace does not include any utPLSQL library calls in it. diff --git a/docs/userguide/expectations.md b/docs/userguide/expectations.md index c51e6c99c..31593e53d 100644 --- a/docs/userguide/expectations.md +++ b/docs/userguide/expectations.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) ## Expectation concepts diff --git a/docs/userguide/getting-started.md b/docs/userguide/getting-started.md index a722f8ac7..4c2aa07f5 100644 --- a/docs/userguide/getting-started.md +++ b/docs/userguide/getting-started.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) # Getting started with TDD and utPLSQL diff --git a/docs/userguide/install.md b/docs/userguide/install.md index 615883720..04b47b97b 100644 --- a/docs/userguide/install.md +++ b/docs/userguide/install.md @@ -1,8 +1,10 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) ## Supported database versions -- Oracle Database 19c or newer (SE/EE/Cloud/Free) +- Oracle Database 19c with Release Update 19.20 or later, or any newer version (SE/EE/Cloud/Free) + +utPLSQL uses SQL macros. Earlier 19c Release Updates are not verified and supported. We do our best to assure full compatibility with **actively supported** versions of Oracle databases. See [this page](https://www.oracle.com/us/support/library/lifetime-support-technology-069183.pdf#page=6) for Oracle Database Releases and their Support Lifetime by Oracle. @@ -163,6 +165,8 @@ If the installing user and utPLSQL owner is one and the same, the user must have - CREATE SYNONYM - ALTER SESSION - CREATE TRIGGER + - CREATE ROLE + - CREATE ANY CONTEXT (needed only for the installation, see [Installing utPLSQL](#installing-utplsql)) In addition, the user must be granted the execute privilege on `DBMS_LOCK` and `DBMS_CRYPTO` packages. @@ -190,6 +194,17 @@ To install the utPLSQL framework into your database, go to `source` directory, r Schema must be created prior to calling the `install` script. You may install utPLSQL from any account that has sufficient privileges to create objects in other users schema. +The installation uses code based access control (CBAC) to give utPLSQL packages access to internal utPLSQL tables without granting those tables to users. +It creates the role `_cbac_modify_objects_role` (for example `ut3_cbac_modify_objects_role`), unless it already exists, and grants it to the utPLSQL schema and to utPLSQL packages. +The installing user therefore needs the `CREATE ROLE` privilege. Each utPLSQL schema gets its own role. The role is dropped when utPLSQL is uninstalled. + +The installation also creates the application context `_info` (for example `ut3_info`), which makes information about the running test available through [`sys_context`](annotations.md#sys_context). +The installing user therefore needs the `CREATE ANY CONTEXT` privilege. +This privilege is needed only while installing, not when running tests. +Because it is a powerful `ANY` privilege, `create_utplsql_owner.sql` deliberately does not grant it to the utPLSQL schema. +If you install utPLSQL as the utPLSQL schema owner, grant `CREATE ANY CONTEXT` to that user before the installation and revoke it afterwards. +The headless installation runs as `SYSDBA` and needs no additional grant. + Example invocation: ```bash cd source diff --git a/docs/userguide/querying_suites.md b/docs/userguide/querying_suites.md index 167fba1b4..1aededc4a 100644 --- a/docs/userguide/querying_suites.md +++ b/docs/userguide/querying_suites.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) ## Obtaining information about suites diff --git a/docs/userguide/reporters.md b/docs/userguide/reporters.md index 807fa537f..8a3a1bd55 100644 --- a/docs/userguide/reporters.md +++ b/docs/userguide/reporters.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) utPLSQL provides several reporting formats. The sections below describe most of them. @@ -180,6 +180,17 @@ Some information in debug log might be redundant. - db object names
- etc. +## Support line + +utPLSQL is free and open source. Support and sponsorship provides funding for the project. To let teams know that commercial support is available and that their organization can help keep the project maintained, some reporters enrich their output with this line: + +``` +Using utPLSQL at work? Get support and help keep it maintained: https://utplsql.org/support +``` + +To switch the line off, call `ut.run` or `ut_runner.run` with `a_support_info => false` (or `a_support_info => 0` with `ut.run` functions). +See [Switching off the support line](running-unit-tests.md#switching-off-the-support-line). + ## Custom reporters It is possible to add your own reporters by creating an appropriate object type. diff --git a/docs/userguide/running-unit-tests.md b/docs/userguide/running-unit-tests.md index 606a5ef97..e19ba66fc 100644 --- a/docs/userguide/running-unit-tests.md +++ b/docs/userguide/running-unit-tests.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) utPLSQL framework provides two main entry points to run unit tests from within the database: @@ -46,6 +46,9 @@ The examples below illustrate different ways and options to invoke `ut.run` proc You can use a wildcard character `*` to call tests by part of their name or to call tests that are located on paths matched by part of path string. Wildcard character can be placed anywhere on the path and can occur mutliple times. Schema name cannot contain a wildcard character whether is in a suitepath call or call by object name. +Only `*` is a wildcard. All other characters, including `_`, `.` and `$`, match only themselves. +A path with a wildcard selects every matching suite or test that you can run and that matches the tags (see [Run by Tags](#run-by-tags)). +Matches that you can't run, or that the tags exclude, are skipped. The run fails with a "does not exist" error only when nothing is left. ```sql linenums="1" alter session set current_schema=hr; @@ -214,6 +217,7 @@ Outputs of multiple reporters can be consumed in parallel. This allows for live - controlling client character set for HTML and XML reports - controlling rollback behavior of test-run - controlling random order of test execution +- switching off the support line Running with multiple reporters. @@ -260,13 +264,23 @@ select from dual; ``` +## Running tests owned by other users + +To run tests in another schema, you need the EXECUTE privilege on its test packages, or the EXECUTE ANY PROCEDURE privilege. +Packages that you can't execute are skipped. + +If such a package is a parent suite (by `--%suitepath`) of a package that you can execute, the child package still runs. +A logical suite with the same name takes the parent's place, so the parent's `--%beforeall`/`--%afterall`, `--%rollback` and `--%tags` don't apply to the child. +The run reports a warning that names the skipped parent suite. + +A path that selects only packages you can't execute fails with a "does not exist" error. ## Order of test execution ### Default order When unit tests are executed without random order, they are ordered by: -- schema name +- schema name: when a run includes several schemas, the suites of each schema run together, in order of schema names - suite path or test package name if `--%suitepath` was not specified for that package - `--%test` line number in package @@ -325,12 +339,15 @@ Multiple tags are separated by comma. ### Tag Expressions Tag expressions are boolean expressions created by combining tags with the `!`, `&`, `|` operators. Tag expressions can be grouped using `(` and `)` braces. Grouping tag expressions affects operator precedence. +An invalid tag expression raises an error (ORA-20219) before any test runs. +Spaces and tabs in a tag expression are ignored. A tag expression made only of spaces and tabs doesn't filter the tests, the same as no tag expression. Two reserved keywords, `any` and `none`, can be used when creating a tag expression to run tests. - `any` keyword represents tests and suites with any tags - `none` keyword represents tests and suites without tags These keywords may be combined with other expressions just like normal tags. +The keywords are lowercase only. Like tags, they are case sensitive, so `NONE` or `Any` in a tag expression is an ordinary tag name, not a keyword. !!! note When specifying `none`, be aware that it will exclude any tests/suites/contexts contained within a tagged suite. @@ -554,6 +571,22 @@ end; **Note:** >This option is not available when running tests using `ut.run` as a table function. +## Switching off the support line + +Some of the reporters include a short line about [utPLSQL support and sponsorship](reporters.md#support-line). +To leave it out, set `a_support_info` to `false` when calling `ut.run` procedures or `ut_runner.run`, or to `0` when calling `ut.run` functions. + +```sql linenums="1" +set serveroutput on +begin + ut.run('hr.test_apply_bonus', a_support_info => false); +end; +``` + +```sql linenums="1" +select * from table(ut.run('hr.test_apply_bonus', a_support_info => 0)); +``` + ## Reports character-set encoding To get properly encoded reports, when running utPLSQL with HTML/XML reports on data containing national characters you need to provide your client character set when calling `ut.run` functions and procedures. diff --git a/docs/userguide/upgrade.md b/docs/userguide/upgrade.md index a49118fbd..28421a1e9 100644 --- a/docs/userguide/upgrade.md +++ b/docs/userguide/upgrade.md @@ -1,4 +1,4 @@ -![version](https://img.shields.io/badge/version-v3.2.01.4414--develop-blue.svg) +![version](https://img.shields.io/badge/version-v3.2.4--develop-blue.svg) # Upgrading from version 2 diff --git a/examples/custom_reporters/ut_expectations_reporter.tpb b/examples/custom_reporters/ut_expectations_reporter.tpb index af9cceb28..6ea5f1cda 100644 --- a/examples/custom_reporters/ut_expectations_reporter.tpb +++ b/examples/custom_reporters/ut_expectations_reporter.tpb @@ -1,10 +1,10 @@ create or replace type body ut_expectations_reporter is /* utPLSQL - Version 3 - Copyright 2016 - 2020 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/examples/custom_reporters/ut_expectations_reporter.tps b/examples/custom_reporters/ut_expectations_reporter.tps index a4238c302..9095051cd 100644 --- a/examples/custom_reporters/ut_expectations_reporter.tps +++ b/examples/custom_reporters/ut_expectations_reporter.tps @@ -1,10 +1,10 @@ create or replace type ut_expectations_reporter under ut_documentation_reporter( /* utPLSQL - Version 3 - Copyright 2016 - 2020 utPLSQL Project + Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/mkdocs.yml b/mkdocs.yml index 49356fd4e..08e75ac97 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -5,15 +5,20 @@ # https://squidfunk.github.io/mkdocs-material/setup/building-for-offline-usage/ edit_uri: "" -site_url: http://utPLSQL.org/ -site_name: utPLSQL-framework -site_description: utPLSQL Ultimate Testing Framework for Oracle PL/SQL & SQL -copyright: Copyright © 2016 - 2026 utPLSQL Team +site_url: https://www.utplsql.org/ +site_name: utPLSQL +site_description: utPLSQL Ultimate Testing Framework for Oracle PL/SQL +copyright: > + Copyright © 2016 - 2026 utPLSQL Project. + Stewarded by utPLSQL Development Labs Ltd. + ♡ SponsorutPLSQL + Change cookie settings repo_url: https://github.com/utPLSQL/utPLSQL extra_css: - stylesheets/extra.css theme: name: material + custom_dir: docs/overrides palette: # Palette toggle for light mode - media: "(prefers-color-scheme: light)" @@ -34,22 +39,36 @@ theme: # - navigation.indexes - navigation.tabs - navigation.tracking + - navigation.top - toc.follow - toc.integrate - search.suggest - search.highlight + - content.code.copy + - content.code.annotate + - content.code.select + extra: -# homepage: http://jgebal.github.io/ -# homepage: http://utPLSQL.org/ - social: - - icon: fontawesome/brands/twitter - link: https://twitter.com/utPLSQL - - icon: fontawesome/regular/comment - link: https://github.com/utPLSQL/utPLSQL/discussions - - icon: fontawesome/brands/github - link: https://github.com/utPLSQL - - icon: fontawesome/solid/envelope - link: mailto:utPLSQL@utPLSQL.org +# homepage: https://www.utPLSQL.org/ + # sets scope of cookies to use a common path (root) + scope: "/" + analytics: + provider: google + property: G-WMFVR98J0Q + feedback: + title: Was this page helpful? + ratings: + - icon: material/emoticon-happy-outline + name: This page was helpful + data: 1 + note: >- + Thanks for your feedback! + - icon: material/emoticon-sad-outline + name: This page could be improved + data: 0 + note: >- + Thanks for your feedback! Help us improve this page by + using our GitHub Discussions. consent: title: Cookie consent description: >- @@ -57,16 +76,36 @@ extra: as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better. + # the cookie: utplsql-consent allows for shred cookie across all documentation versions and the global site + cookie: utplsql-consent + social: + - icon: fontawesome/brands/x-twitter + link: https://x.com/utPLSQL + name: utPLSQL on X + - icon: fontawesome/brands/linkedin + link: https://www.linkedin.com/company/utplsql/ + name: utPLSQL on LinkedIn + - icon: fontawesome/brands/bluesky + link: https://bsky.app/profile/utplsql.org + name: utPLSQL on Bluesky + - icon: fontawesome/regular/comment + link: https://github.com/utPLSQL/utPLSQL/discussions + - icon: fontawesome/brands/github + link: https://github.com/utPLSQL + - icon: fontawesome/solid/envelope + link: mailto:info@utPLSQL.org version: # disable for offline docs provider: mike # disable for offline docs markdown_extensions: - admonition - pymdownx.details - - pymdownx.superfences - pymdownx.highlight: anchor_linenums: true + line_spans: __span + pygments_lang_class: true - pymdownx.inlinehilite - pymdownx.snippets + - pymdownx.superfences - pymdownx.caret - pymdownx.mark - pymdownx.tilde @@ -77,6 +116,13 @@ strict: true plugins: - search + - git-committers: + repository: utPLSQL/utPLSQL + branch: develop + token: !ENV ["API_TOKEN_GITHUB"] + exclude_committers: + - github-actions[bot] + - web-flow - mike - git-revision-date-localized: # disable for offline docs enable_creation_date: true # disable for offline docs @@ -98,8 +144,3 @@ nav: - Using reporters: userguide/reporters.md - Code coverage: userguide/coverage.md - Error handling and reporting: userguide/exception-reporting.md - - About: - - Project Details: about/project-details.md - - License: about/license.md - - Support: about/support.md - - Authors: about/authors.md diff --git a/mkdocs_offline.yml b/mkdocs_offline.yml index 9f0ef57af..8c0ab8fa5 100644 --- a/mkdocs_offline.yml +++ b/mkdocs_offline.yml @@ -5,10 +5,10 @@ # https://squidfunk.github.io/mkdocs-material/setup/building-for-offline-usage/ edit_uri: "" -site_url: http://utPLSQL.org/ +site_url: https://www.utplsql.org/ site_name: utPLSQL-framework site_description: utPLSQL Ultimate Testing Framework for Oracle PL/SQL & SQL -copyright: Copyright © 2016 - 2022 utPLSQL Team +copyright: Copyright © 2016 - 2026 utPLSQL Project. utPLSQL is stewarded by utPLSQL Development Labs Ltd. #repo_url: https://github.com/utPLSQL/utPLSQL # disable for offline docs extra_css: - stylesheets/extra.css @@ -39,17 +39,23 @@ theme: - search.suggest - search.highlight extra: -# homepage: http://jgebal.github.io/ -# homepage: http://utPLSQL.org/ +# homepage: https://www.utPLSQL.org/ social: - - icon: fontawesome/brands/twitter - link: https://twitter.com/utPLSQL + - icon: fontawesome/brands/x-twitter + link: https://x.com/utPLSQL + name: utPLSQL on X + - icon: fontawesome/brands/linkedin + link: https://www.linkedin.com/company/utplsql/ + name: utPLSQL on LinkedIn + - icon: fontawesome/brands/bluesky + link: https://bsky.app/profile/utplsql.org + name: utPLSQL on Bluesky - icon: fontawesome/regular/comment link: https://github.com/utPLSQL/utPLSQL/discussions - icon: fontawesome/brands/github link: https://github.com/utPLSQL - icon: fontawesome/solid/envelope - link: mailto:utPLSQL@utPLSQL.org + link: mailto:info@utPLSQL.org consent: title: Cookie consent description: >- @@ -98,8 +104,3 @@ nav: - Using reporters: userguide/reporters.md - Code coverage: userguide/coverage.md - Error handling and reporting: userguide/exception-reporting.md - - About: - - Project Details: about/project-details.md - - License: about/license.md - - Support: about/support.md - - Authors: about/authors.md diff --git a/readme.md b/readme.md index 7af2183c5..f0843b511 100644 --- a/readme.md +++ b/readme.md @@ -3,12 +3,15 @@ [![latest-release](https://img.shields.io/github/release/utPLSQL/utPLSQL.svg)](https://github.com/utPLSQL/utPLSQL/releases) [![license](https://img.shields.io/github/license/utPLSQL/utPLSQL.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![GitHub Discussions](https://img.shields.io/github/discussions/utPLSQL/utPLSQL)](https://github.com/utPLSQL/utPLSQL/discussions) -[![X](https://img.shields.io/twitter/follow/utPLSQL.svg?style=social&label=Follow)](https://twitter.com/utPLSQL) +[![X](https://img.shields.io/badge/X-utPLSQL-000000?logo=x)](https://x.com/utPLSQL) +[![Bluesky](https://img.shields.io/badge/Bluesky-utplsql.org-0285FF?logo=bluesky&logoColor=white)](https://bsky.app/profile/utplsql.org) +[![LinkedIn](https://img.shields.io/badge/in-utPLSQL-0A66C2)](https://www.linkedin.com/company/utplsql/) +[![Sponsor](https://img.shields.io/badge/Sponsor-utPLSQL-ea4aaa?logo=githubsponsors)](https://www.utplsql.org/sponsorship.html) [![build](https://github.com/utPLSQL/utPLSQL/actions/workflows/build.yml/badge.svg)](https://github.com/utPLSQL/utPLSQL/actions/workflows/build.yml) [![QualityGate](https://sonarcloud.io/api/project_badges/measure?project=utPLSQL_utPLSQL&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=utPLSQL_utPLSQL) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=utPLSQL_utPLSQL&metric=coverage)](https://sonarcloud.io/summary/new_code?id=utPLSQL_utPLSQL) -utPLSQL is a unit testing framework for Oracle PL/SQL and SQL, following industry standards and best practices of modern testing frameworks like [JUnit](http://junit.org/junit4/) and [RSpec](http://rspec.info/). +utPLSQL is a unit testing framework for Oracle PL/SQL and SQL, following industry standards and best practices of modern testing frameworks like [JUnit](https://junit.org/) and [RSpec](https://rspec.info/). ## Key Features @@ -19,14 +22,14 @@ utPLSQL is a unit testing framework for Oracle PL/SQL and SQL, following industr - Hierarchies of test suites configured with annotations - Automatic (configurable) transaction control - Built-in [coverage](docs/userguide/coverage.md) reporting -- Integration with SonarQube, Coveralls, Jenkins and TeamCity via [reporters](docs/userguide/reporters.md) +- Integration with SonarQube, Jenkins and TeamCity via [reporters](docs/userguide/reporters.md) - Plugin architecture for reporters and matchers - Flexible and simple test invocation - Multi-format reporting from the [command line client](https://github.com/utPLSQL/utPLSQL-cli) ## Requirements -- Oracle Database 19c or newer +- Oracle Database 19c with Release Update 19.20 or later, or any newer version (we are testing on 19.20, 21 XE and 23 free ) ## Installation @@ -132,23 +135,26 @@ Migrating from legacy utPLSQL v2? See the [version 2 to version 3 comparison](do ## Contributing -We welcome contributions of all kinds. Please read the [contributing guide](CONTRIBUTING.md) and the [code of conduct](CODE_OF_CONDUCT.md) before getting started. +We welcome contributions of all kinds. Please read the [contributing guide](CONTRIBUTING.md) and the [code of conduct](https://github.com/utPLSQL/utPLSQL?tab=coc-ov-file) before getting started. [GitHub Discussions](https://github.com/utPLSQL/utPLSQL/discussions) is the place to ask questions and connect with the team. -## Supporters +The list of **authors** and **significant contributors** is available on the [About](https://www.utplsql.org/about.html) page. For a full list of contributors, see [contributors](https://github.com/utPLSQL/utPLSQL/graphs/contributors?all=1) on GitHub. -utPLSQL is community-driven and not commercially motivated. Donations and contributions are always welcome. +## Sponsorship - - - - - - - -
supported_by_redgateutPLSQL has been supported by Redgate in the form of sponsored stickers and t-shirts. Thank you for helping us spread the word!
+utPLSQL is free and open source (Apache 2.0). Sponsorship funds development of new features and tools, maintaining compatibility with new Oracle versions and platforms, documentation. +See [Sponsorship](https://www.utplsql.org/sponsorship.html) for organization tiers, commercial support and individual sponsorship. All current and past sponsors are listed in [SPONSORS.md](SPONSORS.md). ---- + + -[Authors](docs/about/authors.md) +## License + +utPLSQL is free and open source, licensed under the [Apache 2.0 license](LICENSE). + +## Stewardship + +utPLSQL is stewarded by utPLSQL Development Labs Ltd, which holds the utPLSQL name, branding and project assets, and manages sponsorships and funded development. +Contributors retain copyright of their contributions, which are licensed under the Apache 2.0 license. +See the [announcement](https://www.utplsql.org/announcements/incorporation-of-utplsql-development-labs-ltd.html) for details. diff --git a/sonar-project.properties b/sonar-project.properties index efcaeb5e6..0a835a2f3 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,7 @@ sonar.organization=utplsql sonar.projectKey=utPLSQL_utPLSQL # this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. sonar.projectName=utPLSQL -sonar.projectVersion=v3.2.01-develop +sonar.projectVersion=v3.2.4-develop # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. # Since SonarQube 4.2, this property is optional if sonar.modules is set. diff --git a/source/api/be_between.syn b/source/api/be_between.syn index c0972595d..233dd65bf 100644 --- a/source/api/be_between.syn +++ b/source/api/be_between.syn @@ -1 +1 @@ -create synonym be_between for ut_be_between; +create noneditionable synonym be_between for ut_be_between; diff --git a/source/api/be_empty.syn b/source/api/be_empty.syn index a8e28de6e..f63366fa3 100644 --- a/source/api/be_empty.syn +++ b/source/api/be_empty.syn @@ -1 +1 @@ -create synonym be_empty for ut_be_empty; +create noneditionable synonym be_empty for ut_be_empty; diff --git a/source/api/be_false.syn b/source/api/be_false.syn index c2665bbcb..cdf497235 100644 --- a/source/api/be_false.syn +++ b/source/api/be_false.syn @@ -1 +1 @@ -create synonym be_false for ut_be_false; +create noneditionable synonym be_false for ut_be_false; diff --git a/source/api/be_greater_or_equal.syn b/source/api/be_greater_or_equal.syn index 386fe7f32..67616dc1d 100644 --- a/source/api/be_greater_or_equal.syn +++ b/source/api/be_greater_or_equal.syn @@ -1 +1 @@ -create synonym be_greater_or_equal for ut_be_greater_or_equal; +create noneditionable synonym be_greater_or_equal for ut_be_greater_or_equal; diff --git a/source/api/be_greater_than.syn b/source/api/be_greater_than.syn index 6f97b7d22..c180f3d43 100644 --- a/source/api/be_greater_than.syn +++ b/source/api/be_greater_than.syn @@ -1 +1 @@ -create synonym be_greater_than for ut_be_greater_than; +create noneditionable synonym be_greater_than for ut_be_greater_than; diff --git a/source/api/be_less_or_equal.syn b/source/api/be_less_or_equal.syn index b2f836144..0069f52ba 100644 --- a/source/api/be_less_or_equal.syn +++ b/source/api/be_less_or_equal.syn @@ -1 +1 @@ -create synonym be_less_or_equal for ut_be_less_or_equal; +create noneditionable synonym be_less_or_equal for ut_be_less_or_equal; diff --git a/source/api/be_less_than.syn b/source/api/be_less_than.syn index fbef3b4c3..5d2766d05 100644 --- a/source/api/be_less_than.syn +++ b/source/api/be_less_than.syn @@ -1 +1 @@ -create synonym be_less_than for ut_be_less_than; +create noneditionable synonym be_less_than for ut_be_less_than; diff --git a/source/api/be_like.syn b/source/api/be_like.syn index a8be1de71..6f62f21a0 100644 --- a/source/api/be_like.syn +++ b/source/api/be_like.syn @@ -1 +1 @@ -create synonym be_like for ut_be_like; +create noneditionable synonym be_like for ut_be_like; diff --git a/source/api/be_not_null.syn b/source/api/be_not_null.syn index d6458683a..a9e02b94d 100644 --- a/source/api/be_not_null.syn +++ b/source/api/be_not_null.syn @@ -1 +1 @@ -create synonym be_not_null for ut_be_not_null; +create noneditionable synonym be_not_null for ut_be_not_null; diff --git a/source/api/be_null.syn b/source/api/be_null.syn index 42f6516c3..4fe3fb9dd 100644 --- a/source/api/be_null.syn +++ b/source/api/be_null.syn @@ -1 +1 @@ -create synonym be_null for ut_be_null; +create noneditionable synonym be_null for ut_be_null; diff --git a/source/api/be_true.syn b/source/api/be_true.syn index bf7392a62..1aa348c7e 100644 --- a/source/api/be_true.syn +++ b/source/api/be_true.syn @@ -1 +1 @@ -create synonym be_true for ut_be_true; +create noneditionable synonym be_true for ut_be_true; diff --git a/source/api/be_within.syn b/source/api/be_within.syn index e00005bb7..4f4f77606 100644 --- a/source/api/be_within.syn +++ b/source/api/be_within.syn @@ -1 +1 @@ -create synonym be_within for ut_be_within; +create noneditionable synonym be_within for ut_be_within; diff --git a/source/api/be_within_pct.syn b/source/api/be_within_pct.syn index 40e3fb8b9..b9fc1cd53 100644 --- a/source/api/be_within_pct.syn +++ b/source/api/be_within_pct.syn @@ -1 +1 @@ -create synonym be_within_pct for ut_be_within_pct; +create noneditionable synonym be_within_pct for ut_be_within_pct; diff --git a/source/api/contain.syn b/source/api/contain.syn index 5bce7d1d2..5b4158635 100644 --- a/source/api/contain.syn +++ b/source/api/contain.syn @@ -1 +1 @@ -create synonym contain for ut_contain; +create noneditionable synonym contain for ut_contain; diff --git a/source/api/equal.syn b/source/api/equal.syn index 71ba58b53..0d81fcf6f 100644 --- a/source/api/equal.syn +++ b/source/api/equal.syn @@ -1 +1 @@ -create synonym equal for ut_equal; +create noneditionable synonym equal for ut_equal; diff --git a/source/api/have_count.syn b/source/api/have_count.syn index a406d47ec..9cbf8ebf2 100644 --- a/source/api/have_count.syn +++ b/source/api/have_count.syn @@ -1 +1 @@ -create synonym have_count for ut_have_count; +create noneditionable synonym have_count for ut_have_count; diff --git a/source/api/match.syn b/source/api/match.syn index ffbda35b1..13e8cc97d 100644 --- a/source/api/match.syn +++ b/source/api/match.syn @@ -1 +1 @@ -create synonym match for ut_match; +create noneditionable synonym match for ut_match; diff --git a/source/api/ut.pkb b/source/api/ut.pkb index d61de040a..4515900d7 100644 --- a/source/api/ut.pkb +++ b/source/api/ut.pkb @@ -1,11 +1,11 @@ -create or replace package body ut is +create or replace noneditionable package body ut is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -135,7 +135,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) is pragma autonomous_transaction; begin @@ -158,7 +159,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + ut_utils.int_to_boolean(a_support_info) ); rollback; end; @@ -179,7 +181,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) is pragma autonomous_transaction; begin @@ -203,7 +206,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + ut_utils.int_to_boolean(a_support_info) ); rollback; end; @@ -253,7 +257,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -274,7 +279,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -301,7 +307,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -322,7 +329,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -350,7 +358,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -371,7 +380,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -399,7 +409,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -420,7 +431,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -448,7 +460,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -469,7 +482,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -497,7 +511,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined is l_reporter ut_reporter_base := a_reporter; l_results sys_refcursor; @@ -518,7 +533,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); if l_reporter is of (ut_output_reporter_base) then l_results := treat(l_reporter as ut_output_reporter_base).get_lines_cursor(); @@ -547,7 +563,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is l_reporter ut_reporter_base := a_reporter; begin @@ -571,7 +588,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); else run_autonomous( @@ -590,7 +608,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + ut_utils.boolean_to_int(a_support_info) ); end if; if l_reporter is of (ut_output_reporter_base) then @@ -616,7 +635,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is l_reporter ut_reporter_base := a_reporter; begin @@ -637,7 +657,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); end; @@ -657,7 +678,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is begin ut.run( @@ -677,7 +699,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); end; @@ -697,7 +720,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is begin ut.run( @@ -717,7 +741,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); end; @@ -738,7 +763,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is begin ut.run( @@ -758,7 +784,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); end; @@ -779,7 +806,8 @@ create or replace package body ut is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is begin ut.run( @@ -799,7 +827,8 @@ create or replace package body ut is a_include_schema_expr, a_include_object_expr, a_exclude_schema_expr, - a_exclude_object_expr + a_exclude_object_expr, + a_support_info ); end; diff --git a/source/api/ut.pks b/source/api/ut.pks index 6fd98dd9f..0324a164c 100644 --- a/source/api/ut.pks +++ b/source/api/ut.pks @@ -1,11 +1,11 @@ -create or replace package ut authid current_user as +create or replace noneditionable package ut authid current_user as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -66,7 +66,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; function run( @@ -84,7 +85,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; function run( @@ -103,7 +105,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; function run( @@ -122,7 +125,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; function run( @@ -141,7 +145,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; function run( @@ -160,7 +165,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info integer := 1 ) return ut_varchar2_rows pipelined; procedure run( @@ -179,7 +185,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); procedure run( @@ -198,7 +205,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); procedure run( @@ -218,7 +226,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); procedure run( @@ -238,7 +247,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); procedure run( @@ -258,7 +268,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); procedure run( @@ -278,7 +289,8 @@ create or replace package ut authid current_user as a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); /** diff --git a/source/api/ut_runner.pkb b/source/api/ut_runner.pkb index 755683cc9..9c64ffdba 100644 --- a/source/api/ut_runner.pkb +++ b/source/api/ut_runner.pkb @@ -1,11 +1,11 @@ -create or replace package body ut_runner is +create or replace noneditionable package body ut_runner is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -73,7 +73,8 @@ create or replace package body ut_runner is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ) is l_run ut_run; l_coverage_schema_names ut_varchar2_rows; @@ -133,7 +134,8 @@ create or replace package body ut_runner is a_test_file_mappings => set(a_test_file_mappings), a_client_character_set => a_client_character_set, a_random_test_order_seed => l_random_test_order_seed, - a_run_tags => a_tags + a_run_tags => a_tags, + a_support_info => a_support_info ); ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, a_tags); diff --git a/source/api/ut_runner.pks b/source/api/ut_runner.pks index 2c6bba888..7ef938f45 100644 --- a/source/api/ut_runner.pks +++ b/source/api/ut_runner.pks @@ -1,11 +1,11 @@ -create or replace package ut_runner authid current_user is +create or replace noneditionable package ut_runner authid current_user is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -45,6 +45,7 @@ create or replace package ut_runner authid current_user is * @param a_fail_on_errors true/false - should an exception be thrown when tests are completed with failures/errors * @param a_client_character_set if provided, affects some of reporters by setting specific character set for XML/HTML reports * @param a_force_manual_rollback true/false - should the transaction control be forced to --%rollback(manual) and no rollback issued at the end of the run + * @param a_support_info true/false - should the reporters print the utPLSQL support line * * @example * Parameter `a_paths` accepts values of the following formats: @@ -75,7 +76,8 @@ create or replace package ut_runner authid current_user is a_include_schema_expr varchar2 := null, a_include_object_expr varchar2 := null, a_exclude_schema_expr varchar2 := null, - a_exclude_object_expr varchar2 := null + a_exclude_object_expr varchar2 := null, + a_support_info boolean := true ); /** diff --git a/source/api/ut_suite_item_info.tpb b/source/api/ut_suite_item_info.tpb index 727707ae9..7005ded37 100644 --- a/source/api/ut_suite_item_info.tpb +++ b/source/api/ut_suite_item_info.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_suite_item_info is +create or replace noneditionable type body ut_suite_item_info is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/api/ut_suite_item_info.tps b/source/api/ut_suite_item_info.tps index f632b2f52..c6fdbeb72 100644 --- a/source/api/ut_suite_item_info.tps +++ b/source/api/ut_suite_item_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_item_info as object ( +create or replace noneditionable type ut_suite_item_info as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/api/ut_suite_items_info.tps b/source/api/ut_suite_items_info.tps index e47b350e5..ac0d52a93 100644 --- a/source/api/ut_suite_items_info.tps +++ b/source/api/ut_suite_items_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_items_info as +create or replace noneditionable type ut_suite_items_info as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/check_object_grants.sql b/source/check_object_grants.sql index 0e7a9b4c9..87e821003 100644 --- a/source/check_object_grants.sql +++ b/source/check_object_grants.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -16,11 +16,7 @@ */ declare - $if dbms_db_version.version >= 18 $then - c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray('DBMS_CRYPTO'); - $else - c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray('DBMS_LOCK','DBMS_CRYPTO'); - $end + c_expected_grants constant dbmsoutput_linesarray := dbmsoutput_linesarray('DBMS_CRYPTO'); l_missing_grants varchar2(4000); l_target_table varchar2(128); l_owner_column varchar2(128); diff --git a/source/check_sys_grants.sql b/source/check_sys_grants.sql index f81157183..9e1a64e0b 100644 --- a/source/check_sys_grants.sql +++ b/source/check_sys_grants.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotated_object.tps b/source/core/annotations/ut_annotated_object.tps index 21f6ab330..a8b767212 100644 --- a/source/core/annotations/ut_annotated_object.tps +++ b/source/core/annotations/ut_annotated_object.tps @@ -1,10 +1,10 @@ -create type ut_annotated_object as object( +create or replace noneditionable type ut_annotated_object as object( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotated_objects.tps b/source/core/annotations/ut_annotated_objects.tps index 63679b699..fe8fc62f7 100644 --- a/source/core/annotations/ut_annotated_objects.tps +++ b/source/core/annotations/ut_annotated_objects.tps @@ -1,10 +1,10 @@ -create type ut_annotated_objects as +create or replace noneditionable type ut_annotated_objects as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotation.tps b/source/core/annotations/ut_annotation.tps index 18747516a..5b8208b8a 100644 --- a/source/core/annotations/ut_annotation.tps +++ b/source/core/annotations/ut_annotation.tps @@ -1,10 +1,10 @@ -create type ut_annotation as object( +create or replace noneditionable type ut_annotation as object( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotation_cache.sql b/source/core/annotations/ut_annotation_cache.sql index 7d69b1db6..2ebcb245f 100644 --- a/source/core/annotations/ut_annotation_cache.sql +++ b/source/core/annotations/ut_annotation_cache.sql @@ -2,8 +2,8 @@ create table ut_annotation_cache ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/annotations/ut_annotation_cache_info.sql b/source/core/annotations/ut_annotation_cache_info.sql index 6248f4fbc..4600af793 100644 --- a/source/core/annotations/ut_annotation_cache_info.sql +++ b/source/core/annotations/ut_annotation_cache_info.sql @@ -2,8 +2,8 @@ create table ut_annotation_cache_info ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -17,8 +17,8 @@ create table ut_annotation_cache_info ( object_name varchar2(250) not null, object_type varchar2(250) not null, parse_time timestamp not null, - constraint ut_annotation_cache_info_pk primary key(cache_id) using index, - constraint ut_annotation_cache_info_uk unique (object_owner, object_type, object_name) using index, + constraint ut_annotation_cache_info_pk primary key(object_owner, object_type, object_name) using index, + constraint ut_annotation_cache_info_uk unique (cache_id) using index, constraint ut_annotation_cache_info_fk foreign key(object_owner, object_type) references ut_annotation_cache_schema(object_owner, object_type) on delete cascade ) organization index; diff --git a/source/core/annotations/ut_annotation_cache_macros.pkb b/source/core/annotations/ut_annotation_cache_macros.pkb new file mode 100644 index 000000000..b03b7529f --- /dev/null +++ b/source/core/annotations/ut_annotation_cache_macros.pkb @@ -0,0 +1,29 @@ +create or replace noneditionable package body ut_annotation_cache_macros as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + function get_cached_objects(a_object_owner varchar2, a_object_type varchar2) return varchar2 sql_macro is + begin + return q'[ + select /*+ NO_UNNEST NO_EXPAND */ i.object_owner, i.object_name, i.object_type, i.parse_time + from &&ut3_owner..ut_annotation_cache_info i + where i.object_owner = a_object_owner + and i.object_type = a_object_type]'; + end; + +end; +/ diff --git a/source/core/annotations/ut_annotation_cache_macros.pks b/source/core/annotations/ut_annotation_cache_macros.pks new file mode 100644 index 000000000..fa3f43765 --- /dev/null +++ b/source/core/annotations/ut_annotation_cache_macros.pks @@ -0,0 +1,39 @@ +create or replace noneditionable package ut_annotation_cache_macros authid definer as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + /* + * SQL macros over the annotation cache tables. + * + * A package containing SQL macros cannot be an invoker rights package, so the macros are kept apart from ut_annotation_cache_manager. + * A macro only returns SQL text. The text is expanded into the calling SQL statement and runs with the privileges of the caller, + * so the macros can only be used by framework code that has the _cbac_modify_objects_role. + * Callers reference the macros qualified with the framework owner, as unqualified names in invoker rights SQL resolve in the invoker's schema. + * The owner is filled in by the SQL*Plus substitution variable ut3_owner when the package body is installed by install.sql. + */ + + /** + * Table SQL macro returning objects stored in annotation cache + * Columns: object_owner, object_name, object_type, parse_time + * + * @param a_object_owner owner of cached objects + * @param a_object_type type of cached objects + */ + function get_cached_objects(a_object_owner varchar2, a_object_type varchar2) return varchar2 sql_macro; + +end; +/ diff --git a/source/core/annotations/ut_annotation_cache_manager.pkb b/source/core/annotations/ut_annotation_cache_manager.pkb index 52184e17d..10be118f5 100644 --- a/source/core/annotations/ut_annotation_cache_manager.pkb +++ b/source/core/annotations/ut_annotation_cache_manager.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_annotation_cache_manager as +create or replace noneditionable package body ut_annotation_cache_manager as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,12 +21,12 @@ create or replace package body ut_annotation_cache_manager as l_timestamp timestamp := systimestamp; pragma autonomous_transaction; begin - update /*+ no_parallel */ ut_annotation_cache_schema s + update /*+ no_parallel */ &&ut3_owner..ut_annotation_cache_schema s set s.max_parse_time = l_timestamp where s.object_type = a_object.object_type and s.object_owner = a_object.object_owner; if sql%rowcount = 0 then - insert /*+ no_parallel */ into ut_annotation_cache_schema s + insert /*+ no_parallel */ into &&ut3_owner..ut_annotation_cache_schema s (object_owner, object_type, max_parse_time) values (a_object.object_owner, a_object.object_type, l_timestamp); end if; @@ -34,7 +34,7 @@ create or replace package body ut_annotation_cache_manager as -- if not in trigger, or object has annotations if a_object.annotations is not null and a_object.annotations.count > 0 then - update /*+ no_parallel */ ut_annotation_cache_info i + update /*+ no_parallel */ &&ut3_owner..ut_annotation_cache_info i set i.parse_time = l_timestamp where (i.object_owner, i.object_name, i.object_type) in ((a_object.object_owner, a_object.object_name, a_object.object_type)) @@ -42,15 +42,15 @@ create or replace package body ut_annotation_cache_manager as if sql%rowcount = 0 then - insert /*+ no_parallel */ into ut_annotation_cache_info + insert /*+ no_parallel */ into &&ut3_owner..ut_annotation_cache_info (cache_id, object_owner, object_name, object_type, parse_time) - values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, l_timestamp) + values (&&ut3_owner..ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, l_timestamp) returning cache_id into l_cache_id; end if; - - delete /*+ no_parallel */ from ut_annotation_cache c where cache_id = l_cache_id; - insert /*+ no_parallel */ into ut_annotation_cache + delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache c where cache_id = l_cache_id; + + insert /*+ no_parallel */ into &&ut3_owner..ut_annotation_cache (cache_id, annotation_position, annotation_name, annotation_text, subobject_name) select /*+ no_parallel */ l_cache_id, a.position, a.name, a.text, a.subobject_name from table(a_object.annotations) a; @@ -70,10 +70,10 @@ create or replace package body ut_annotation_cache_manager as pragma autonomous_transaction; begin - delete /*+ no_parallel */ from ut_annotation_cache c + delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache c where c.cache_id in (select /*+ no_parallel */ i.cache_id - from ut_annotation_cache_info i + from &&ut3_owner..ut_annotation_cache_info i join table (a_objects) o on o.object_name = i.object_name and o.object_type = i.object_type @@ -81,7 +81,7 @@ create or replace package body ut_annotation_cache_manager as and o.needs_refresh = 'Y' ); - update /*+ no_parallel */ ut_annotation_cache_schema s + update /*+ no_parallel */ &&ut3_owner..ut_annotation_cache_schema s set s.max_parse_time = l_timestamp where (s.object_owner, s.object_type) in ( @@ -91,7 +91,7 @@ create or replace package body ut_annotation_cache_manager as ); if sql%rowcount = 0 then - insert /*+ no_parallel */ into ut_annotation_cache_schema s + insert /*+ no_parallel */ into &&ut3_owner..ut_annotation_cache_schema s (object_owner, object_type, max_parse_time) select /*+ no_parallel */ distinct o.object_owner, o.object_type, l_timestamp from table(a_objects) o @@ -99,7 +99,7 @@ create or replace package body ut_annotation_cache_manager as end if; merge /*+ no_parallel */ - into ut_annotation_cache_info i + into &&ut3_owner..ut_annotation_cache_info i using (select /*+ no_parallel */ o.object_name, o.object_type, o.object_owner from table(a_objects) o where o.needs_refresh = 'Y' @@ -112,36 +112,18 @@ create or replace package body ut_annotation_cache_manager as set parse_time = l_timestamp when not matched then insert (cache_id, object_owner, object_name, object_type, parse_time) - values (ut_annotation_cache_seq.nextval, o.object_owner, o.object_name, o.object_type, l_timestamp); + values (&&ut3_owner..ut_annotation_cache_seq.nextval, o.object_owner, o.object_name, o.object_type, l_timestamp); commit; end; - function get_cached_objects_list(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp := null) return ut_annotation_objs_cache_info is - l_result ut_annotation_objs_cache_info; - begin - select /*+ no_parallel */ ut_annotation_obj_cache_info( - object_owner => i.object_owner, - object_name => i.object_name, - object_type => i.object_type, - needs_refresh => 'N', - parse_time => i.parse_time - ) - bulk collect into l_result - from ut_annotation_cache_info i - where i.object_owner = a_object_owner - and i.object_type = a_object_type - and (i.parse_time > a_parsed_after or a_parsed_after is null); - return l_result; - end; - function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info is l_result t_cache_schema_info; begin begin select /*+ no_parallel */ * into l_result - from ut_annotation_cache_schema s + from &&ut3_owner..ut_annotation_cache_schema s where s.object_type = a_object_type and s.object_owner = a_object_owner; exception when no_data_found then @@ -153,7 +135,7 @@ create or replace package body ut_annotation_cache_manager as procedure set_fully_refreshed(a_object_owner varchar2, a_object_type varchar2) is pragma autonomous_transaction; begin - update /*+ no_parallel */ ut_annotation_cache_schema s + update /*+ no_parallel */ &&ut3_owner..ut_annotation_cache_schema s set s.full_refresh_time = s.max_parse_time where s.object_owner = a_object_owner and s.object_type = a_object_type; @@ -164,7 +146,7 @@ create or replace package body ut_annotation_cache_manager as pragma autonomous_transaction; begin - delete /*+ no_parallel */ from ut_annotation_cache_info i + delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache_info i where exists ( select /*+ no_parallel */ 1 from table (a_objects) o where o.object_name = i.object_name @@ -178,22 +160,25 @@ create or replace package body ut_annotation_cache_manager as function get_annotations_parsed_since(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp) return sys_refcursor is l_results sys_refcursor; begin + --cast(collect(...)) does not use privileges of code based access control roles (ORA-00902), cast(multiset(...)) does open l_results for - select /*+ no_parallel */ ut_annotated_object( + select /*+ no_parallel */ &&ut3_owner..ut_annotated_object( i.object_owner, i.object_name, i.object_type, i.parse_time, cast( - collect( - ut_annotation( - c.annotation_position, c.annotation_name, c.annotation_text, c.subobject_name - ) order by c.annotation_position - ) as ut_annotations + multiset( + select /*+ no_parallel */ &&ut3_owner..ut_annotation( + c.annotation_position, c.annotation_name, c.annotation_text, c.subobject_name + ) + from &&ut3_owner..ut_annotation_cache c + where c.cache_id = i.cache_id + order by c.annotation_position + ) as &&ut3_owner..ut_annotations ) ) as annotated_object - from ut_annotation_cache_info i - join ut_annotation_cache c on i.cache_id = c.cache_id + from &&ut3_owner..ut_annotation_cache_info i where i.object_owner = a_object_owner and i.object_type = a_object_type and (i.parse_time > a_parsed_after or a_parsed_after is null) - group by i.object_owner, i.object_type, i.object_name, i.parse_time; + and exists (select /*+ no_parallel */ 1 from &&ut3_owner..ut_annotation_cache c where c.cache_id = i.cache_id); return l_results; end; @@ -208,15 +193,15 @@ create or replace package body ut_annotation_cache_manager as else l_filter := case when a_object_owner is null then ':a_object_owner is null' else 'object_owner = :a_object_owner' end; l_filter := l_filter || ' and ' || case when a_object_type is null then ':a_object_type is null' else 'object_type = :a_object_type' end; - l_cache_filter := ' c.cache_id in (select /*+ no_parallel */ i.cache_id from ut_annotation_cache_info i where ' || l_filter || ' )'; + l_cache_filter := ' c.cache_id in (select /*+ no_parallel */ i.cache_id from &&ut3_owner..ut_annotation_cache_info i where ' || l_filter || ' )'; end if; - execute immediate 'delete /*+ no_parallel */ from ut_annotation_cache c where ' || l_cache_filter + execute immediate 'delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache c where ' || l_cache_filter using a_object_owner, a_object_type; - execute immediate ' delete /*+ no_parallel */ from ut_annotation_cache_info i where ' || l_filter + execute immediate ' delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache_info i where ' || l_filter using a_object_owner, a_object_type; - execute immediate ' delete /*+ no_parallel */ from ut_annotation_cache_schema s where ' || l_filter + execute immediate ' delete /*+ no_parallel */ from &&ut3_owner..ut_annotation_cache_schema s where ' || l_filter using a_object_owner, a_object_type; commit; diff --git a/source/core/annotations/ut_annotation_cache_manager.pks b/source/core/annotations/ut_annotation_cache_manager.pks index 55d109f91..a07f56e66 100644 --- a/source/core/annotations/ut_annotation_cache_manager.pks +++ b/source/core/annotations/ut_annotation_cache_manager.pks @@ -1,10 +1,10 @@ -create or replace package ut_annotation_cache_manager authid definer as +create or replace noneditionable package ut_annotation_cache_manager authid current_user as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -15,6 +15,13 @@ create or replace package ut_annotation_cache_manager authid definer as See the License for the specific language governing permissions and limitations under the License. */ + + /* + * The package runs with invoker rights. It accesses the annotation cache tables of the framework owner + * through the code based access control role _cbac_modify_objects_role granted to the package, + * so all references to those tables in SQL statements are qualified with the framework owner. + * The owner is filled in by the SQL*Plus substitution variable ut3_owner when the package body is installed by install.sql. + */ subtype t_cache_schema_info is ut_annotation_cache_schema%rowtype; /** @@ -41,11 +48,6 @@ create or replace package ut_annotation_cache_manager authid definer as function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info; - /** - * Returns information about all objects stored in annotation cache - */ - function get_cached_objects_list(a_object_owner varchar2, a_object_type varchar2, a_parsed_after timestamp := null) return ut_annotation_objs_cache_info; - /** * Resets cached information about annotations for objects on the list and updates parse_time in cache info table. * diff --git a/source/core/annotations/ut_annotation_cache_schema.sql b/source/core/annotations/ut_annotation_cache_schema.sql index b8ebaa40b..46c49739d 100644 --- a/source/core/annotations/ut_annotation_cache_schema.sql +++ b/source/core/annotations/ut_annotation_cache_schema.sql @@ -2,8 +2,8 @@ create table ut_annotation_cache_schema ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/annotations/ut_annotation_cache_seq.sql b/source/core/annotations/ut_annotation_cache_seq.sql index f0f1f17d7..0313abde5 100644 --- a/source/core/annotations/ut_annotation_cache_seq.sql +++ b/source/core/annotations/ut_annotation_cache_seq.sql @@ -2,8 +2,8 @@ create sequence ut_annotation_cache_seq /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/annotations/ut_annotation_manager.pkb b/source/core/annotations/ut_annotation_manager.pkb index e7d9f2719..59bc54530 100644 --- a/source/core/annotations/ut_annotation_manager.pkb +++ b/source/core/annotations/ut_annotation_manager.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_annotation_manager as +create or replace noneditionable package body ut_annotation_manager as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -27,28 +27,30 @@ create or replace package body ut_annotation_manager as end; function get_non_existing_objects( a_object_owner varchar2, a_object_type varchar2 ) return ut_annotation_objs_cache_info is + l_ut_owner varchar2(250) := ut_utils.ut_owner; l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); - l_object_to_delete ut_annotation_objs_cache_info := ut_annotation_objs_cache_info(); - l_cached_objects ut_annotation_objs_cache_info; + l_object_to_delete ut_annotation_objs_cache_info; begin - l_cached_objects := ut_annotation_cache_manager.get_cached_objects_list( a_object_owner, a_object_type ); - - if l_cached_objects is not empty then - execute immediate 'select /*+ no_parallel cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */ - value(i) - from table( :l_data ) i - where - not exists ( - select 1 from '||l_objects_view||q'[ o - where o.owner = i.object_owner - and o.object_name = i.object_name - and o.object_type = i.object_type - and o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' - and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' - )]' - bulk collect into l_object_to_delete - using l_cached_objects; - end if; + execute immediate + 'select /*+ no_parallel */ + '||l_ut_owner||q'[.ut_annotation_obj_cache_info( + object_owner => i.object_owner, + object_name => i.object_name, + object_type => i.object_type, + needs_refresh => 'N', + parse_time => i.parse_time + ) + from (]'||l_ut_owner||q'[.ut_annotation_cache_macros.get_cached_objects( :a_object_owner, :a_object_type )) i + where not exists ( + select 1 from ]'||l_objects_view||q'[ o + where o.owner = i.object_owner + and o.object_name = i.object_name + and o.object_type = i.object_type + and o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' + and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' + )]' + bulk collect into l_object_to_delete + using a_object_owner, a_object_type; return l_object_to_delete; end; @@ -60,7 +62,6 @@ create or replace package body ut_annotation_manager as l_ut_owner varchar2(250) := ut_utils.ut_owner; l_refresh_needed boolean; l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); - l_cached_objects ut_annotation_objs_cache_info; l_result ut_annotation_objs_cache_info := ut_annotation_objs_cache_info(); begin ut_event_manager.trigger_event( 'get_objects_to_refresh - start', ut_key_anyvalues().put('ut_trigger_check.is_alive()',ut_trigger_check.is_alive()) ); @@ -69,9 +70,8 @@ create or replace package body ut_annotation_manager as if l_refresh_needed then --limit the list to objects that exist and are visible to the invoking user --enrich the list by info about cache validity - l_cached_objects := ut_annotation_cache_manager.get_cached_objects_list( a_object_owner, a_object_type, a_modified_after ); execute immediate - 'select /*+ no_parallel cardinality(i '||ut_utils.scale_cardinality(cardinality(l_cached_objects))||') */ + 'select /*+ no_parallel */ '||l_ut_owner||q'[.ut_annotation_obj_cache_info( object_owner => o.owner, object_name => o.object_name, @@ -80,20 +80,20 @@ create or replace package body ut_annotation_manager as parse_time => c.parse_time ) from ]'||l_objects_view||' o - left join table( cast(:l_cached_objects as '||l_ut_owner||q'[.ut_annotation_objs_cache_info ) ) c + left join '||l_ut_owner||q'[.ut_annotation_cache_macros.get_cached_objects( :a_object_owner, :a_object_type ) c on o.owner = c.object_owner and o.object_name = c.object_name and o.object_type = c.object_type where o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' - and case when o.last_ddl_time < cast(c.parse_time as date) then 'N' else 'Y' end = 'Y' + and (c.parse_time is null or o.last_ddl_time >= cast(c.parse_time as date)) and ]' || case when a_modified_after is null then ':a_modified_after is null' else 'o.last_ddl_time >= cast(:a_modified_after as date)' end - bulk collect into l_result using l_cached_objects, a_modified_after; + bulk collect into l_result using a_object_owner, a_object_type, a_modified_after; end if; ut_event_manager.trigger_event('get_objects_to_refresh - end (count='||l_result.count||')'); return l_result; @@ -277,15 +277,8 @@ create or replace package body ut_annotation_manager as begin if ora_dict_obj_type in ('PACKAGE','PROCEDURE','FUNCTION','TYPE') then - $if dbms_db_version.version < 12 $then - l_restricted_users := ora_name_list_t( - 'ANONYMOUS','APPQOSSYS','AUDSYS','DBSFWUSER','DBSNMP','DIP','GGSYS','GSMADMIN_INTERNAL', - 'GSMCATUSER','GSMUSER','ORACLE_OCM','OUTLN','REMOTE_SCHEDULER_AGENT','SYS','SYS$UMF', - 'SYSBACKUP','SYSDG','SYSKM','SYSRAC','SYSTEM','WMSYS','XDB','XS$NULL'); - $else - select /*+ no_parallel */ username bulk collect into l_restricted_users - from all_users where oracle_maintained = 'Y'; - $end + select /*+ no_parallel */ username bulk collect into l_restricted_users + from all_users where oracle_maintained = 'Y'; if ora_dict_obj_owner member of l_restricted_users then return; end if; diff --git a/source/core/annotations/ut_annotation_manager.pks b/source/core/annotations/ut_annotation_manager.pks index 637577d59..37809e88c 100644 --- a/source/core/annotations/ut_annotation_manager.pks +++ b/source/core/annotations/ut_annotation_manager.pks @@ -1,10 +1,10 @@ -create or replace package ut_annotation_manager authid current_user as +create or replace noneditionable package ut_annotation_manager authid current_user as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotation_obj_cache_info.tps b/source/core/annotations/ut_annotation_obj_cache_info.tps index f7bdfa9a8..1e2d9d265 100644 --- a/source/core/annotations/ut_annotation_obj_cache_info.tps +++ b/source/core/annotations/ut_annotation_obj_cache_info.tps @@ -1,10 +1,10 @@ -create type ut_annotation_obj_cache_info as object( +create or replace noneditionable type ut_annotation_obj_cache_info as object( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotation_objs_cache_info.tps b/source/core/annotations/ut_annotation_objs_cache_info.tps index eb69f41e9..1e1d730b6 100644 --- a/source/core/annotations/ut_annotation_objs_cache_info.tps +++ b/source/core/annotations/ut_annotation_objs_cache_info.tps @@ -1,10 +1,10 @@ -create type ut_annotation_objs_cache_info as +create or replace noneditionable type ut_annotation_objs_cache_info as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotation_parser.pkb b/source/core/annotations/ut_annotation_parser.pkb index 8682604f6..f7314c2a0 100644 --- a/source/core/annotations/ut_annotation_parser.pkb +++ b/source/core/annotations/ut_annotation_parser.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_annotation_parser as +create or replace noneditionable package body ut_annotation_parser as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotation_parser.pks b/source/core/annotations/ut_annotation_parser.pks index 5bc2700a4..84d54df81 100644 --- a/source/core/annotations/ut_annotation_parser.pks +++ b/source/core/annotations/ut_annotation_parser.pks @@ -1,10 +1,10 @@ -create or replace package ut_annotation_parser authid current_user as +create or replace noneditionable package ut_annotation_parser authid current_user as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_annotations.tps b/source/core/annotations/ut_annotations.tps index 7669f008b..2295dc797 100644 --- a/source/core/annotations/ut_annotations.tps +++ b/source/core/annotations/ut_annotations.tps @@ -1,10 +1,10 @@ -create type ut_annotations +create or replace noneditionable type ut_annotations /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_trigger_annotation_parsing.trg b/source/core/annotations/ut_trigger_annotation_parsing.trg index 75caea5e8..60d1fec16 100644 --- a/source/core/annotations/ut_trigger_annotation_parsing.trg +++ b/source/core/annotations/ut_trigger_annotation_parsing.trg @@ -6,8 +6,8 @@ begin utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/annotations/ut_trigger_check.pkb b/source/core/annotations/ut_trigger_check.pkb index d533044bb..c9b5172f7 100644 --- a/source/core/annotations/ut_trigger_check.pkb +++ b/source/core/annotations/ut_trigger_check.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_trigger_check is +create or replace noneditionable package body ut_trigger_check is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -22,7 +22,7 @@ create or replace package body ut_trigger_check is function is_alive return boolean is pragma autonomous_transaction; begin - execute immediate 'create or replace synonym '||ut_utils.ut_owner||'.'||gc_check_object_name||' for no_object'; + execute immediate 'create or replace noneditionable synonym '||ut_utils.ut_owner||'.'||gc_check_object_name||' for no_object'; return g_is_trigger_live; end; diff --git a/source/core/annotations/ut_trigger_check.pks b/source/core/annotations/ut_trigger_check.pks index 8c095c71a..a473c859b 100644 --- a/source/core/annotations/ut_trigger_check.pks +++ b/source/core/annotations/ut_trigger_check.pks @@ -1,10 +1,10 @@ -create or replace package ut_trigger_check authid definer is +create or replace noneditionable package ut_trigger_check authid definer is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage.pkb b/source/core/coverage/ut_coverage.pkb index f3181fdc7..257d809ed 100644 --- a/source/core/coverage/ut_coverage.pkb +++ b/source/core/coverage/ut_coverage.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage is +create or replace noneditionable package body ut_coverage is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -277,41 +277,38 @@ create or replace package body ut_coverage is l_result_profiler_enrich := ut_coverage_profiler.get_coverage_data( l_coverage_options ); ut_event_manager.trigger_event('profiler coverage data retrieved'); - -- If block coverage available we will use it. - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - l_result_block := ut_coverage_block.get_coverage_data( l_coverage_options ); - ut_event_manager.trigger_event('block coverage data retrieved'); - - -- Enrich profiler results with some of the block results - l_object := l_result_profiler_enrich.objects.first; - while (l_object is not null) loop - - l_line_no := l_result_profiler_enrich.objects(l_object).lines.first; - - -- to avoid no data found check if we got object in profiler - if l_result_block.objects.exists(l_object) then - while (l_line_no is not null) loop - -- To avoid no data check for object line - if l_result_block.objects(l_object).lines.exists(l_line_no) then - -- enrich line level stats - l_result_profiler_enrich.objects(l_object).lines(l_line_no).partcove := l_result_block.objects(l_object).lines(l_line_no).partcove; - l_result_profiler_enrich.objects(l_object).lines(l_line_no).covered_blocks := l_result_block.objects(l_object).lines(l_line_no).covered_blocks; - l_result_profiler_enrich.objects(l_object).lines(l_line_no).no_blocks := l_result_block.objects(l_object).lines(l_line_no).no_blocks; - -- enrich object level stats - l_result_profiler_enrich.objects(l_object).partcovered_lines := nvl(l_result_profiler_enrich.objects(l_object).partcovered_lines,0) + l_result_block.objects(l_object).lines(l_line_no).partcove; - end if; - --At the end go to next line - l_line_no := l_result_profiler_enrich.objects(l_object).lines.next(l_line_no); - end loop; - --total level stats enrich - l_result_profiler_enrich.partcovered_lines := nvl(l_result_profiler_enrich.partcovered_lines,0) + l_result_profiler_enrich.objects(l_object).partcovered_lines; - -- At the end go to next object - end if; - - l_object := l_result_profiler_enrich.objects.next(l_object); - end loop; - ut_event_manager.trigger_event('coverage data combined'); - $end + l_result_block := ut_coverage_block.get_coverage_data( l_coverage_options ); + ut_event_manager.trigger_event('block coverage data retrieved'); + + -- Enrich profiler results with some of the block results + l_object := l_result_profiler_enrich.objects.first; + while (l_object is not null) loop + + l_line_no := l_result_profiler_enrich.objects(l_object).lines.first; + + -- to avoid no data found check if we got object in profiler + if l_result_block.objects.exists(l_object) then + while (l_line_no is not null) loop + -- To avoid no data check for object line + if l_result_block.objects(l_object).lines.exists(l_line_no) then + -- enrich line level stats + l_result_profiler_enrich.objects(l_object).lines(l_line_no).partcove := l_result_block.objects(l_object).lines(l_line_no).partcove; + l_result_profiler_enrich.objects(l_object).lines(l_line_no).covered_blocks := l_result_block.objects(l_object).lines(l_line_no).covered_blocks; + l_result_profiler_enrich.objects(l_object).lines(l_line_no).no_blocks := l_result_block.objects(l_object).lines(l_line_no).no_blocks; + -- enrich object level stats + l_result_profiler_enrich.objects(l_object).partcovered_lines := nvl(l_result_profiler_enrich.objects(l_object).partcovered_lines,0) + l_result_block.objects(l_object).lines(l_line_no).partcove; + end if; + --At the end go to next line + l_line_no := l_result_profiler_enrich.objects(l_object).lines.next(l_line_no); + end loop; + --total level stats enrich + l_result_profiler_enrich.partcovered_lines := nvl(l_result_profiler_enrich.partcovered_lines,0) + l_result_profiler_enrich.objects(l_object).partcovered_lines; + -- At the end go to next object + end if; + + l_object := l_result_profiler_enrich.objects.next(l_object); + end loop; + ut_event_manager.trigger_event('coverage data combined'); return l_result_profiler_enrich; end get_coverage_data; diff --git a/source/core/coverage/ut_coverage.pks b/source/core/coverage/ut_coverage.pks index 6bcde8e64..f777fde4e 100644 --- a/source/core/coverage/ut_coverage.pks +++ b/source/core/coverage/ut_coverage.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage authid current_user is +create or replace noneditionable package ut_coverage authid current_user is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_block.pkb b/source/core/coverage/ut_coverage_block.pkb index 2d7e8bdac..d6f52d9db 100644 --- a/source/core/coverage/ut_coverage_block.pkb +++ b/source/core/coverage/ut_coverage_block.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_block is +create or replace noneditionable package body ut_coverage_block is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -32,7 +32,6 @@ create or replace package body ut_coverage_block is l_source_object ut_coverage_helper.t_tmp_table_object; begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then l_source_objects_crsr := ut_coverage_helper.get_tmp_table_objects_cursor(); loop fetch l_source_objects_crsr @@ -151,7 +150,6 @@ create or replace package body ut_coverage_block is end loop; close l_source_objects_crsr; - $end return l_result; end get_coverage_data; diff --git a/source/core/coverage/ut_coverage_block.pks b/source/core/coverage/ut_coverage_block.pks index 1bd9c2d39..68451e1ed 100644 --- a/source/core/coverage/ut_coverage_block.pks +++ b/source/core/coverage/ut_coverage_block.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_block authid current_user is +create or replace noneditionable package ut_coverage_block authid current_user is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_helper.pkb b/source/core/coverage/ut_coverage_helper.pkb index 16e0bf7a1..555c12fa4 100644 --- a/source/core/coverage/ut_coverage_helper.pkb +++ b/source/core/coverage/ut_coverage_helper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_helper is +create or replace noneditionable package body ut_coverage_helper is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_helper.pks b/source/core/coverage/ut_coverage_helper.pks index da4cba087..3b51bddb3 100644 --- a/source/core/coverage/ut_coverage_helper.pks +++ b/source/core/coverage/ut_coverage_helper.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_helper authid definer is +create or replace noneditionable package ut_coverage_helper authid definer is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_helper_block.pkb b/source/core/coverage/ut_coverage_helper_block.pkb index 0cf009a10..6aa9f6912 100644 --- a/source/core/coverage/ut_coverage_helper_block.pkb +++ b/source/core/coverage/ut_coverage_helper_block.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_helper_block is +create or replace noneditionable package body ut_coverage_helper_block is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -25,20 +25,12 @@ create or replace package body ut_coverage_helper_block is function coverage_start(a_run_comment varchar2) return integer is begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - return dbms_plsql_code_coverage.start_coverage(run_comment => a_run_comment); - $else - return null; - $end + return dbms_plsql_code_coverage.start_coverage(run_comment => a_run_comment); end; procedure coverage_stop is begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - dbms_plsql_code_coverage.stop_coverage(); - $else - null; - $end + dbms_plsql_code_coverage.stop_coverage(); exception when others then if sqlcode = -08402 then @@ -89,21 +81,19 @@ create or replace package body ut_coverage_helper_block is l_results ut_coverage_helper.t_unit_line_calls; begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - l_tmp_data := block_results(a_object, a_coverage_run_id); + l_tmp_data := block_results(a_object, a_coverage_run_id); - for i in 1 .. l_tmp_data.count loop - l_results(l_tmp_data(i).line).blocks := l_tmp_data(i).blocks; - l_results(l_tmp_data(i).line).covered_blocks := l_tmp_data(i).covered_blocks; - l_results(l_tmp_data(i).line).partcovered := - case - when (l_tmp_data(i).covered_blocks > 0) - and (l_tmp_data(i).blocks > l_tmp_data(i).covered_blocks) - then 1 - else 0 - end; - end loop; - $end + for i in 1 .. l_tmp_data.count loop + l_results(l_tmp_data(i).line).blocks := l_tmp_data(i).blocks; + l_results(l_tmp_data(i).line).covered_blocks := l_tmp_data(i).covered_blocks; + l_results(l_tmp_data(i).line).partcovered := + case + when (l_tmp_data(i).covered_blocks > 0) + and (l_tmp_data(i).blocks > l_tmp_data(i).covered_blocks) + then 1 + else 0 + end; + end loop; return l_results; end; end; diff --git a/source/core/coverage/ut_coverage_helper_block.pks b/source/core/coverage/ut_coverage_helper_block.pks index 3ee1f266c..0bef1ebce 100644 --- a/source/core/coverage/ut_coverage_helper_block.pks +++ b/source/core/coverage/ut_coverage_helper_block.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_helper_block authid current_user is +create or replace noneditionable package ut_coverage_helper_block authid current_user is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_helper_profiler.pkb b/source/core/coverage/ut_coverage_helper_profiler.pkb index 7f6e6e51d..f1c9ab921 100644 --- a/source/core/coverage/ut_coverage_helper_profiler.pkb +++ b/source/core/coverage/ut_coverage_helper_profiler.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_helper_profiler is +create or replace noneditionable package body ut_coverage_helper_profiler is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_helper_profiler.pks b/source/core/coverage/ut_coverage_helper_profiler.pks index 2e56d10f7..841235080 100644 --- a/source/core/coverage/ut_coverage_helper_profiler.pks +++ b/source/core/coverage/ut_coverage_helper_profiler.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_helper_profiler authid definer is +create or replace noneditionable package ut_coverage_helper_profiler authid definer is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_profiler.pkb b/source/core/coverage/ut_coverage_profiler.pkb index 1dc40bcbc..1bd037083 100644 --- a/source/core/coverage/ut_coverage_profiler.pkb +++ b/source/core/coverage/ut_coverage_profiler.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_profiler is +create or replace noneditionable package body ut_coverage_profiler is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_profiler.pks b/source/core/coverage/ut_coverage_profiler.pks index 16145c34a..4cdab2ae1 100644 --- a/source/core/coverage/ut_coverage_profiler.pks +++ b/source/core/coverage/ut_coverage_profiler.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_profiler authid current_user is +create or replace noneditionable package ut_coverage_profiler authid current_user is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_reporter_base.tpb b/source/core/coverage/ut_coverage_reporter_base.tpb index f28226428..70d27afc3 100644 --- a/source/core/coverage/ut_coverage_reporter_base.tpb +++ b/source/core/coverage/ut_coverage_reporter_base.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_coverage_reporter_base is +create or replace noneditionable type body ut_coverage_reporter_base is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_reporter_base.tps b/source/core/coverage/ut_coverage_reporter_base.tps index b917ea707..3de89e8bb 100644 --- a/source/core/coverage/ut_coverage_reporter_base.tps +++ b/source/core/coverage/ut_coverage_reporter_base.tps @@ -1,10 +1,10 @@ -create or replace type ut_coverage_reporter_base under ut_output_reporter_base( +create or replace noneditionable type ut_coverage_reporter_base under ut_output_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/coverage/ut_coverage_sources_tmp.sql b/source/core/coverage/ut_coverage_sources_tmp.sql index 35eb05510..90fe38171 100644 --- a/source/core/coverage/ut_coverage_sources_tmp.sql +++ b/source/core/coverage/ut_coverage_sources_tmp.sql @@ -2,8 +2,8 @@ create global temporary table ut_coverage_sources_tmp( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/events/ut_event_item.tps b/source/core/events/ut_event_item.tps index bb4556e03..28391a8d2 100644 --- a/source/core/events/ut_event_item.tps +++ b/source/core/events/ut_event_item.tps @@ -1,10 +1,10 @@ -create or replace type ut_event_item authid current_user as object ( +create or replace noneditionable type ut_event_item authid current_user as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/events/ut_event_listener.tps b/source/core/events/ut_event_listener.tps index ee34bb009..c16d00065 100644 --- a/source/core/events/ut_event_listener.tps +++ b/source/core/events/ut_event_listener.tps @@ -1,10 +1,10 @@ -create or replace type ut_event_listener authid current_user as object ( +create or replace noneditionable type ut_event_listener authid current_user as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/events/ut_event_manager.pkb b/source/core/events/ut_event_manager.pkb index 0b80b5a98..bbc342a1f 100644 --- a/source/core/events/ut_event_manager.pkb +++ b/source/core/events/ut_event_manager.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_event_manager as +create or replace noneditionable package body ut_event_manager as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/events/ut_event_manager.pks b/source/core/events/ut_event_manager.pks index 9cea89898..d6480b83f 100644 --- a/source/core/events/ut_event_manager.pks +++ b/source/core/events/ut_event_manager.pks @@ -1,10 +1,10 @@ -create or replace package ut_event_manager authid current_user as +create or replace noneditionable package ut_event_manager authid current_user as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/output_buffers/ut_output_buffer_base.tpb b/source/core/output_buffers/ut_output_buffer_base.tpb index dc9b34b88..6bbb00b4b 100644 --- a/source/core/output_buffers/ut_output_buffer_base.tpb +++ b/source/core/output_buffers/ut_output_buffer_base.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_output_buffer_base is +create or replace noneditionable type body ut_output_buffer_base is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -40,7 +40,7 @@ create or replace type body ut_output_buffer_base is member procedure lock_buffer(a_timeout_sec number := null) is l_status integer; begin - l_status := dbms_lock.request( self.lock_handle, dbms_lock.x_mode, 5, false ); + l_status := dbms_lock.request( self.lock_handle, dbms_lock.x_mode, coalesce(a_timeout_sec, 0.1), false ); if l_status != 0 then raise_application_error(-20000, 'Cannot allocate lock for output buffer of reporter. lock request status = '||l_status||', lock handle = '||self.lock_handle||', self.output_id ='||self.output_id); end if; diff --git a/source/core/output_buffers/ut_output_buffer_base.tps b/source/core/output_buffers/ut_output_buffer_base.tps index 9615cdc5e..e2d1c6731 100644 --- a/source/core/output_buffers/ut_output_buffer_base.tps +++ b/source/core/output_buffers/ut_output_buffer_base.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_buffer_base force authid definer as object( +create or replace noneditionable type ut_output_buffer_base force authid definer as object( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/output_buffers/ut_output_buffer_info_tmp.sql b/source/core/output_buffers/ut_output_buffer_info_tmp.sql index 2aba5a55c..b8bb10095 100644 --- a/source/core/output_buffers/ut_output_buffer_info_tmp.sql +++ b/source/core/output_buffers/ut_output_buffer_info_tmp.sql @@ -2,8 +2,8 @@ create table ut_output_buffer_info_tmp( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/output_buffers/ut_output_buffer_tmp.sql b/source/core/output_buffers/ut_output_buffer_tmp.sql index 68b738d3f..dc4c5043c 100644 --- a/source/core/output_buffers/ut_output_buffer_tmp.sql +++ b/source/core/output_buffers/ut_output_buffer_tmp.sql @@ -2,8 +2,8 @@ create table ut_output_buffer_tmp( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -21,11 +21,8 @@ create table ut_output_buffer_tmp( message_id number(38,0) not null, text varchar2(4000), item_type varchar2(1000), - is_finished number(1,0) default 0 not null, constraint ut_output_buffer_tmp_pk primary key(output_id, message_id), - constraint ut_output_buffer_tmp_ck check( - is_finished = 0 and (text is not null or item_type is not null ) - or is_finished = 1 and text is null and item_type is null ), + constraint ut_output_buffer_tmp_ck check( text is not null or item_type is not null ), constraint ut_output_buffer_fk foreign key (output_id) references ut_output_buffer_info_tmp(output_id) on delete cascade ) organization index nologging initrans 100 overflow nologging initrans 100; diff --git a/source/core/output_buffers/ut_output_bulk_buffer.tpb b/source/core/output_buffers/ut_output_bulk_buffer.tpb index bc0ec6128..60efda708 100644 --- a/source/core/output_buffers/ut_output_bulk_buffer.tpb +++ b/source/core/output_buffers/ut_output_bulk_buffer.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_output_bulk_buffer is +create or replace noneditionable type body ut_output_bulk_buffer is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -118,7 +118,7 @@ create or replace type body ut_output_bulk_buffer is or self.timeout_producer_not_started(l_producer_started, l_already_waited_sec, lc_init_wait_sec) or l_producer_finished; - dbms_lock.sleep(l_sleep_time); + dbms_session.sleep(l_sleep_time); l_already_waited_sec := l_already_waited_sec + l_sleep_time; end loop; diff --git a/source/core/output_buffers/ut_output_bulk_buffer.tps b/source/core/output_buffers/ut_output_bulk_buffer.tps index 31d7271fa..7534e8fa8 100644 --- a/source/core/output_buffers/ut_output_bulk_buffer.tps +++ b/source/core/output_buffers/ut_output_bulk_buffer.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_bulk_buffer under ut_output_buffer_base ( +create or replace noneditionable type ut_output_bulk_buffer under ut_output_buffer_base ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/output_buffers/ut_output_clob_buffer_tmp.sql b/source/core/output_buffers/ut_output_clob_buffer_tmp.sql index fa61191ce..b832e68c7 100644 --- a/source/core/output_buffers/ut_output_clob_buffer_tmp.sql +++ b/source/core/output_buffers/ut_output_clob_buffer_tmp.sql @@ -7,8 +7,8 @@ begin /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -26,11 +26,8 @@ begin message_id number(38,0) not null, text clob, item_type varchar2(1000), - is_finished number(1,0) default 0 not null, constraint ut_output_clob_buffer_tmp_pk primary key(output_id, message_id), - constraint ut_output_clob_buffer_tmp_ck check( - is_finished = 0 and (text is not null or item_type is not null ) - or is_finished = 1 and text is null and item_type is null ), + constraint ut_output_clob_buffer_tmp_ck check( text is not null or item_type is not null ), constraint ut_output_clob_buffer_tmp_fk foreign key (output_id) references ut_output_buffer_info_tmp(output_id) on delete cascade ) nologging initrans 100 '; diff --git a/source/core/output_buffers/ut_output_clob_table_buffer.tpb b/source/core/output_buffers/ut_output_clob_table_buffer.tpb index 8f1cd3187..c79e90510 100644 --- a/source/core/output_buffers/ut_output_clob_table_buffer.tpb +++ b/source/core/output_buffers/ut_output_clob_table_buffer.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_output_clob_table_buffer is +create or replace noneditionable type body ut_output_clob_table_buffer is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -56,7 +56,6 @@ create or replace type body ut_output_clob_table_buffer is lc_init_wait_sec constant number := coalesce(a_initial_timeout, 10 ); l_buffer_rowids ut_varchar2_rows; l_buffer_data ut_output_data_rows; - l_finished_flags ut_integer_list; l_already_waited_sec number(10,2) := 0; l_finished boolean := false; l_sleep_time number(2,1); @@ -65,20 +64,19 @@ create or replace type body ut_output_clob_table_buffer is l_producer_finished boolean := false; procedure get_data_from_buffer_table( a_buffer_data out nocopy ut_output_data_rows, - a_buffer_rowids out nocopy ut_varchar2_rows, - a_finished_flags out nocopy ut_integer_list + a_buffer_rowids out nocopy ut_varchar2_rows ) is lc_bulk_limit constant integer := 5000; begin with ordered_buffer as ( - select /*+ no_parallel index(a) */ ut_output_data_row(a.text, a.item_type), rowidtochar(a.rowid), is_finished + select /*+ no_parallel index(a) */ ut_output_data_row(a.text, a.item_type), rowidtochar(a.rowid) from ut_output_clob_buffer_tmp a where a.output_id = self.output_id and a.message_id <= (select min(message_id) from ut_output_clob_buffer_tmp o where o.output_id = self.output_id) + lc_bulk_limit order by a.message_id ) select /*+ no_parallel */ b.* - bulk collect into a_buffer_data, a_buffer_rowids, a_finished_flags + bulk collect into a_buffer_data, a_buffer_rowids from ordered_buffer b; end; @@ -96,22 +94,19 @@ create or replace type body ut_output_clob_table_buffer is l_sleep_time := case when l_already_waited_sec >= 1 then 0.5 else 0.1 end; l_lock_status := self.get_lock_status(); - get_data_from_buffer_table( l_buffer_data, l_buffer_rowids, l_finished_flags ); + get_data_from_buffer_table( l_buffer_data, l_buffer_rowids ); if l_buffer_data.count > 0 then l_already_waited_sec := 0; for i in 1 .. l_buffer_data.count loop if l_buffer_data(i).text is not null then pipe row( l_buffer_data(i) ); - elsif l_finished_flags(i) = 1 then - l_finished := true; - exit; end if; end loop; remove_read_data(l_buffer_rowids); else --nothing fetched from output, wait. - dbms_lock.sleep(l_sleep_time); + dbms_session.sleep(l_sleep_time); l_already_waited_sec := l_already_waited_sec + l_sleep_time; end if; @@ -121,8 +116,7 @@ create or replace type body ut_output_clob_table_buffer is l_finished := self.timeout_producer_not_finished(l_producer_finished, l_already_waited_sec, a_timeout_sec) or self.timeout_producer_not_started(l_producer_started, l_already_waited_sec, lc_init_wait_sec) - or l_producer_finished - or l_finished; + or l_producer_finished; end loop; diff --git a/source/core/output_buffers/ut_output_clob_table_buffer.tps b/source/core/output_buffers/ut_output_clob_table_buffer.tps index 2cfb2538b..22d6ac227 100644 --- a/source/core/output_buffers/ut_output_clob_table_buffer.tps +++ b/source/core/output_buffers/ut_output_clob_table_buffer.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_clob_table_buffer under ut_output_buffer_base ( +create or replace noneditionable type ut_output_clob_table_buffer under ut_output_buffer_base ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/output_buffers/ut_output_data_row.tps b/source/core/output_buffers/ut_output_data_row.tps index ecfde404a..a8f0743ee 100644 --- a/source/core/output_buffers/ut_output_data_row.tps +++ b/source/core/output_buffers/ut_output_data_row.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_data_row as object ( +create or replace noneditionable type ut_output_data_row as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/output_buffers/ut_output_data_rows.tps b/source/core/output_buffers/ut_output_data_rows.tps index c505e2fbf..6067e0d3b 100644 --- a/source/core/output_buffers/ut_output_data_rows.tps +++ b/source/core/output_buffers/ut_output_data_rows.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_data_rows as +create or replace noneditionable type ut_output_data_rows as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/output_buffers/ut_output_table_buffer.tpb b/source/core/output_buffers/ut_output_table_buffer.tpb index 5fbd39907..2edabe58c 100644 --- a/source/core/output_buffers/ut_output_table_buffer.tpb +++ b/source/core/output_buffers/ut_output_table_buffer.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_output_table_buffer is +create or replace noneditionable type body ut_output_table_buffer is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -95,7 +95,6 @@ create or replace type body ut_output_table_buffer is lc_init_wait_sec constant number := coalesce(a_initial_timeout, 10 ); l_buffer_texts ut_varchar2_rows; l_buffer_item_types ut_varchar2_rows; - l_finished_flags ut_integer_list; l_already_waited_sec number(10,2) := 0; l_finished boolean := false; l_sleep_time number(2,1); @@ -105,8 +104,7 @@ create or replace type body ut_output_table_buffer is procedure get_data_from_buffer_table( a_buffer_texts out nocopy ut_varchar2_rows, - a_buffer_item_types out nocopy ut_varchar2_rows, - a_finished_flags out nocopy ut_integer_list + a_buffer_item_types out nocopy ut_varchar2_rows ) is lc_bulk_limit constant integer := 20000; pragma autonomous_transaction; @@ -118,8 +116,8 @@ create or replace type body ut_output_table_buffer is and a.message_id <= (select min(message_id) from ut_output_buffer_tmp o where o.output_id = self.output_id) + lc_bulk_limit order by a.message_id ) d - returning d.text, d.item_type, d.is_finished - bulk collect into a_buffer_texts, a_buffer_item_types, a_finished_flags; + returning d.text, d.item_type + bulk collect into a_buffer_texts, a_buffer_item_types; commit; end; begin @@ -127,21 +125,18 @@ create or replace type body ut_output_table_buffer is l_sleep_time := case when l_already_waited_sec >= 1 then 0.5 else 0.1 end; l_lock_status := self.get_lock_status(); - get_data_from_buffer_table( l_buffer_texts, l_buffer_item_types, l_finished_flags ); + get_data_from_buffer_table( l_buffer_texts, l_buffer_item_types ); if l_buffer_texts.count > 0 then l_already_waited_sec := 0; for i in 1 .. l_buffer_texts.count loop if l_buffer_texts(i) is not null then pipe row( ut_output_data_row(l_buffer_texts(i), l_buffer_item_types(i)) ); - elsif l_finished_flags(i) = 1 then - l_finished := true; - exit; end if; end loop; else --nothing fetched from output, wait. - dbms_lock.sleep(l_sleep_time); + dbms_session.sleep(l_sleep_time); l_already_waited_sec := l_already_waited_sec + l_sleep_time; end if; @@ -151,8 +146,7 @@ create or replace type body ut_output_table_buffer is l_finished := self.timeout_producer_not_finished(l_producer_finished, l_already_waited_sec, a_timeout_sec) or self.timeout_producer_not_started(l_producer_started, l_already_waited_sec, lc_init_wait_sec) - or l_producer_finished - or l_finished; + or l_producer_finished; end loop; diff --git a/source/core/output_buffers/ut_output_table_buffer.tps b/source/core/output_buffers/ut_output_table_buffer.tps index 6c75421db..06e157d90 100644 --- a/source/core/output_buffers/ut_output_table_buffer.tps +++ b/source/core/output_buffers/ut_output_table_buffer.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_table_buffer under ut_output_buffer_base ( +create or replace noneditionable type ut_output_table_buffer under ut_output_buffer_base ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/session_context/ut_session_context.pkb b/source/core/session_context/ut_session_context.pkb index 2443a350a..2db83506e 100644 --- a/source/core/session_context/ut_session_context.pkb +++ b/source/core/session_context/ut_session_context.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_session_context as +create or replace noneditionable package body ut_session_context as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/session_context/ut_session_context.pks b/source/core/session_context/ut_session_context.pks index 8df2decee..1221bccda 100644 --- a/source/core/session_context/ut_session_context.pks +++ b/source/core/session_context/ut_session_context.pks @@ -1,10 +1,10 @@ -create or replace package ut_session_context as +create or replace noneditionable package ut_session_context as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/session_context/ut_session_info.tpb b/source/core/session_context/ut_session_info.tpb index d9d576fb9..fd1b80069 100644 --- a/source/core/session_context/ut_session_info.tpb +++ b/source/core/session_context/ut_session_info.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_session_info as +create or replace noneditionable type body ut_session_info as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/session_context/ut_session_info.tps b/source/core/session_context/ut_session_info.tps index aeb3361c3..741d6cb59 100644 --- a/source/core/session_context/ut_session_info.tps +++ b/source/core/session_context/ut_session_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_session_info under ut_event_listener ( +create or replace noneditionable type ut_session_info under ut_event_listener ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_console_reporter_base.tpb b/source/core/types/ut_console_reporter_base.tpb index 282a52a9a..635a4d456 100644 --- a/source/core/types/ut_console_reporter_base.tpb +++ b/source/core/types/ut_console_reporter_base.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_console_reporter_base is +create or replace noneditionable type body ut_console_reporter_base is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_console_reporter_base.tps b/source/core/types/ut_console_reporter_base.tps index 077af7e37..d23c6d9e4 100644 --- a/source/core/types/ut_console_reporter_base.tps +++ b/source/core/types/ut_console_reporter_base.tps @@ -1,10 +1,10 @@ -create or replace type ut_console_reporter_base under ut_output_reporter_base( +create or replace noneditionable type ut_console_reporter_base under ut_output_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_coverage_options.tpb b/source/core/types/ut_coverage_options.tpb index 6c81af773..f4e07bf9b 100644 --- a/source/core/types/ut_coverage_options.tpb +++ b/source/core/types/ut_coverage_options.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_coverage_options as +create or replace noneditionable type body ut_coverage_options as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_coverage_options.tps b/source/core/types/ut_coverage_options.tps index 3813232df..81a04101f 100644 --- a/source/core/types/ut_coverage_options.tps +++ b/source/core/types/ut_coverage_options.tps @@ -1,10 +1,10 @@ -create or replace type ut_coverage_options force as object ( +create or replace noneditionable type ut_coverage_options force as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_executable.tpb b/source/core/types/ut_executable.tpb index c78cf4d77..5d454989d 100644 --- a/source/core/types/ut_executable.tpb +++ b/source/core/types/ut_executable.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_executable is +create or replace noneditionable type body ut_executable is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -38,20 +38,30 @@ create or replace type body ut_executable is return ut_metadata.form_name(l_owner_name, object_name, procedure_name); end; - member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) is + member procedure do_execute( + self in out nocopy ut_executable, + a_item in out nocopy ut_suite_item, + a_ignored_exception_names in ut_varchar2_rows := null, + a_ignored_exception_numbers in ut_varchar2_rows :=null) + is l_completed_without_errors boolean; begin - l_completed_without_errors := self.do_execute(a_item); + l_completed_without_errors := self.do_execute(a_item, a_ignored_exception_names, a_ignored_exception_numbers); end do_execute; - member function do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) return boolean is - l_statement varchar2(4000); - l_status number; - l_cursor_number number; - l_completed_without_errors boolean := true; - l_failed_with_invalid_pck boolean := true; - l_start_transaction_id varchar2(250); - l_end_transaction_id varchar2(250); + member function do_execute( + self in out nocopy ut_executable, + a_item in out nocopy ut_suite_item, + a_ignored_exception_names in ut_varchar2_rows := null, + a_ignored_exception_numbers in ut_varchar2_rows :=null) + return boolean is + l_statement varchar2(4000); + l_status number; + l_cursor_number number; + l_completed_without_errors boolean := true; + l_failed_with_invalid_pck boolean := true; + l_start_transaction_id varchar2(250); + l_end_transaction_id varchar2(250); function is_defined return boolean is l_result boolean := false; @@ -111,19 +121,33 @@ create or replace type body ut_executable is if l_completed_without_errors then l_statement := 'declare' || chr(10) || - ' l_error_stack varchar2(32767);' || chr(10) || - ' l_error_backtrace varchar2(32767);' || chr(10) || + ' l_error_stack varchar2(32767);' || chr(10) || + ' l_error_backtrace varchar2(32767);' || chr(10) || + ' l_ignored_exception_detected integer := 0;' || chr(10) || 'begin' || chr(10) || ' begin' || chr(10) || ' ' || self.form_name( a_skip_current_user_schema => true ) || ';' || chr(10) || ' exception' || chr(10) || + case when a_ignored_exception_names is not empty then + ' when ' || ut_utils.table_to_clob( a_ignored_exception_names, ' or ' ) || ' then ' || chr(10) || + ' l_ignored_exception_detected := 1;' + end || ' when others then ' || chr(10) || + case when a_ignored_exception_numbers is not empty then + ' if sqlcode in (' || ut_utils.table_to_clob( a_ignored_exception_numbers, ', ' ) || ') then ' || chr(10) || + ' l_ignored_exception_detected := 1; ' || chr(10) || + ' else ' || chr(10) || + ' l_error_stack := dbms_utility.format_error_stack;' || chr(10) || + ' l_error_backtrace := dbms_utility.format_error_backtrace;' || chr(10) || + ' end if;' + else ' l_error_stack := dbms_utility.format_error_stack;' || chr(10) || - ' l_error_backtrace := dbms_utility.format_error_backtrace;' || chr(10) || - ' --raise on ORA-04068, ORA-04061: existing state of packages has been discarded to avoid unrecoverable session exception' || chr(10) || + ' l_error_backtrace := dbms_utility.format_error_backtrace;' + end || chr(10) || ' end;' || chr(10) || ' :a_error_stack := l_error_stack;' || chr(10) || ' :a_error_backtrace := l_error_backtrace;' || chr(10) || + ' :a_ignored_exception_detected := l_ignored_exception_detected;' || chr(10) || 'end;'; ut_utils.debug_log('ut_executable.do_execute l_statement: ' || l_statement); @@ -139,9 +163,11 @@ create or replace type body ut_executable is dbms_sql.parse(l_cursor_number, statement => l_statement, language_flag => dbms_sql.native); dbms_sql.bind_variable(l_cursor_number, 'a_error_stack', to_char(null), 32767); dbms_sql.bind_variable(l_cursor_number, 'a_error_backtrace', to_char(null), 32767); + dbms_sql.bind_variable(l_cursor_number, 'a_ignored_exception_detected', to_number(null)); l_status := dbms_sql.execute(l_cursor_number); dbms_sql.variable_value(l_cursor_number, 'a_error_stack', self.error_stack); dbms_sql.variable_value(l_cursor_number, 'a_error_backtrace', self.error_backtrace); + dbms_sql.variable_value(l_cursor_number, 'a_ignored_exception_detected', self.ignored_exception_detected); dbms_sql.close_cursor(l_cursor_number); exception when ut_utils.ex_invalid_package then diff --git a/source/core/types/ut_executable.tps b/source/core/types/ut_executable.tps index 7d04c4e41..4e263402d 100644 --- a/source/core/types/ut_executable.tps +++ b/source/core/types/ut_executable.tps @@ -1,10 +1,10 @@ -create or replace type ut_executable under ut_event_item( +create or replace noneditionable type ut_executable under ut_event_item( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,26 +18,37 @@ create or replace type ut_executable under ut_event_item( /** * The name of the event to be executed before and after the executable is invoked */ - executable_type varchar2(250 char), - owner_name varchar2(250 char), - object_name varchar2(250 char), - procedure_name varchar2(250 char), - error_backtrace varchar2(4000), - error_stack varchar2(4000), - serveroutput clob, + executable_type varchar2(250 char), + owner_name varchar2(250 char), + object_name varchar2(250 char), + procedure_name varchar2(250 char), + error_backtrace varchar2(4000), + error_stack varchar2(4000), + ignored_exception_detected integer, + serveroutput clob, /** * Used for ordering of executables, as Oracle doesn not guarantee ordering of items in a nested table. */ seq_no integer, constructor function ut_executable( self in out nocopy ut_executable, a_owner varchar2, a_package varchar2, a_procedure_name varchar2, a_executable_type varchar2) return self as result, member function form_name(a_skip_current_user_schema boolean := false) return varchar2, - member procedure do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item), + member procedure do_execute( + self in out nocopy ut_executable, + a_item in out nocopy ut_suite_item, + a_ignored_exception_names in ut_varchar2_rows := null, + a_ignored_exception_numbers in ut_varchar2_rows := null + ), /** * executes the defines executable * returns true if executed without exceptions * returns false if exceptions were raised */ - member function do_execute(self in out nocopy ut_executable, a_item in out nocopy ut_suite_item) return boolean, + member function do_execute( + self in out nocopy ut_executable, + a_item in out nocopy ut_suite_item, + a_ignored_exception_names in ut_varchar2_rows := null, + a_ignored_exception_numbers in ut_varchar2_rows :=null + ) return boolean, member function get_error_stack_trace return varchar2 ) not final / diff --git a/source/core/types/ut_executable_test.tpb b/source/core/types/ut_executable_test.tpb index e816a1b1b..06851a007 100644 --- a/source/core/types/ut_executable_test.tpb +++ b/source/core/types/ut_executable_test.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_executable_test as +create or replace noneditionable type body ut_executable_test as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -31,141 +31,129 @@ create or replace type body ut_executable_test as member procedure do_execute( self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_varchar2_rows + a_expected_errors in ut_varchar2_rows ) is l_completed_without_errors boolean; begin - l_completed_without_errors := self.do_execute(a_item, a_expected_error_codes); + l_completed_without_errors := self.do_execute(a_item, a_expected_errors); end do_execute; member function do_execute( self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_varchar2_rows + a_expected_errors in ut_varchar2_rows ) return boolean is - l_expected_except_message varchar2(4000); - l_expected_error_numbers ut_integer_list; - - function build_exception_numbers_list( - a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_varchar2_rows - ) return ut_integer_list is + l_failure_message varchar2(32767); + l_expected_error_names ut_varchar2_rows; + l_expected_error_numbers ut_varchar2_rows; + l_all_expected_errors ut_varchar2_rows; + + procedure build_expected_exceptions( + a_item in out nocopy ut_suite_item, + a_exception_definitions in ut_varchar2_rows, + a_exception_names_list out ut_varchar2_rows, + a_exception_numbers_list out ut_varchar2_rows + ) is l_exception_number integer; - l_exception_number_list ut_integer_list := ut_integer_list(); - c_regexp_for_exception_no constant varchar2(30) := '^-?[[:digit:]]{1,5}$'; - - c_integer_exception constant varchar2(1) := 'I'; - c_named_exception constant varchar2(1) := 'N'; - - function is_valid_qualified_name (a_name varchar2) return boolean is - l_name varchar2(500); - begin - l_name := dbms_assert.qualified_sql_name(a_name); - return true; - exception when others then - return false; - end; - - function check_exception_type(a_exception_name in varchar2) return varchar2 is - l_exception_type varchar2(50); - begin - --check if it is a predefined exception + l_exception_name varchar2(128); + function to_exception_number (a_exception_var in varchar2, a_item ut_suite_item) return integer is + function get_exception_no(a_exception_var in varchar2) return integer is + l_exc_no integer; begin - execute immediate 'begin null; exception when '||a_exception_name||' then null; end;'; - l_exception_type := c_named_exception; + execute immediate 'declare l_exception integer; begin :l_exception := '||a_exception_var||'; end;' + using out l_exc_no; + return l_exc_no; exception when others then - if dbms_utility.format_error_stack() like '%PLS-00485%' then - declare - e_invalid_number exception; - pragma exception_init ( e_invalid_number, -6502 ); - begin - execute immediate 'declare x integer := '||a_exception_name||'; begin null; end;'; - l_exception_type := c_integer_exception; - exception - when others then - null; - end; - end if; + return null; end; - return l_exception_type; - end; - - function get_exception_number (a_exception_var in varchar2) return integer is - l_exc_no integer; - l_exc_type varchar2(50); function remap_no_data_found (a_number integer) return integer is begin return case a_number when 100 then -1403 else a_number end; end; begin - l_exc_type := check_exception_type(a_exception_var); - - execute immediate - case l_exc_type - when c_integer_exception then - 'declare l_exception number; begin :l_exception := '||a_exception_var||'; end;' - when c_named_exception then - 'begin raise '||a_exception_var||'; exception when others then :l_exception := sqlcode; end;' - else - 'begin :l_exception := null; end;' - end - using out l_exc_no; + return remap_no_data_found( + coalesce( + get_exception_no(a_exception_var), + get_exception_no(a_item.object_name||'.'||a_exception_var), + get_exception_no(a_item.object_owner||'.'||a_exception_var), + get_exception_no(a_item.object_owner||'.'||a_item.object_name||'.'||a_exception_var) + ) + ); + end; + + function to_exception_name (a_exception_var in varchar2, a_item ut_suite_item) return varchar2 is + function verify_name(a_exception_name in varchar2) return varchar2 is + begin + --check if it is an existing, named exception + execute immediate 'begin null; exception when '||a_exception_name||' then null; end;'; + return a_exception_name; + exception + when others then + return null; + end; + begin + return coalesce( + verify_name(a_exception_var), + verify_name(a_item.object_name||'.'||a_exception_var), + verify_name(a_item.object_owner||'.'||a_exception_var), + verify_name(a_item.object_owner||'.'||a_item.object_name||'.'||a_exception_var) + ); - return remap_no_data_found(l_exc_no); end; begin - if a_expected_error_codes is not empty then - for i in 1 .. a_expected_error_codes.count loop - /** - * Check if its a valid qualified name and if so try to resolve name to an exception number - */ - if is_valid_qualified_name(a_expected_error_codes(i)) then - l_exception_number := get_exception_number(a_expected_error_codes(i)); - elsif regexp_like(a_expected_error_codes(i), c_regexp_for_exception_no) then - l_exception_number := a_expected_error_codes(i); - end if; - - if l_exception_number is null then + a_exception_names_list := ut_varchar2_rows(); + a_exception_numbers_list := ut_varchar2_rows(); + if a_exception_definitions is not empty then + for i in 1 .. a_exception_definitions.count loop + l_exception_number := + coalesce( + to_exception_number(a_exception_definitions(i), a_item), + to_number(a_exception_definitions(i) default null on conversion error ) + ); + l_exception_name := to_exception_name(a_exception_definitions(i), a_item); + + if l_exception_number is null and l_exception_name is null then a_item.put_warning( - 'Invalid parameter value "'||a_expected_error_codes(i)||'" for "--%throws" annotation. Parameter ignored.', + 'Invalid parameter value "'||a_exception_definitions(i)||'" for "--%throws" annotation. Parameter ignored.', self.procedure_name, a_item.line_no ); elsif l_exception_number >= 0 then a_item.put_warning( - 'Invalid parameter value "'||a_expected_error_codes(i)||'" for "--%throws" annotation. Exception value must be a negative integer. Parameter ignored.', + 'Invalid parameter value "'||a_exception_definitions(i)||'" for "--%throws" annotation. Exception value must be a negative integer. Parameter ignored.', self.procedure_name, a_item.line_no ); - else - l_exception_number_list.extend; - l_exception_number_list(l_exception_number_list.last) := l_exception_number; + elsif l_exception_number is not null then + a_exception_numbers_list.extend; + a_exception_numbers_list(a_exception_numbers_list.last) := l_exception_number; + elsif l_exception_name is not null then + a_exception_names_list.extend; + a_exception_names_list(a_exception_names_list.last) := l_exception_name; end if; - l_exception_number := null; end loop; end if; - - return l_exception_number_list; end; - function failed_expec_errnum_message(a_expected_error_codes in ut_integer_list) return varchar is + + function get_exception_failure_message(a_expected_errors_list ut_varchar2_rows) return varchar2 is l_actual_error_no integer; - l_expected_error_codes varchar2(4000); + l_expected_errors varchar2(4000); l_fail_message varchar2(4000); begin --Convert the ut_varchar2_list to string to can construct the message - l_expected_error_codes := ut_utils.table_to_clob(a_expected_error_codes, ', '); + l_expected_errors := ut_utils.table_to_clob(a_expected_errors_list, ', '); if self.error_stack is null then - l_fail_message := 'Expected one of exceptions ('||l_expected_error_codes||') but nothing was raised.'; + l_fail_message := 'Expected one of exceptions ('|| l_expected_errors|| ') but nothing was raised.'; else l_actual_error_no := regexp_substr(self.error_stack, '^[[:alpha:]]{3}(-[0-9]+)', subexpression=>1); - if not l_actual_error_no member of a_expected_error_codes or l_actual_error_no is null then + if not l_actual_error_no member of a_expected_errors_list or l_actual_error_no is null then l_fail_message := 'Actual: '||l_actual_error_no||' was expected to '; - if cardinality(a_expected_error_codes) > 1 then - l_fail_message := l_fail_message || 'be one of: ('||l_expected_error_codes||')'; + if cardinality(a_expected_errors_list) > 1 then + l_fail_message := l_fail_message || 'be one of: ('|| l_expected_errors|| ')'; else - l_fail_message := l_fail_message || 'equal: '||l_expected_error_codes; + l_fail_message := l_fail_message || 'equal: '||l_expected_errors; end if; l_fail_message := substr( l_fail_message||chr(10)||self.error_stack||chr(10)||self.error_backtrace, 1, 4000 ); end if; @@ -175,14 +163,16 @@ create or replace type body ut_executable_test as end; begin --Create a ut_executable object and call do_execute after that get the data to know the test's execution result - self.do_execute(a_item); - l_expected_error_numbers := build_exception_numbers_list(a_item, a_expected_error_codes); - if l_expected_error_numbers is not null and l_expected_error_numbers is not empty then - l_expected_except_message := failed_expec_errnum_message( l_expected_error_numbers ); + build_expected_exceptions(a_item, a_expected_errors, l_expected_error_names, l_expected_error_numbers ); + + self.do_execute(a_item, l_expected_error_names, l_expected_error_numbers); + l_all_expected_errors := l_expected_error_names multiset union all l_expected_error_numbers; + if l_all_expected_errors is not empty and self.ignored_exception_detected = 0 then + l_failure_message := get_exception_failure_message( l_all_expected_errors); - if l_expected_except_message is not null then + if l_failure_message is not null then ut_expectation_processor.add_expectation_result( - ut_expectation_result(ut_utils.gc_failure, null, l_expected_except_message, false) + ut_expectation_result(ut_utils.gc_failure, null, l_failure_message, false) ); end if; self.error_stack := null; diff --git a/source/core/types/ut_executable_test.tps b/source/core/types/ut_executable_test.tps index 76f2d1c7d..2f9a5f236 100644 --- a/source/core/types/ut_executable_test.tps +++ b/source/core/types/ut_executable_test.tps @@ -1,10 +1,10 @@ -create or replace type ut_executable_test authid current_user under ut_executable ( +create or replace noneditionable type ut_executable_test authid current_user under ut_executable ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -22,12 +22,12 @@ create or replace type ut_executable_test authid current_user under ut_executabl member procedure do_execute( self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_varchar2_rows + a_expected_errors in ut_varchar2_rows ), member function do_execute( self in out nocopy ut_executable_test, a_item in out nocopy ut_suite_item, - a_expected_error_codes in ut_varchar2_rows + a_expected_errors in ut_varchar2_rows ) return boolean ) final; diff --git a/source/core/types/ut_executables.tps b/source/core/types/ut_executables.tps index f5fbbdfad..fb08b287d 100644 --- a/source/core/types/ut_executables.tps +++ b/source/core/types/ut_executables.tps @@ -1,10 +1,10 @@ -create or replace type ut_executables as +create or replace noneditionable type ut_executables as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_expectation_result.tpb b/source/core/types/ut_expectation_result.tpb index cf445b705..b98853efc 100644 --- a/source/core/types/ut_expectation_result.tpb +++ b/source/core/types/ut_expectation_result.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_expectation_result is +create or replace noneditionable type body ut_expectation_result is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_expectation_result.tps b/source/core/types/ut_expectation_result.tps index 5a430fe64..5fc296bfe 100644 --- a/source/core/types/ut_expectation_result.tps +++ b/source/core/types/ut_expectation_result.tps @@ -1,10 +1,10 @@ -create or replace type ut_expectation_result under ut_event_item( +create or replace noneditionable type ut_expectation_result under ut_event_item( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_expectation_results.tps b/source/core/types/ut_expectation_results.tps index 50cc046ec..361bb8669 100644 --- a/source/core/types/ut_expectation_results.tps +++ b/source/core/types/ut_expectation_results.tps @@ -1,10 +1,10 @@ -create or replace type ut_expectation_results as +create or replace noneditionable type ut_expectation_results as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_file_mapping.tpb b/source/core/types/ut_file_mapping.tpb index 5b7133c56..4286bb171 100644 --- a/source/core/types/ut_file_mapping.tpb +++ b/source/core/types/ut_file_mapping.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_file_mapping as +create or replace noneditionable type body ut_file_mapping as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_file_mapping.tps b/source/core/types/ut_file_mapping.tps index 8fed2df00..bd048a218 100644 --- a/source/core/types/ut_file_mapping.tps +++ b/source/core/types/ut_file_mapping.tps @@ -1,10 +1,10 @@ -create or replace type ut_file_mapping as object( +create or replace noneditionable type ut_file_mapping as object( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_file_mappings.tps b/source/core/types/ut_file_mappings.tps index 0e1653969..8ad94d2ec 100644 --- a/source/core/types/ut_file_mappings.tps +++ b/source/core/types/ut_file_mappings.tps @@ -1,10 +1,10 @@ -create or replace type ut_file_mappings as +create or replace noneditionable type ut_file_mappings as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_integer_list.tps b/source/core/types/ut_integer_list.tps index 00bce87c4..86316e630 100644 --- a/source/core/types/ut_integer_list.tps +++ b/source/core/types/ut_integer_list.tps @@ -1,10 +1,10 @@ -create or replace type ut_integer_list as +create or replace noneditionable type ut_integer_list as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_key_value_pair.tps b/source/core/types/ut_key_value_pair.tps index 38dee5a7d..0082affd3 100644 --- a/source/core/types/ut_key_value_pair.tps +++ b/source/core/types/ut_key_value_pair.tps @@ -1,10 +1,10 @@ -create or replace type ut_key_value_pair force as object( +create or replace noneditionable type ut_key_value_pair force as object( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_key_value_pairs.tps b/source/core/types/ut_key_value_pairs.tps index 327986e19..4b76438d4 100644 --- a/source/core/types/ut_key_value_pairs.tps +++ b/source/core/types/ut_key_value_pairs.tps @@ -1,10 +1,10 @@ -create or replace type ut_key_value_pairs as +create or replace noneditionable type ut_key_value_pairs as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_logical_suite.tpb b/source/core/types/ut_logical_suite.tpb index ea9b42857..47a154399 100644 --- a/source/core/types/ut_logical_suite.tpb +++ b/source/core/types/ut_logical_suite.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_logical_suite as +create or replace noneditionable type body ut_logical_suite as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_logical_suite.tps b/source/core/types/ut_logical_suite.tps index ab2271e32..5993ee4f8 100644 --- a/source/core/types/ut_logical_suite.tps +++ b/source/core/types/ut_logical_suite.tps @@ -1,10 +1,10 @@ -create or replace type ut_logical_suite force under ut_suite_item ( +create or replace noneditionable type ut_logical_suite force under ut_suite_item ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_object_name.tpb b/source/core/types/ut_object_name.tpb index e39231b0f..ce5d3b052 100644 --- a/source/core/types/ut_object_name.tpb +++ b/source/core/types/ut_object_name.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_object_name as +create or replace noneditionable type body ut_object_name as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_object_name.tps b/source/core/types/ut_object_name.tps index dc4fe2bca..23ab1b161 100644 --- a/source/core/types/ut_object_name.tps +++ b/source/core/types/ut_object_name.tps @@ -1,10 +1,10 @@ -create or replace type ut_object_name as object ( +create or replace noneditionable type ut_object_name as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_object_names.tps b/source/core/types/ut_object_names.tps index 2b42cce21..10159fbbb 100644 --- a/source/core/types/ut_object_names.tps +++ b/source/core/types/ut_object_names.tps @@ -1,10 +1,10 @@ -create or replace type ut_object_names as +create or replace noneditionable type ut_object_names as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_output_reporter_base.tpb b/source/core/types/ut_output_reporter_base.tpb index fec4ebfab..4857036a6 100644 --- a/source/core/types/ut_output_reporter_base.tpb +++ b/source/core/types/ut_output_reporter_base.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_output_reporter_base is +create or replace noneditionable type body ut_output_reporter_base is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_output_reporter_base.tps b/source/core/types/ut_output_reporter_base.tps index f5827a97d..585069cf7 100644 --- a/source/core/types/ut_output_reporter_base.tps +++ b/source/core/types/ut_output_reporter_base.tps @@ -1,10 +1,10 @@ -create or replace type ut_output_reporter_base under ut_reporter_base( +create or replace noneditionable type ut_output_reporter_base under ut_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_path_item.tpb b/source/core/types/ut_path_item.tpb index 685178987..3d85c4e3e 100644 --- a/source/core/types/ut_path_item.tpb +++ b/source/core/types/ut_path_item.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_path_item as +create or replace noneditionable type body ut_path_item as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_path_item.tps b/source/core/types/ut_path_item.tps index 5946cacbf..e90cf6099 100644 --- a/source/core/types/ut_path_item.tps +++ b/source/core/types/ut_path_item.tps @@ -1,10 +1,10 @@ -create or replace type ut_path_item as object ( +create or replace noneditionable type ut_path_item as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_path_items.tps b/source/core/types/ut_path_items.tps index 7ae04e0b9..0cf12fa1a 100644 --- a/source/core/types/ut_path_items.tps +++ b/source/core/types/ut_path_items.tps @@ -1,10 +1,10 @@ -create or replace type ut_path_items as +create or replace noneditionable type ut_path_items as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_reporter_base.tpb b/source/core/types/ut_reporter_base.tpb index 445d9d351..5dca1db44 100644 --- a/source/core/types/ut_reporter_base.tpb +++ b/source/core/types/ut_reporter_base.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_reporter_base is +create or replace noneditionable type body ut_reporter_base is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_reporter_base.tps b/source/core/types/ut_reporter_base.tps index 9df353060..f90162791 100644 --- a/source/core/types/ut_reporter_base.tps +++ b/source/core/types/ut_reporter_base.tps @@ -1,10 +1,10 @@ -create or replace type ut_reporter_base under ut_event_listener ( +create or replace noneditionable type ut_reporter_base under ut_event_listener ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_reporter_info.tps b/source/core/types/ut_reporter_info.tps index 3491f7679..6f7219f7c 100644 --- a/source/core/types/ut_reporter_info.tps +++ b/source/core/types/ut_reporter_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_reporter_info as object ( +create or replace noneditionable type ut_reporter_info as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_reporters.tps b/source/core/types/ut_reporters.tps index ab6439dce..d47240e8b 100644 --- a/source/core/types/ut_reporters.tps +++ b/source/core/types/ut_reporters.tps @@ -1,10 +1,10 @@ -create or replace type ut_reporters as +create or replace noneditionable type ut_reporters as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_reporters_info.tps b/source/core/types/ut_reporters_info.tps index 3639f4c2c..b100789df 100644 --- a/source/core/types/ut_reporters_info.tps +++ b/source/core/types/ut_reporters_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_reporters_info as +create or replace noneditionable type ut_reporters_info as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_results_counter.tpb b/source/core/types/ut_results_counter.tpb index 87fd83cf9..64be5d5a4 100644 --- a/source/core/types/ut_results_counter.tpb +++ b/source/core/types/ut_results_counter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_results_counter as +create or replace noneditionable type body ut_results_counter as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_results_counter.tps b/source/core/types/ut_results_counter.tps index 62b3d9ffd..d53d37e21 100644 --- a/source/core/types/ut_results_counter.tps +++ b/source/core/types/ut_results_counter.tps @@ -1,10 +1,10 @@ -create or replace type ut_results_counter as object( +create or replace noneditionable type ut_results_counter as object( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_run.tpb b/source/core/types/ut_run.tpb index 0956be32d..85fa930e4 100644 --- a/source/core/types/ut_run.tpb +++ b/source/core/types/ut_run.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_run as +create or replace noneditionable type body ut_run as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -24,7 +24,8 @@ create or replace type body ut_run as a_test_file_mappings ut_file_mappings := null, a_client_character_set varchar2 := null, a_random_test_order_seed positive := null, - a_run_tags varchar2 := null + a_run_tags varchar2 := null, + a_support_info boolean := true ) return self as result is begin self.run_paths := a_run_paths; @@ -36,9 +37,15 @@ create or replace type body ut_run as self.results_count := ut_results_counter(); self.test_file_mappings := coalesce(a_test_file_mappings, ut_file_mappings()); self.coverage_options := a_coverage_options; + self.support_info_flag := ut_utils.boolean_to_int(coalesce(a_support_info, true)); return; end; + member function get_support_info_flag return boolean is + begin + return ut_utils.int_to_boolean(self.support_info_flag); + end; + overriding member procedure mark_as_skipped(self in out nocopy ut_run,a_skip_reason in varchar2) is begin null; diff --git a/source/core/types/ut_run.tps b/source/core/types/ut_run.tps index ef3631082..a3f0b69b8 100644 --- a/source/core/types/ut_run.tps +++ b/source/core/types/ut_run.tps @@ -1,10 +1,10 @@ -create or replace type ut_run under ut_suite_item ( +create or replace noneditionable type ut_run under ut_suite_item ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -26,6 +26,7 @@ create or replace type ut_run under ut_suite_item ( test_file_mappings ut_file_mappings, client_character_set varchar2(100), random_test_order_seed number(38,0), + support_info_flag integer(1), constructor function ut_run( self in out nocopy ut_run, a_items ut_suite_items := null, @@ -34,8 +35,10 @@ create or replace type ut_run under ut_suite_item ( a_test_file_mappings ut_file_mappings := null, a_client_character_set varchar2 := null, a_random_test_order_seed positive := null, - a_run_tags varchar2 := null + a_run_tags varchar2 := null, + a_support_info boolean := true ) return self as result, + member function get_support_info_flag return boolean, overriding member procedure mark_as_skipped(self in out nocopy ut_run,a_skip_reason in varchar2), overriding member function do_execute(self in out nocopy ut_run) return boolean, overriding member procedure set_rollback_type(self in out nocopy ut_run, a_rollback_type integer, a_force boolean := false), diff --git a/source/core/types/ut_run_info.tpb b/source/core/types/ut_run_info.tpb index 1370de3cc..509960b05 100644 --- a/source/core/types/ut_run_info.tpb +++ b/source/core/types/ut_run_info.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_run_info as +create or replace noneditionable type body ut_run_info as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -12,7 +12,7 @@ create or replace type body ut_run_info as Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions andTEST_GET_REPORTERS_LIST + See the License for the specific language governing permissions and limitations under the License. */ constructor function ut_run_info(self in out nocopy ut_run_info) return self as result is diff --git a/source/core/types/ut_run_info.tps b/source/core/types/ut_run_info.tps index df82c380d..b8ad8c55b 100644 --- a/source/core/types/ut_run_info.tps +++ b/source/core/types/ut_run_info.tps @@ -1,10 +1,10 @@ -create or replace type ut_run_info under ut_event_item ( +create or replace noneditionable type ut_run_info under ut_event_item ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_stack.tpb b/source/core/types/ut_stack.tpb index da0c371a6..40ba8982b 100644 --- a/source/core/types/ut_stack.tpb +++ b/source/core/types/ut_stack.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_stack as +create or replace noneditionable type body ut_stack as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_stack.tps b/source/core/types/ut_stack.tps index 5a5f90263..9356c4eb2 100644 --- a/source/core/types/ut_stack.tps +++ b/source/core/types/ut_stack.tps @@ -1,12 +1,12 @@ -create or replace type ut_stack as object ( +create or replace noneditionable type ut_stack as object ( top integer, tokens ut_varchar2_list, /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite.tpb b/source/core/types/ut_suite.tpb index 9558565ed..7012dee97 100644 --- a/source/core/types/ut_suite.tpb +++ b/source/core/types/ut_suite.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_suite as +create or replace noneditionable type body ut_suite as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite.tps b/source/core/types/ut_suite.tps index 199e05ea4..3ed0def80 100644 --- a/source/core/types/ut_suite.tps +++ b/source/core/types/ut_suite.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite under ut_logical_suite ( +create or replace noneditionable type ut_suite under ut_logical_suite ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_cache_row.tps b/source/core/types/ut_suite_cache_row.tps index f294b3697..2293f9273 100644 --- a/source/core/types/ut_suite_cache_row.tps +++ b/source/core/types/ut_suite_cache_row.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_cache_row as object ( +create or replace noneditionable type ut_suite_cache_row as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_cache_rows.tps b/source/core/types/ut_suite_cache_rows.tps index c69c8672f..cb3b573eb 100644 --- a/source/core/types/ut_suite_cache_rows.tps +++ b/source/core/types/ut_suite_cache_rows.tps @@ -1,10 +1,10 @@ -create type ut_suite_cache_rows as +create or replace noneditionable type ut_suite_cache_rows as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_context.tpb b/source/core/types/ut_suite_context.tpb index 52e57924a..9221cb160 100644 --- a/source/core/types/ut_suite_context.tpb +++ b/source/core/types/ut_suite_context.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_suite_context as +create or replace noneditionable type body ut_suite_context as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_context.tps b/source/core/types/ut_suite_context.tps index 51d318235..a60899f9b 100644 --- a/source/core/types/ut_suite_context.tps +++ b/source/core/types/ut_suite_context.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_context under ut_suite ( +create or replace noneditionable type ut_suite_context under ut_suite ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_item.tpb b/source/core/types/ut_suite_item.tpb index 965d2416e..01b9b0ee0 100644 --- a/source/core/types/ut_suite_item.tpb +++ b/source/core/types/ut_suite_item.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_suite_item as +create or replace noneditionable type body ut_suite_item as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_item.tps b/source/core/types/ut_suite_item.tps index 8ba3c6183..556ff7f0b 100644 --- a/source/core/types/ut_suite_item.tps +++ b/source/core/types/ut_suite_item.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_item force under ut_event_item ( +create or replace noneditionable type ut_suite_item force under ut_event_item ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_suite_items.tps b/source/core/types/ut_suite_items.tps index ee3466c5d..fe11b732a 100644 --- a/source/core/types/ut_suite_items.tps +++ b/source/core/types/ut_suite_items.tps @@ -1,10 +1,10 @@ -create or replace type ut_suite_items as +create or replace noneditionable type ut_suite_items as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_test.tpb b/source/core/types/ut_test.tpb index 21ca44713..c3577274c 100644 --- a/source/core/types/ut_test.tpb +++ b/source/core/types/ut_test.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_test as +create or replace noneditionable type body ut_test as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_test.tps b/source/core/types/ut_test.tps index 215e3e9d6..7590abc35 100644 --- a/source/core/types/ut_test.tps +++ b/source/core/types/ut_test.tps @@ -1,10 +1,10 @@ -create or replace type ut_test force under ut_suite_item ( +create or replace noneditionable type ut_test force under ut_suite_item ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_varchar2_list.tps b/source/core/types/ut_varchar2_list.tps index 95a5545a8..86c26d4de 100644 --- a/source/core/types/ut_varchar2_list.tps +++ b/source/core/types/ut_varchar2_list.tps @@ -1,10 +1,10 @@ -create or replace type ut_varchar2_list as +create or replace noneditionable type ut_varchar2_list as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/types/ut_varchar2_rows.tps b/source/core/types/ut_varchar2_rows.tps index c6f05df86..f34f990e6 100644 --- a/source/core/types/ut_varchar2_rows.tps +++ b/source/core/types/ut_varchar2_rows.tps @@ -1,10 +1,10 @@ -create or replace type ut_varchar2_rows as +create or replace noneditionable type ut_varchar2_rows as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_dbms_output_cache.sql b/source/core/ut_dbms_output_cache.sql index 802f30942..344afc7aa 100644 --- a/source/core/ut_dbms_output_cache.sql +++ b/source/core/ut_dbms_output_cache.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/ut_expectation_processor.pkb b/source/core/ut_expectation_processor.pkb index 654a838ca..e95576d8e 100644 --- a/source/core/ut_expectation_processor.pkb +++ b/source/core/ut_expectation_processor.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_expectation_processor as +create or replace noneditionable package body ut_expectation_processor as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -149,14 +149,15 @@ create or replace package body ut_expectation_processor as end; function who_called_expectation(a_call_stack varchar2) return varchar2 is - l_caller_stack_line varchar2(4000); - l_call_stack varchar2(4000); + c_max_source_line_len constant integer := 500; + l_caller_stack_line varchar2(32767); + l_call_stack varchar2(32767); l_line_no integer; l_owner varchar2(1000); l_object_name varchar2(1000); - l_result varchar2(4000); - -- in 12.2 format_call_stack reportes not only package name, but also the procedure name - -- when 11g and 12c reports only package name + l_source_line varchar2(32767); + l_result varchar2(32767); + -- format_call_stack reports not only package name, but also the procedure name function cut_header_and_expectations( a_stack varchar2 ) return varchar2 is begin return regexp_substr( a_stack, '(.*\.(UT_EQUAL|UT_BE_WITHIN[[:alnum:]$#_]*|UT_EXPECTATION[[:alnum:]$#_]*|UT|UTASSERT2?)(\.[[:alnum:]$#_]+)?\s+)+((.|\s)*)', 1, 1, 'm', 4); @@ -192,13 +193,21 @@ create or replace package body ut_expectation_processor as l_line_no := to_number( regexp_substr( l_caller_stack_line, ', line (\d+)', subexpression => 1 ) ); l_owner := regexp_substr( l_caller_stack_line, 'at "([[:alnum:]$#_]+)\.(([[:alnum:]$#_]+)(\.([[:alnum:]$#_]+))?)", line (\d+)', subexpression => 1 ); l_object_name := regexp_substr( l_caller_stack_line, 'at "([[:alnum:]$#_]+)\.(([[:alnum:]$#_]+)(\.([[:alnum:]$#_]+))?)", line (\d+)', subexpression => 3 ); + l_source_line := rtrim(ut_metadata.get_source_definition_line(l_owner, l_object_name, l_line_no),chr(10)); + if length( l_source_line ) > c_max_source_line_len then + l_source_line := substr( l_source_line, 1, c_max_source_line_len - ut_utils.gc_more_data_string_len ) || ut_utils.gc_more_data_string; + end if; l_result := - l_caller_stack_line || ' ' || rtrim(ut_metadata.get_source_definition_line(l_owner, l_object_name, l_line_no),chr(10)) + l_caller_stack_line || ' ' || l_source_line || replace( l_call_stack, l_caller_stack_line ); else l_result := l_call_stack; end if; - return rtrim(l_result,chr(10)); + l_result := rtrim(l_result,chr(10)); + if lengthb( l_result ) > ut_utils.gc_max_storage_varchar2_len then + l_result := substrb( l_result, 1, ut_utils.gc_max_storage_varchar2_len - ut_utils.gc_more_data_string_len ) || ut_utils.gc_more_data_string; + end if; + return l_result; end; procedure add_warning(a_messsage varchar2) is diff --git a/source/core/ut_expectation_processor.pks b/source/core/ut_expectation_processor.pks index 1837188eb..8d19becce 100644 --- a/source/core/ut_expectation_processor.pks +++ b/source/core/ut_expectation_processor.pks @@ -1,10 +1,10 @@ -create or replace package ut_expectation_processor authid current_user as +create or replace noneditionable package ut_expectation_processor authid current_user as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_file_mapper.pkb b/source/core/ut_file_mapper.pkb index 077319d76..8cb3f3911 100644 --- a/source/core/ut_file_mapper.pkb +++ b/source/core/ut_file_mapper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_file_mapper is +create or replace noneditionable package body ut_file_mapper is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_file_mapper.pks b/source/core/ut_file_mapper.pks index 71e045d7e..e1ce48a54 100644 --- a/source/core/ut_file_mapper.pks +++ b/source/core/ut_file_mapper.pks @@ -1,10 +1,10 @@ -create or replace package ut_file_mapper authid current_user is +create or replace noneditionable package ut_file_mapper authid current_user is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_metadata.pkb b/source/core/ut_metadata.pkb index aec9a3c8d..ed8391638 100644 --- a/source/core/ut_metadata.pkb +++ b/source/core/ut_metadata.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_metadata as +create or replace noneditionable package body ut_metadata as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -77,13 +77,24 @@ create or replace package body ut_metadata as if not nvl(c_key = g_cached_object, false) then g_cached_object := c_key; execute immediate - 'select /*+ no_parallel */ trim(text) text - from '||l_view_name||q'[ s - where s.owner = :a_owner - and s.name = :a_object_name - /*skip the declarations, consider only definitions*/ - and s.type not in ('PACKAGE', 'TYPE') - order by line]' + 'with + all_source_filter as ( + select /*+ no_parallel */ + lag( + case when substr(text, -1) = chr(10) then 1 else 0 end + , 1 + ) over (partition by owner, name, type order by line) prev_line_end, + line, text + from '||l_view_name||q'[ a + where a.owner = :a_owner + and a.name = :a_object_name + /*skip the declarations, consider only definitions*/ + and a.type not in ('PACKAGE', 'TYPE') + ) + select trim(s.text) + from all_source_filter s + where nvl(s.prev_line_end, 1) > 0 + order by s.line]' bulk collect into g_source_cache using a_owner, a_object_name; end if; diff --git a/source/core/ut_metadata.pks b/source/core/ut_metadata.pks index 31cf4889b..f320e7bf8 100644 --- a/source/core/ut_metadata.pks +++ b/source/core/ut_metadata.pks @@ -1,10 +1,10 @@ -create or replace package ut_metadata authid current_user as +create or replace noneditionable package ut_metadata authid current_user as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_savepoint_seq.sql b/source/core/ut_savepoint_seq.sql index 2026ab0e3..393c2419a 100644 --- a/source/core/ut_savepoint_seq.sql +++ b/source/core/ut_savepoint_seq.sql @@ -2,8 +2,8 @@ create sequence ut_savepoint_seq /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/ut_suite_builder.pkb b/source/core/ut_suite_builder.pkb index 2ebdb980c..0c9bbc982 100644 --- a/source/core/ut_suite_builder.pkb +++ b/source/core/ut_suite_builder.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_suite_builder is +create or replace noneditionable package body ut_suite_builder is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -754,7 +754,7 @@ create or replace package body ut_suite_builder is l_used_context_names(l_context_name) := true; l_context := ut_suite_context(a_parent.object_owner, a_parent.object_name, l_context_name, l_context_pos ); - l_context.path := a_parent.path||'.'||l_context_name; + l_context.path := a_parent.path||'.'||l_context.name; l_context.description := coalesce( a_annotations.by_line( l_context_pos ).text, l_context_name ); l_context.parse_time := a_annotations.parse_time; diff --git a/source/core/ut_suite_builder.pks b/source/core/ut_suite_builder.pks index 7e43a720e..31b76e2c6 100644 --- a/source/core/ut_suite_builder.pks +++ b/source/core/ut_suite_builder.pks @@ -1,10 +1,10 @@ -create or replace package ut_suite_builder authid current_user is +create or replace noneditionable package ut_suite_builder authid current_user is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_suite_cache.sql b/source/core/ut_suite_cache.sql index 1d7389e9f..296851a10 100644 --- a/source/core/ut_suite_cache.sql +++ b/source/core/ut_suite_cache.sql @@ -2,8 +2,8 @@ create table ut_suite_cache /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/ut_suite_cache_macros.pkb b/source/core/ut_suite_cache_macros.pkb new file mode 100644 index 000000000..735b81830 --- /dev/null +++ b/source/core/ut_suite_cache_macros.pkb @@ -0,0 +1,46 @@ +create or replace noneditionable package body ut_suite_cache_macros as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + function match_paths(a_items dbms_tf.table_t, a_paths dbms_tf.table_t) return varchar2 sql_macro is + begin + --names: "_" is not a wildcard, "*" is; suitepath patterns: "." and "$" are literal, "*" matches part of a path element + return q'[ + select p.path_id, i.object_owner, i.path + from a_items i + join a_paths p + on i.object_owner = upper(p.schema_name) + where ( p.suite_path is null and p.object_name is null ) + or ( p.suite_path is null + and i.object_name like replace(replace(upper(p.object_name), '_', '\_'), '*', '%') escape '\' + and ( p.procedure_name is null or p.procedure_name = '*' + or i.name like replace(replace(upper(p.procedure_name), '_', '\_'), '*', '%') escape '\' + ) + ) + or ( instr(p.suite_path, '*') = 0 + and ( i.path = p.suite_path or substr(i.path, 1, length(p.suite_path) + 1) = p.suite_path || '.' ) + ) + or ( instr(p.suite_path, '*') > 0 + and regexp_like( + i.path, + '^' || replace(replace(replace(p.suite_path, '.', '\.'), '$', '\$'), '*', '[[:alnum:]$#_]*') + ) + )]'; + end; + +end; +/ diff --git a/source/core/ut_suite_cache_macros.pks b/source/core/ut_suite_cache_macros.pks new file mode 100644 index 000000000..2554ccba2 --- /dev/null +++ b/source/core/ut_suite_cache_macros.pks @@ -0,0 +1,43 @@ +create or replace noneditionable package ut_suite_cache_macros authid definer as + /* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + /* + * SQL macros for ut_suite_cache_manager. + * + * A package containing SQL macros cannot be an invoker rights package, so the macros are kept apart from ut_suite_cache_manager. + * A macro only returns SQL text, which is expanded into the calling SQL statement. + * A macro body sees the values of literal arguments only, so the returned text does not depend on argument values. + */ + + /** + * Table SQL macro matching suite items with run paths: the single definition of which items a run path selects. + * Returns one row (path_id, object_owner, path) for every pair of a path and an item it selects: + * - schema: all items of the schema + * - schema.package[.*]: all items of the package + * - schema.package.procedure: the items named like the procedure + * - schema:suite.path: the item at the suitepath and all items below it + * - schema:suite*.path: the items whose path starts with a match of the suitepath pattern + * Package and procedure names may contain wildcards (*). Parents of the selected items are not returned. + * + * @param a_items table or query with columns object_owner, object_name, name, path (as in ut_suite_cache), without collection columns + * @param a_paths table or query with columns path_id and the columns of ut_path_item + */ + function match_paths(a_items dbms_tf.table_t, a_paths dbms_tf.table_t) return varchar2 sql_macro; + +end; +/ diff --git a/source/core/ut_suite_cache_manager.pkb b/source/core/ut_suite_cache_manager.pkb index fb7c2c888..a3ff6edfd 100644 --- a/source/core/ut_suite_cache_manager.pkb +++ b/source/core/ut_suite_cache_manager.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_suite_cache_manager is +create or replace noneditionable package body ut_suite_cache_manager is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -17,77 +17,10 @@ create or replace package body ut_suite_cache_manager is */ /* - * Private code + * Public code */ - cursor c_get_bulk_cache_suite(cp_suite_items in ut_suite_cache_rows) is - with - suite_items as ( - select /*+ cardinality(c 500) */ value(c) as obj - from table(cp_suite_items) c), - suitepaths as ( - select distinct substr(c.obj.path,1,instr(c.obj.path,'.',-1)-1) as suitepath, - c.obj.path as path, - c.obj.object_owner as object_owner - from suite_items c - where c.obj.self_type = 'UT_SUITE' - ), - gen as ( - select rownum as pos - from xmltable('1 to 20') - ), - suitepath_part AS ( - select distinct - substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path, - object_owner - from suitepaths b - join gen g - on g.pos <= regexp_count(b.suitepath, '\w+') - ), - logical_suite_data as ( - select 'UT_LOGICAL_SUITE' as self_type, p.path, p.object_owner, - upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name, - cast(null as ut_executables) as x, - cast(null as ut_varchar2_rows) as y, - cast(null as ut_executable_test) as z - from suitepath_part p - where p.path - not in (select s.path from suitepaths s) - ), - logical_suites as ( - select ut_suite_cache_row( - null, - s.self_type, s.path, s.object_owner, s.object_name, - s.object_name, null, null, null, null, 0,null, - ut_varchar2_rows(), - s.x, s.x, s.x, s.x, s.x, s.x, - s.y, null, s.z - ) as obj - from logical_suite_data s - ) - select /*+ no_parallel */ obj from suite_items - union all - select /*+ no_parallel */ obj from logical_suites; - function get_missing_cache_objects(a_object_owner varchar2) return ut_varchar2_rows is - l_result ut_varchar2_rows; - l_data ut_annotation_objs_cache_info; - begin - l_data := ut_annotation_cache_manager.get_cached_objects_list(a_object_owner, 'PACKAGE'); - - select /*+ no_parallel */ i.object_name - bulk collect into l_result - from ut_suite_cache_package i - where not exists ( - select 1 from table(l_data) o - where o.object_owner = i.object_owner - and o.object_name = i.object_name - and o.object_type = 'PACKAGE' - ) - and i.object_owner = a_object_owner; - return l_result; - end; - - function group_paths_by_schema(a_paths ut_varchar2_list) return ut_path_items is + function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items is c_package_path_regex constant varchar2(100) := '^([[:alnum:]$#_]+)(\.([[:alnum:]$#_\*]+))?(\.([[:alnum:]$#_\*]+))?$'; l_results ut_path_items := ut_path_items(); l_path_item ut_path_item; @@ -113,184 +46,234 @@ create or replace package body ut_suite_cache_manager is end; /* - First SQL queries for objects where procedure is null or its only wildcard. - We split that due to fact that we can use func min to combine rows. - - Second union is responsible expanding paths where the procedure filter is given - We cannot select min here as filter can cover only half of tests within - package. Even if the filter doesnt return anything we still capture a proc filter - name for error reporting later on. - - Third SQL cover scenario where a suitapath only is populated and wildcard is given - - Fourth SQL cover scenario where suitepath is populated with no filters - */ - function expand_paths(a_schema_paths ut_path_items) return ut_path_items is - l_schema_paths ut_path_items:= ut_path_items(); - begin - with - schema_paths as ( - select * from table(a_schema_paths) - ), - paths_for_object as ( - select /*+ no_parallel */ min(path) as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name, - null as procedure_name - from schema_paths sp left outer join ut_suite_cache c - on ( c.object_owner = upper(sp.schema_name) - and c.object_name like replace(upper(sp.object_name),'*','%')) - where sp.suite_path is null and sp.object_name is not null - and ( sp.procedure_name is null or sp.procedure_name = '*') - group by sp.schema_name,nvl(c.object_name,sp.object_name) - ), - paths_for_procedures as ( - select /*+ no_parallel */ path as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name, - nvl(c.name,sp.procedure_name) as procedure_name - from schema_paths sp left outer join ut_suite_cache c - on ( c.object_owner = upper(sp.schema_name) - and c.object_name like replace(upper(sp.object_name),'*','%') - and c.name like nvl(replace(upper(sp.procedure_name),'*','%'), c.name)) - where sp.suite_path is null and sp.object_name is not null - and (sp.procedure_name is not null and sp.procedure_name != '*') - ), - paths_for_suite_path_with_ast as ( - select /*+ no_parallel */ nvl(c.path,sp.suite_path) as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name - from schema_paths sp left outer join ut_suite_cache c on - ( c.object_owner = upper(sp.schema_name) - --and c.path like replace(sp.suite_path,'*','%')) - and regexp_like(c.path,'^'||replace(sp.suite_path,'*','[[:alnum:]$#_]*'))) - where sp.suite_path is not null and instr(sp.suite_path,'*') > 0 - ), - straigth_suite_paths as ( - select /*+ no_parallel */ sp.suite_path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name - from schema_paths sp - where - (sp.suite_path is not null and instr(sp.suite_path,'*') = 0) - or - (sp.suite_path is null and sp.object_name is null) - ), - all_suitepaths_together as ( - select * from paths_for_object - union all - select * from paths_for_procedures - union all - select * from paths_for_suite_path_with_ast - union all - select * from straigth_suite_paths - ) - select ut_path_item(schema_name,object_name,procedure_name,suite_path) - bulk collect into l_schema_paths - from - (select schema_name,object_name,procedure_name,suite_path, - row_number() over ( partition by schema_name,object_name,procedure_name,suite_path order by 1) as r_num - from all_suitepaths_together) - where r_num = 1 ; - return l_schema_paths; - end; - - /* - Get a suite items rows that matching our criteria like - path,object_name etc. - We need to consider also an wildcard character on our procedures and object - names. - Were the path is populated we need to make sure we dont return duplicates - as the wildcard can produce multiple results from same path and - parents and child for each can be same resulting in duplicates - */ - function get_suite_items ( - a_schema_paths ut_path_items - ) return ut_suite_cache_rows is - l_suite_items ut_suite_cache_rows := ut_suite_cache_rows(); + Returns ids of the cache rows the paths select (wildcards included, see ut_suite_cache_macros.match_paths) + and of their parents, only for packages the invoking user can access, unless a_skip_access_check is true. + A separate statement, as a SQL macro cannot be used inside a WITH clause (ORA-64630). + */ + function get_matched_ids( + a_schema_paths ut_path_items, + a_skip_access_check boolean + ) return ut_integer_list is + l_results ut_integer_list; + l_skip_access_check varchar2(1) := case when a_skip_access_check then 'Y' else 'N' end; begin - select obj bulk collect into l_suite_items - from ( - select /*+ cardinality(c 500) */ value(c) as obj,row_number() over ( partition by path,object_owner order by path,object_owner asc) as r_num - from ut_suite_cache c, - table(a_schema_paths) sp - where c.object_owner = upper(sp.schema_name) - and ((sp.suite_path is not null and sp.suite_path||'.' like c.path||'.%' /*all parents and self*/ - or - ( - c.path||'.' like sp.suite_path||'.%' /*all children and self*/ - and c.object_name like nvl(upper(sp.object_name),c.object_name) - and c.name like nvl(upper(sp.procedure_name),c.name) - )) - or - ( sp.suite_path is null - and c.object_name = nvl(upper(sp.object_name),c.object_name) - and c.name = nvl(upper(sp.procedure_name),c.name)))) where r_num =1; - return l_suite_items; + --all_objects is used only in the main query: in a WITH clause of a statement with a SQL macro it raises ORA-00942 + with + path_items as ( + select rownum as path_id, sp.schema_name, sp.object_name, sp.procedure_name, sp.suite_path + from table(a_schema_paths) sp + ), + schema_items as ( + --only scalar columns: a table argument of a SQL macro cannot have collection columns (ORA-62558) + select /*+ no_parallel */ c.id, c.object_owner, c.object_name, c.name, c.path + from &&ut3_owner..ut_suite_cache c + where c.object_owner in (select upper(p.schema_name) from path_items p) + ) + select /*+ no_parallel */ distinct r.id + bulk collect into l_results + from (&&ut3_owner..ut_suite_cache_macros.match_paths(schema_items, path_items)) m + join schema_items s + on s.object_owner = m.object_owner + and s.path = m.path + join schema_items r + on r.object_owner = s.object_owner + and ( r.path = s.path or substr(s.path, 1, length(r.path) + 1) = r.path || '.' /* the selected row or its parent */ ) + where l_skip_access_check = 'Y' + or ( exists ( select 1 from all_objects a where a.owner = s.object_owner and a.object_name = s.object_name and a.object_type = 'PACKAGE' ) + and exists ( select 1 from all_objects a where a.owner = r.object_owner and a.object_name = r.object_name and a.object_type = 'PACKAGE' ) + ); + return l_results; end; - + /* - We will sort a suites in hierarchical structure. - Sorting from bottom to top so when we consolidate - we will go in proper order. - For random seed we will add an extra sort that can be null. - The object owner is irrelevant on joing via path as we already - resolved a list of test we want to use so as long they share a suitepath - they are correct. + Returns suite items for the paths, sorted bottom up, so that reconstruct_from_cache in ut_suite_manager + can build the suite hierarchy in a single pass. The statement: + - matched_rows: the rows from get_matched_ids + - tagged_rows: when tags are given, the rows having a test matching the tag expression below them (or being one); + a test inherits the tags of the suites and contexts above it + - logical_suites: suites for the parts of the suitepaths that have no package behind them, + or whose package the user can't access (with a warning in that case) + - ordered: the hierarchy sorted depth first by schema, then by line number, or by a hash of the path when a_random_seed is given + The tag expression is evaluated per test by ut_suite_tag_filter.is_matching, so the statement is static SQL. + Without a_with_executables, the rows have no executables (before/after lists, test item), which only a run needs. */ - procedure sort_and_randomize_tests( - a_suite_rows in out ut_suite_cache_rows, - a_random_seed positive := null) - is - l_suite_rows ut_suite_cache_rows; + function select_suite_rows( + a_schema_paths ut_path_items, + a_skip_access_check boolean, + a_tags varchar2, + a_random_seed positive, + a_with_executables boolean + ) return ut_suite_cache_rows is + l_results ut_suite_cache_rows; + l_matched_ids ut_integer_list := get_matched_ids(a_schema_paths, a_skip_access_check); + l_with_executables varchar2(1) := case when a_with_executables then 'Y' else 'N' end; + --an expression of spaces and tabs only is no tag filter + l_tags varchar2(32767) := ut_suite_tag_filter.remove_whitespace(a_tags); begin with - extract_parent_child as ( - select s.path, substr(s.path,1,instr(s.path,'.',-1,1)-1) as parent_path,s.object_owner, - case when a_random_seed is null then s.line_no end line_no, - case when a_random_seed is not null then ut_utils.hash_suite_path(s.path, a_random_seed) end random_seed - from table(a_suite_rows) s), - t1(path,parent_path,object_owner,line_no,random_seed) as ( - --Anchor member - select s.path, parent_path,s.object_owner,s.line_no,random_seed - from extract_parent_child s - where parent_path is null + matched_rows as ( + select /*+ no_parallel */ c.id, c.self_type, c.path, c.object_owner, c.object_name, c.line_no, c.tags + from &&ut3_owner..ut_suite_cache c + where c.id in (select m.column_value from table(l_matched_ids) m) + ), + propagate_tags_from_ancestors as ( + select c.id, c.self_type, c.path, c.object_owner, listagg(distinct c_tags.tag, ',') within group (order by c_tags.tag) as tags + from matched_rows c + left join matched_rows t + on t.self_type in ('UT_SUITE','UT_SUITE_CONTEXT') + and c.path like t.path||'.%' /* all descendants */ + and c.object_owner = t.object_owner + outer apply (select column_value tag from table(c.tags) union select column_value tag from table(t.tags) ) c_tags + where c.self_type = 'UT_TEST' + group by c.id, c.self_type, c.path, c.object_owner + ), + filter_by_tags as ( + select x.path, x.object_owner + from propagate_tags_from_ancestors x + where &&ut3_owner..ut_suite_tag_filter.is_matching(x.tags, l_tags) = 1 + ), + tagged_rows as ( + select /*+ no_expand */ item.* + from matched_rows item + where l_tags is null + or exists ( + select 1 + from filter_by_tags tst + where tst.path||'.' like item.path || '.%' /* all descendants and self */ + and tst.object_owner = item.object_owner + ) + ), + suitepaths as ( + select distinct substr(c.path,1,instr(c.path,'.',-1)-1) as suitepath, c.path, c.object_owner + from tagged_rows c + where c.self_type = 'UT_SUITE' + ), + gen as ( + --not xmltable('1 to 20'): together with the recursive "ordered" below it makes the parse hang or fail with ORA-07445 [qmxtrProcCorrOpn] on 19.20 + select level as pos from dual connect by level <= 20 + ), + suitepath_part as ( + select distinct substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path, b.object_owner + from suitepaths b + join gen g + on g.pos <= regexp_count(b.suitepath, '\w+') + ), + logical_suites as ( + select p.path, p.object_owner, upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name + from suitepath_part p + where p.path not in (select s.path from suitepaths s) + ), + all_items as ( + select t.id, t.path, t.object_owner, t.object_name, t.line_no + from tagged_rows t union all - --Recursive member - select t2.path, t2.parent_path,t2.object_owner,t2.line_no,t2.random_seed - from t1,extract_parent_child t2 - where t2.parent_path = t1.path - and t2.object_owner = t1.object_owner) - search depth first by line_no desc,random_seed desc nulls last set order1 - select value(i) as obj - bulk collect into l_suite_rows - from t1 c - join table(a_suite_rows) i on i.object_owner = c.object_owner and i.path = c.path - order by order1 desc; - - a_suite_rows := l_suite_rows; + select null as id, l.path, l.object_owner, l.object_name, null as line_no + from logical_suites l + ), + items_for_sort as ( + select a.id, a.path, substr(a.path,1,instr(a.path,'.',-1,1)-1) as parent_path, a.object_owner, a.object_name, + case when a_random_seed is null then a.line_no end as line_no, + case when a_random_seed is not null then &&ut3_owner..ut_utils.hash_suite_path(a.path, a_random_seed) end as random_seed + from all_items a + ), + ordered(id, path, parent_path, object_owner, object_name, line_no, random_seed) as ( + select s.id, s.path, s.parent_path, s.object_owner, s.object_name, s.line_no, s.random_seed + from items_for_sort s + where s.parent_path is null + union all + select s.id, s.path, s.parent_path, s.object_owner, s.object_name, s.line_no, s.random_seed + from ordered o + join items_for_sort s + on s.parent_path = o.path + and s.object_owner = o.object_owner + ) + --object_owner first: a run can span several schemas, so top level items are grouped by schema + --(below the top level all items of a subtree have the same owner) + --path: siblings with the same line number (packages, logical suites) keep the order of their paths + search depth first by object_owner, line_no desc, random_seed desc nulls last, path set order1 + select /*+ no_parallel */ + case + when o.id is not null and l_with_executables = 'Y' then value(c) + when o.id is not null then + --without the executables, which only a run needs + &&ut3_owner..ut_suite_cache_row( + c.id, c.self_type, c.path, c.object_owner, c.object_name, c.name, + c.line_no, c.parse_time, c.description, c.rollback_type, c.disabled_flag, c.disabled_reason, + null, + null, null, null, null, null, null, + null, c.tags, null + ) + else &&ut3_owner..ut_suite_cache_row( + null, 'UT_LOGICAL_SUITE', o.path, o.object_owner, o.object_name, o.object_name, + null, null, null, null, 0, null, + case + when h.id is null then &&ut3_owner..ut_varchar2_rows() + else &&ut3_owner..ut_varchar2_rows( + 'Suite ' || lower(h.object_owner || '.' || h.object_name) + || ' is not run, as it does not exist or you have no EXECUTE privilege on it.' + || ' Its beforeall/afterall, rollback setting and tags are not applied to the suites below it.' + ) + end, + null, null, null, null, null, null, + null, null, null + ) + end + bulk collect into l_results + from ordered o + left join &&ut3_owner..ut_suite_cache c + on c.id = o.id + --a package suite that get_matched_ids left out as not accessible, replaced by a logical suite + left join &&ut3_owner..ut_suite_cache h + on o.id is null + and h.object_owner = o.object_owner + and h.path = o.path + and h.self_type = 'UT_SUITE' + order by o.order1 desc; + + return l_results; end; - - /* - * Public code - */ - - function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items is + + function get_suite_rows( + a_schema_paths ut_path_items, + a_skip_access_check boolean, + a_tags varchar2 := null, + a_random_seed positive := null + ) return ut_suite_cache_rows is begin - return expand_paths(group_paths_by_schema(a_paths)); + return select_suite_rows(a_schema_paths, a_skip_access_check, a_tags, a_random_seed, a_with_executables => true); end; - - function get_cached_suite_rows( - a_suites_filtered ut_suite_cache_rows - ) return ut_suite_cache_rows is - l_results ut_suite_cache_rows := ut_suite_cache_rows(); - begin - open c_get_bulk_cache_suite(a_suites_filtered); - fetch c_get_bulk_cache_suite bulk collect into l_results; - close c_get_bulk_cache_suite; - - return l_results; + function get_suite_items_info( + a_suite_cache_items ut_suite_cache_rows + ) return ut_suite_items_info is + l_results ut_suite_items_info; + begin + select /*+ no_parallel */ &&ut3_owner..ut_suite_item_info( + c.object_owner, c.object_name, c.name, + c.description, c.self_type, c.line_no, + c.path, c.disabled_flag, c.disabled_reason, c.tags + ) + bulk collect into l_results + from table(a_suite_cache_items) c; + return l_results; end; - + + function get_suites_info( + a_schema_paths ut_path_items, + a_skip_access_check boolean + ) return ut_suite_items_info is + begin + return get_suite_items_info( + select_suite_rows(a_schema_paths, a_skip_access_check, a_tags => null, a_random_seed => null, a_with_executables => false) + ); + end; + function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache is l_cache_parse_time timestamp; begin select /*+ no_parallel */ min(t.parse_time) into l_cache_parse_time - from ut_suite_cache_schema t + from &&ut3_owner..ut_suite_cache_schema t where object_owner = upper(a_schema_name); return l_cache_parse_time; end; @@ -308,11 +291,8 @@ create or replace package body ut_suite_cache_manager is begin if a_suite_items is null or a_suite_items.count = 0 then - delete from ut_suite_cache t - where t.object_owner = l_object_owner - and t.object_name = l_object_name; - - delete from ut_suite_cache_package t + --rows of ut_suite_cache are removed by the "on delete cascade" foreign key + delete from &&ut3_owner..ut_suite_cache_package t where t.object_owner = l_object_owner and t.object_name = l_object_name; @@ -320,38 +300,38 @@ create or replace package body ut_suite_cache_manager is select /*+ no_parallel */ min(parse_time) into l_cached_parse_time - from ut_suite_cache_package t + from &&ut3_owner..ut_suite_cache_package t where t.object_name = l_object_name and t.object_owner = l_object_owner; if a_parse_time > l_cached_parse_time or l_cached_parse_time is null then - update /*+ no_parallel */ ut_suite_cache_schema t + update /*+ no_parallel */ &&ut3_owner..ut_suite_cache_schema t set t.parse_time = greatest(t.parse_time,a_parse_time) where object_owner = l_object_owner; if sql%rowcount = 0 then - insert /*+ no_parallel */ into ut_suite_cache_schema + insert /*+ no_parallel */ into &&ut3_owner..ut_suite_cache_schema (object_owner, parse_time) values (l_object_owner, a_parse_time); end if; - update /*+ no_parallel */ ut_suite_cache_package t + update /*+ no_parallel */ &&ut3_owner..ut_suite_cache_package t set t.parse_time = a_parse_time where t.object_owner = l_object_owner and t.object_name = l_object_name; if sql%rowcount = 0 then - insert /*+ no_parallel */ into ut_suite_cache_package + insert /*+ no_parallel */ into &&ut3_owner..ut_suite_cache_package (object_owner, object_name, parse_time) values (l_object_owner, l_object_name, a_parse_time ); end if; - delete from ut_suite_cache t + delete from &&ut3_owner..ut_suite_cache t where t.object_owner = l_object_owner and t.object_name = l_object_name; - insert /*+ no_parallel */ into ut_suite_cache t + insert /*+ no_parallel */ into &&ut3_owner..ut_suite_cache t ( id, self_type, path, object_owner, object_name, name, line_no, parse_time, description, @@ -363,10 +343,10 @@ create or replace package body ut_suite_cache_manager is item ) with suites as ( - select treat(value(x) as ut_suite) i + select treat(value(x) as &&ut3_owner..ut_suite) i from table(a_suite_items) x where x.self_type in( 'UT_SUITE', 'UT_SUITE_CONTEXT' ) ) - select /*+ no_parallel */ ut_suite_cache_seq.nextval, s.i.self_type as self_type, s.i.path as path, + select /*+ no_parallel */ &&ut3_owner..ut_suite_cache_seq.nextval, s.i.self_type as self_type, s.i.path as path, upper(s.i.object_owner) as object_owner, upper(s.i.object_name) as object_name, upper(s.i.name) as name, s.i.line_no as line_no, s.i.parse_time as parse_time, s.i.description as description, s.i.rollback_type as rollback_type, s.i.disabled_flag as disabled_flag,s.i.disabled_reason as disabled_reason, s.i.warnings as warnings, @@ -377,7 +357,7 @@ create or replace package body ut_suite_cache_manager is null item from suites s; - insert /*+ no_parallel */ into ut_suite_cache t + insert /*+ no_parallel */ into &&ut3_owner..ut_suite_cache t ( id, self_type, path, object_owner, object_name, name, line_no, parse_time, description, @@ -389,10 +369,10 @@ create or replace package body ut_suite_cache_manager is item ) with tests as ( - select treat(value(x) as ut_test) t + select treat(value(x) as &&ut3_owner..ut_test) t from table ( a_suite_items ) x where x.self_type in ( 'UT_TEST' ) ) - select /*+ no_parallel */ ut_suite_cache_seq.nextval, s.t.self_type as self_type, s.t.path as path, + select /*+ no_parallel */ &&ut3_owner..ut_suite_cache_seq.nextval, s.t.self_type as self_type, s.t.path as path, upper(s.t.object_owner) as object_owner, upper(s.t.object_name) as object_name, upper(s.t.name) as name, s.t.line_no as line_no, s.t.parse_time as parse_time, s.t.description as description, s.t.rollback_type as rollback_type, s.t.disabled_flag as disabled_flag, s.t.disabled_reason as disabled_reason, s.t.warnings as warnings, @@ -409,54 +389,28 @@ create or replace package body ut_suite_cache_manager is end; procedure remove_missing_objs_from_cache(a_schema_name varchar2) is - l_objects ut_varchar2_rows; pragma autonomous_transaction; begin - l_objects := get_missing_cache_objects(a_schema_name); - - if l_objects is not empty then - delete /*+ no_parallel */ from ut_suite_cache i - where i.object_owner = a_schema_name - and i.object_name in ( select /*+ no_parallel */ column_value from table (l_objects) ); - - delete /*+ no_parallel */ from ut_suite_cache_package i - where i.object_owner = a_schema_name - and i.object_name in ( select /*+ no_parallel */ column_value from table (l_objects) ); - end if; + --rows of ut_suite_cache are removed by the "on delete cascade" foreign key + delete /*+ no_parallel */ from &&ut3_owner..ut_suite_cache_package i + where i.object_owner = a_schema_name + and not exists ( + select 1 + from (&&ut3_owner..ut_annotation_cache_macros.get_cached_objects(a_schema_name, 'PACKAGE')) o + where o.object_name = i.object_name + ); commit; end; - function get_cached_suite_info( - a_schema_paths ut_path_items - ) return ut_suite_cache_rows is - begin - return get_cached_suite_rows(get_suite_items(a_schema_paths)); - end; - - function get_suite_items_info( - a_suite_cache_items ut_suite_cache_rows - ) return ut_suite_items_info is - l_results ut_suite_items_info; - begin - select /*+ no_parallel */ ut_suite_item_info( - c.object_owner, c.object_name, c.name, - c.description, c.self_type, c.line_no, - c.path, c.disabled_flag, c.disabled_reason, c.tags - ) - bulk collect into l_results - from table(a_suite_cache_items) c; - return l_results; - end; - function get_cached_packages( a_schema_names ut_varchar2_rows ) return ut_object_names is l_results ut_object_names; begin - select /*+ no_parallel */ ut_object_name( c.object_owner, c.object_name ) + select /*+ no_parallel */ &&ut3_owner..ut_object_name( c.object_owner, c.object_name ) bulk collect into l_results - from ut_suite_cache_package c + from &&ut3_owner..ut_suite_cache_package c join table ( a_schema_names ) s on c.object_owner = upper(s.column_value); return l_results; @@ -473,7 +427,7 @@ create or replace package body ut_suite_cache_manager is select /*+ no_parallel */ count( 1 ) into l_count from dual where exists( select 1 - from ut_suite_cache c + from &&ut3_owner..ut_suite_cache c where c.object_owner = a_owner_name and c.object_name = a_package_name and c.name = a_procedure_name @@ -482,7 +436,7 @@ create or replace package body ut_suite_cache_manager is select /*+ no_parallel */ count( 1 ) into l_count from dual where exists( select 1 - from ut_suite_cache c + from &&ut3_owner..ut_suite_cache c where c.object_owner = a_owner_name and c.object_name = a_package_name ); @@ -490,7 +444,7 @@ create or replace package body ut_suite_cache_manager is select /*+ no_parallel */ count( 1 ) into l_count from dual where exists( select 1 - from ut_suite_cache c + from &&ut3_owner..ut_suite_cache c where c.object_owner = a_owner_name ); end if; diff --git a/source/core/ut_suite_cache_manager.pks b/source/core/ut_suite_cache_manager.pks index bd236678d..1ff9552cc 100644 --- a/source/core/ut_suite_cache_manager.pks +++ b/source/core/ut_suite_cache_manager.pks @@ -1,10 +1,10 @@ -create or replace package ut_suite_cache_manager authid definer is +create or replace noneditionable package ut_suite_cache_manager authid current_user is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,6 +18,11 @@ create or replace package ut_suite_cache_manager authid definer is /** * Responsible for storing and retrieving suite data from cache + * + * The package runs with invoker rights. It accesses the suite cache tables of the framework owner + * through the code based access control role _cbac_modify_objects_role granted to the package, + * so all references to framework objects in SQL statements are qualified with the framework owner. + * The owner is filled in by the SQL*Plus substitution variable ut3_owner when the package body is installed by install.sql. */ /* @@ -41,41 +46,33 @@ create or replace package ut_suite_cache_manager authid definer is procedure remove_missing_objs_from_cache(a_schema_name varchar2); /* - * We will sort a suites in hierarchical structure. - * Sorting from bottom to top so when we consolidate - * we will go in proper order. + * Splits run paths (schema[.package[.procedure]] or schema:suitepath, wildcards allowed) into their parts. + * Wildcards are resolved by get_suite_rows. */ - procedure sort_and_randomize_tests( - a_suite_rows in out ut_suite_cache_rows, - a_random_seed positive := null); + function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items; /* - * Retrieves suite items data from cache. - * Returned data is not filtered by user access rights. - * Not to be used publicly. Used internally for building suites at runtime. + * Retrieves suite items matching the paths from cache, with logical suites added for suitepaths without a package. + * Returns only items of packages the invoking user can access, unless a_skip_access_check is true. + * When a_tags is given, returns only items with a test matching the tag expression below them (or being one). + * The rows are sorted bottom up: children before parents, by line number or, when a_random_seed is given, randomly. + * Not to be used publicly. Used internally for building suites at runtime and suites info. */ - function get_cached_suite_rows( - a_suites_filtered ut_suite_cache_rows + function get_suite_rows( + a_schema_paths ut_path_items, + a_skip_access_check boolean, + a_tags varchar2 := null, + a_random_seed positive := null ) return ut_suite_cache_rows; - function get_schema_paths(a_paths in ut_varchar2_list) return ut_path_items; - /* - * Retrieves suite item info rows from cache. - * Returned data is not filtered by user access rights. - * Not to be used publicly. Used internally for building suites info. + * Retrieves information about the suite items matching the paths, as get_suite_rows does without tags. + * Not to be used publicly. Used internally for ut_runner.get_suites_info. */ - function get_cached_suite_info( - a_schema_paths ut_path_items - ) return ut_suite_cache_rows; - - function get_suite_items_info( - a_suite_cache_items ut_suite_cache_rows + function get_suites_info( + a_schema_paths ut_path_items, + a_skip_access_check boolean ) return ut_suite_items_info; - - function get_suite_items ( - a_schema_paths ut_path_items - ) return ut_suite_cache_rows; /* * Retrieves list of cached suite packages. diff --git a/source/core/ut_suite_cache_package.sql b/source/core/ut_suite_cache_package.sql index 40b7b8dec..1f05c633f 100644 --- a/source/core/ut_suite_cache_package.sql +++ b/source/core/ut_suite_cache_package.sql @@ -2,8 +2,8 @@ create table ut_suite_cache_package ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/ut_suite_cache_schema.sql b/source/core/ut_suite_cache_schema.sql index cace332e3..a49b92f7e 100644 --- a/source/core/ut_suite_cache_schema.sql +++ b/source/core/ut_suite_cache_schema.sql @@ -2,8 +2,8 @@ create table ut_suite_cache_schema ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/ut_suite_cache_seq.sql b/source/core/ut_suite_cache_seq.sql index 020c25c4d..ce7b5d19a 100644 --- a/source/core/ut_suite_cache_seq.sql +++ b/source/core/ut_suite_cache_seq.sql @@ -2,8 +2,8 @@ create sequence ut_suite_cache_seq /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index ad7f27f59..3689d991e 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_suite_manager is +create or replace noneditionable package body ut_suite_manager is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -19,7 +19,6 @@ create or replace package body ut_suite_manager is gc_suitpath_error_message constant varchar2(100) := 'Suitepath exceeds 1000 CHAR on: '; cursor c_cached_suites_cursor is select * from table(ut_suite_cache_rows()); type tt_cached_suites is table of c_cached_suites_cursor%rowtype; - type t_cached_suites_cursor is ref cursor return c_cached_suites_cursor%rowtype; type t_item_levels is table of ut_suite_items index by binary_integer; ------------------ @@ -143,91 +142,51 @@ create or replace package body ut_suite_manager is a_items_at_level t_item_levels ) return ut_suite_item is l_result ut_suite_item; + l_items ut_suite_items; begin + --the items one level below, collected before the parent (rows are sorted bottom up) + l_items := case when a_prev_level > a_level then a_items_at_level(a_prev_level) else ut_suite_items() end; case a_rows( a_idx ).self_type when 'UT_SUITE' then l_result := - case when a_prev_level > a_level then - ut_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => a_items_at_level(a_prev_level), - before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags - ) - else - ut_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => ut_suite_items(), - before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags - ) - end; + ut_suite( + self_type => a_rows( a_idx ).self_type, + object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), + name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, + line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, + start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, + results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), + items => l_items, + before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( + a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags + ); when 'UT_SUITE_CONTEXT' then l_result := - case when a_prev_level > a_level then - ut_suite_context( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => a_items_at_level(a_prev_level), - before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags - ) - else - ut_suite_context( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => ut_suite_items(), - before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( - a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags - ) - end; + ut_suite_context( + self_type => a_rows( a_idx ).self_type, + object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), + name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, + line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, + start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, + results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), + items => l_items, + before_all_list => sort_by_seq_no( a_rows( a_idx ).before_all_list), after_all_list => sort_by_seq_no( + a_rows( a_idx ).after_all_list), tags => a_rows(a_idx).tags + ); when 'UT_LOGICAL_SUITE' then l_result := - case when a_prev_level > a_level then - ut_logical_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => a_items_at_level(a_prev_level), tags => null - ) - else - ut_logical_suite( - self_type => a_rows( a_idx ).self_type, - object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), - name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, - rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, - line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, - start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, - results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), - items => ut_suite_items(), tags => null - ) - end; + ut_logical_suite( + self_type => a_rows( a_idx ).self_type, + object_owner => a_rows( a_idx ).object_owner, object_name => lower( a_rows( a_idx ).object_name), + name => lower( a_rows( a_idx ).name), description => a_rows( a_idx ).description, path => a_rows( a_idx ).path, + rollback_type => a_rows( a_idx ).rollback_type, disabled_flag => a_rows( a_idx ).disabled_flag, disabled_reason => a_rows(a_idx).disabled_reason, + line_no => a_rows( a_idx ).line_no, parse_time => a_rows( a_idx ).parse_time, + start_time => null, end_time => null, result => null, warnings => a_rows( a_idx ).warnings, + results_count => ut_results_counter(), transaction_invalidators => ut_varchar2_list(), + items => l_items, tags => null + ); when 'UT_TEST' then l_result := ut_test( @@ -250,42 +209,46 @@ create or replace package body ut_suite_manager is return l_result; end; + /* + Builds the suite hierarchy from cache rows sorted bottom-up (see ut_suite_cache_manager.get_suite_rows) + and propagates the rollback type of top level suites to their items. + + The rows are converted to records with SQL before use. Building ut_test objects from the item attribute + of ut_suite_cache_row objects directly makes the test execution fail on Oracle 19.20 with + ORA-00600: [pfrobj.c: invalid RTTI for Object] in ut_executable.do_execute (seen in nested runs, test_ut_test). + */ procedure reconstruct_from_cache( a_suites in out nocopy ut_suite_items, - a_suite_data_cursor sys_refcursor + a_suite_rows ut_suite_cache_rows ) is - c_bulk_limit constant pls_integer := 1000; l_items_at_level t_item_levels; l_rows tt_cached_suites; l_level pls_integer; l_prev_level pls_integer; l_idx integer; begin - loop - fetch a_suite_data_cursor bulk collect into l_rows limit c_bulk_limit; - - l_idx := l_rows.first; - while l_idx is not null loop - l_level := length(l_rows(l_idx).path) - length( replace(l_rows(l_idx).path, '.') ) + 1; - if l_level > 1 then - if not l_items_at_level.exists(l_level) then - l_items_at_level(l_level) := ut_suite_items(); - end if; - l_items_at_level(l_level).extend; - pragma inline(get_logical_suite, 'YES'); - l_items_at_level(l_level)(l_items_at_level(l_level).last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level ); - else - a_suites.extend; - pragma inline(get_logical_suite, 'YES'); - a_suites(a_suites.last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level ); - end if; - if l_prev_level > l_level then - l_items_at_level(l_prev_level).delete; + select * bulk collect into l_rows from table(a_suite_rows); + + l_idx := l_rows.first; + while l_idx is not null loop + l_level := length(l_rows(l_idx).path) - length( replace(l_rows(l_idx).path, '.') ) + 1; + if l_level > 1 then + if not l_items_at_level.exists(l_level) then + l_items_at_level(l_level) := ut_suite_items(); end if; - l_prev_level := l_level; - l_idx := l_rows.next(l_idx); - end loop; - exit when a_suite_data_cursor%NOTFOUND; + l_items_at_level(l_level).extend; + pragma inline(get_logical_suite, 'YES'); + l_items_at_level(l_level)(l_items_at_level(l_level).last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level ); + else + a_suites.extend; + pragma inline(get_logical_suite, 'YES'); + a_suites(a_suites.last) := get_logical_suite(l_rows, l_idx, l_level,l_prev_level, l_items_at_level ); + end if; + if l_prev_level > l_level then + l_items_at_level(l_prev_level).delete; + end if; + l_prev_level := l_level; + l_idx := l_rows.next(l_idx); end loop; reverse_list_order( a_suites ); @@ -293,52 +256,56 @@ create or replace package body ut_suite_manager is for i in 1 .. a_suites.count loop a_suites( i ).set_rollback_type( a_suites( i ).get_rollback_type ); end loop; - close a_suite_data_cursor; end reconstruct_from_cache; - function get_filtered_cursor( - a_unfiltered_rows in ut_suite_cache_rows, - a_skip_all_objects boolean := false - ) - return ut_suite_cache_rows is - l_result ut_suite_cache_rows := ut_suite_cache_rows(); + /* + A user can run all packages of a schema they own, and of any schema with EXECUTE ANY PROCEDURE, + so the access to those packages does not need checking. + */ + function can_skip_access_check(a_owner_name varchar2) return boolean is begin - if ut_metadata.user_has_execute_any_proc() or a_skip_all_objects then - l_result := a_unfiltered_rows; - else - select obj bulk collect into l_result - from ( - select /*+ no_parallel */ value(c) as obj from table(a_unfiltered_rows) c - where sys_context( 'userenv', 'current_user' ) = upper(c.object_owner) - union all - select /*+ no_parallel */ value(c) as obj from table(a_unfiltered_rows) c - where sys_context( 'userenv', 'current_user' ) != upper(c.object_owner) - and ( exists - ( select 1 - from all_objects a - where a.object_name = c.object_name - and a.owner = c.object_owner - and a.object_type = 'PACKAGE' - ) - or c.self_type = 'UT_LOGICAL_SUITE')); - end if; - return l_result; + return sys_context( 'userenv', 'current_user' ) = upper(a_owner_name) or ut_metadata.user_has_execute_any_proc(); + end; + + function can_skip_access_check(a_schema_paths ut_path_items) return boolean is + begin + for i in 1 .. a_schema_paths.count loop + if not can_skip_access_check(a_schema_paths(i).schema_name) then + return false; + end if; + end loop; + return true; end; + /* + Raises ut_utils.gc_suite_package_not_found for the first path that selects none of the suite rows + (as returned by ut_suite_cache_manager.get_suite_rows), with the same matching rule: + the SQL macro ut_suite_cache_macros.match_paths. + */ procedure reconcile_paths_and_suites( - a_schema_paths ut_path_items, - a_filtered_rows ut_suite_cache_rows + a_schema_paths ut_path_items, + a_suite_rows ut_suite_cache_rows ) is begin - for i in ( select /*+ no_parallel */ sp.schema_name,sp.object_name,sp.procedure_name, - sp.suite_path,sc.path - from table(a_schema_paths) sp left outer join - table(a_filtered_rows) sc on - (( upper(sp.schema_name) = upper(sc.object_owner) and upper(sp.object_name) = upper(sc.object_name) - and nvl(upper(sp.procedure_name),sc.name) = sc.name ) - or (sc.path = sp.suite_path)) - where sc.path is null) - loop + for i in ( + with + path_items as ( + select /*+ materialize */ rownum as path_id, sp.schema_name, sp.object_name, sp.procedure_name, sp.suite_path + from table(a_schema_paths) sp + ), + suite_items as ( + select r.object_owner, r.object_name, r.name, r.path + from table(a_suite_rows) r + ) + select /*+ no_parallel */ p.schema_name, p.object_name, p.procedure_name, p.suite_path + from path_items p + where not exists ( + select 1 + from (&&ut3_owner..ut_suite_cache_macros.match_paths(suite_items, path_items)) m + where m.path_id = p.path_id + ) + order by p.path_id + ) loop if i.suite_path is not null then raise_application_error(ut_utils.gc_suite_package_not_found,'No suite packages found for path '||i.schema_name||':'||i.suite_path|| '.'); elsif i.procedure_name is not null then @@ -352,32 +319,16 @@ create or replace package body ut_suite_manager is function get_cached_suite_data( a_schema_paths ut_path_items, a_random_seed positive, - a_tags varchar2 := null, - a_skip_all_objects boolean := false - ) return t_cached_suites_cursor is - l_unfiltered_rows ut_suite_cache_rows; - l_tag_filter_applied ut_suite_cache_rows; - l_filtered_rows ut_suite_cache_rows; - l_result t_cached_suites_cursor; + a_tags varchar2 := null + ) return ut_suite_cache_rows is + l_suite_rows ut_suite_cache_rows; begin - l_unfiltered_rows := ut_suite_cache_manager.get_suite_items(a_schema_paths); - - l_tag_filter_applied := ut_suite_tag_filter.apply(l_unfiltered_rows,a_tags); - l_filtered_rows := get_filtered_cursor(ut_suite_cache_manager.get_cached_suite_rows(l_tag_filter_applied),a_skip_all_objects); - reconcile_paths_and_suites(a_schema_paths,l_filtered_rows); - - ut_suite_cache_manager.sort_and_randomize_tests(l_filtered_rows,a_random_seed); - - open l_result for - select * from table(l_filtered_rows); - return l_result; - end; + l_suite_rows := ut_suite_cache_manager.get_suite_rows( + a_schema_paths, can_skip_access_check(a_schema_paths), a_tags, a_random_seed + ); + reconcile_paths_and_suites(a_schema_paths, l_suite_rows); - function can_skip_all_objects_scan( - a_owner_name varchar2 - ) return boolean is - begin - return sys_context( 'userenv', 'current_user' ) = upper(a_owner_name) or ut_metadata.user_has_execute_any_proc(); + return l_suite_rows; end; procedure build_and_cache_suites( @@ -438,13 +389,33 @@ create or replace package body ut_suite_manager is build_and_cache_suites(l_owner_name, l_annotations_cursor); - if can_skip_all_objects_scan(l_owner_name) or ut_metadata.is_object_visible( 'dba_objects') then + if can_skip_access_check(l_owner_name) or ut_metadata.is_object_visible( 'dba_objects') then ut_suite_cache_manager.remove_missing_objs_from_cache( l_owner_name ); end if; ut_event_manager.trigger_event('refresh_cache - end'); end; + /* + Resolves the schema names of the paths, refreshes the suite cache of those schemas + and returns the paths split into their parts. + */ + function refresh_cache_for_paths( + a_paths ut_varchar2_list + ) return ut_path_items is + l_paths ut_varchar2_list := a_paths; + l_schema_names ut_varchar2_rows; + l_schema varchar2(4000); + begin + l_schema_names := resolve_schema_names(l_paths); + l_schema := l_schema_names.first; + while l_schema is not null loop + refresh_cache(upper(l_schema_names(l_schema))); + l_schema := l_schema_names.next(l_schema); + end loop; + return ut_suite_cache_manager.get_schema_paths(l_paths); + end; + procedure add_suites_for_paths( a_schema_paths ut_path_items, a_suites in out nocopy ut_suite_items, @@ -471,8 +442,7 @@ create or replace package body ut_suite_manager is a_annotated_objects sys_refcursor, a_path varchar2 := null, a_object_name varchar2 := null, - a_procedure_name varchar2 := null, - a_skip_all_objects boolean := false + a_procedure_name varchar2 := null ) return ut_suite_items is l_suites ut_suite_items := ut_suite_items(); l_schema_paths ut_path_items; @@ -484,8 +454,7 @@ create or replace package body ut_suite_manager is get_cached_suite_data( l_schema_paths, null, - null, - a_skip_all_objects + null ) ); return l_suites; @@ -528,38 +497,22 @@ create or replace package body ut_suite_manager is a_random_seed positive := null, a_tags varchar2 := null ) is - l_paths ut_varchar2_list := a_paths; - l_schema_names ut_varchar2_rows; - l_schema_paths ut_path_items; - l_schema varchar2(4000); + l_tags_match integer; begin ut_event_manager.trigger_event('configure_execution_by_path - start'); + --raise an error for an invalid tag expression even when the paths select no tests to evaluate it on + if a_tags is not null then + l_tags_match := ut_suite_tag_filter.is_matching(null, a_tags); + end if; a_suites := ut_suite_items(); - --resolve schema names from paths and group paths by schema name - l_schema_names := resolve_schema_names(l_paths); - - --refresh cache - l_schema := l_schema_names.first; - while l_schema is not null loop - refresh_cache(upper(l_schema_names(l_schema))); - l_schema := l_schema_names.next(l_schema); - end loop; - - l_schema_paths := ut_suite_cache_manager.get_schema_paths(l_paths); - --We will get a single list of paths rather than loop by loop. add_suites_for_paths( - l_schema_paths, + refresh_cache_for_paths(a_paths), a_suites, a_random_seed, a_tags ); - --propagate rollback type to suite items after organizing suites into hierarchy - for i in 1 .. a_suites.count loop - a_suites(i).set_rollback_type( a_suites(i).get_rollback_type() ); - end loop; - ut_event_manager.trigger_event('configure_execution_by_path - end'); end configure_execution_by_path; @@ -568,25 +521,9 @@ create or replace package body ut_suite_manager is ) return sys_refcursor is l_result sys_refcursor; l_all_suite_info ut_suite_items_info; - l_schema_names ut_varchar2_rows; - l_schema_paths ut_path_items; - l_paths ut_varchar2_list := a_paths; - l_schema varchar2(4000); - l_unfiltered_rows ut_suite_cache_rows; - l_filtered_rows ut_suite_cache_rows; - + l_schema_paths ut_path_items := refresh_cache_for_paths(a_paths); begin - l_schema_names := resolve_schema_names(l_paths); - --refresh cache - l_schema := l_schema_names.first; - while l_schema is not null loop - refresh_cache(upper(l_schema_names(l_schema))); - l_schema := l_schema_names.next(l_schema); - end loop; - l_schema_paths := ut_suite_cache_manager.get_schema_paths(l_paths); - l_unfiltered_rows := ut_suite_cache_manager.get_cached_suite_info(l_schema_paths); - l_filtered_rows := get_filtered_cursor(l_unfiltered_rows); - l_all_suite_info := ut_suite_cache_manager.get_suite_items_info(l_filtered_rows); + l_all_suite_info := ut_suite_cache_manager.get_suites_info(l_schema_paths, can_skip_access_check(l_schema_paths)); open l_result for select /*+ no_parallel */ value(c) from table(l_all_suite_info) c @@ -609,7 +546,7 @@ create or replace package body ut_suite_manager is refresh_cache(l_owner_name); l_item_exists := ut_suite_cache_manager.suite_item_exists( l_owner_name, l_package_name, l_procedure_name ); - if not can_skip_all_objects_scan( l_owner_name ) and l_package_name is not null then + if not can_skip_access_check( l_owner_name ) and l_package_name is not null then select /*+ no_parallel */ count(1) into l_count from dual c diff --git a/source/core/ut_suite_manager.pks b/source/core/ut_suite_manager.pks index 8ac7cc8ad..b381ecc63 100644 --- a/source/core/ut_suite_manager.pks +++ b/source/core/ut_suite_manager.pks @@ -1,10 +1,10 @@ -create or replace package ut_suite_manager authid current_user is +create or replace noneditionable package ut_suite_manager authid current_user is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -20,6 +20,13 @@ create or replace package ut_suite_manager authid current_user is * Resposible for building hierarhy of sutes from individual suites created by suite_builder */ + /* + * The package runs with invoker rights. It calls the SQL macros of ut_suite_cache_macros in SQL statements + * through the code based access control role _cbac_modify_objects_role granted to the package, + * so the references to framework objects in those statements are qualified with the framework owner. + * The owner is filled in by the SQL*Plus substitution variable ut3_owner when the package body is installed by install.sql. + */ + /** * @private * @@ -72,8 +79,7 @@ create or replace package ut_suite_manager authid current_user is a_annotated_objects sys_refcursor, a_path varchar2 := null, a_object_name varchar2 := null, - a_procedure_name varchar2 := null, - a_skip_all_objects boolean := false + a_procedure_name varchar2 := null ) return ut_suite_items; diff --git a/source/core/ut_suite_tag_filter.pkb b/source/core/ut_suite_tag_filter.pkb index 17b5ba4b0..1ff204a5e 100644 --- a/source/core/ut_suite_tag_filter.pkb +++ b/source/core/ut_suite_tag_filter.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_suite_tag_filter is +create or replace noneditionable package body ut_suite_tag_filter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -17,40 +17,47 @@ create or replace package body ut_suite_tag_filter is */ /** - * Constants use in postfix and infix transformations + * Constants used in the conversion to postfix notation */ gc_operators constant ut_varchar2_list := ut_varchar2_list('|','&','!'); gc_unary_operators constant ut_varchar2_list := ut_varchar2_list('!'); -- right side associative operator gc_binary_operators constant ut_varchar2_list := ut_varchar2_list('|','&'); -- left side associative operator - gc_reserved_tag_words constant ut_varchar2_list := ut_varchar2_list('none','any'); gc_exception_msg constant varchar2(200) := 'Invalid tag expression'; type t_precedence_table is table of number index by varchar2(1); g_precedence t_precedence_table; + g_last_tag_expression varchar2(32767); + g_last_postfix ut_varchar2_list; + function tokenize_tags_string(a_tags in varchar2) return ut_varchar2_list is l_tags_tokens ut_varchar2_list := ut_varchar2_list(); begin - --Tokenize a string into operators and tags - select regexp_substr(a_tags,'([^!()|&]+)|([!()|&])', 1, level) as string_parts - bulk collect into l_tags_tokens - from dual connect by regexp_substr (a_tags, '([^!()|&]+)|([!()|&])', 1, level) is not null; + if a_tags is not null then + select regexp_substr(a_tags,'([^!()|&]+)|([!()|&])', 1, level) as string_parts + bulk collect into l_tags_tokens + from dual connect by regexp_substr (a_tags, '([^!()|&]+)|([!()|&])', 1, level) is not null; + end if; return l_tags_tokens; end; + function remove_whitespace(a_tag_expression varchar2) return varchar2 is + begin + return replace(replace(a_tag_expression, ' '), chr(9)); + end; + /* - To support a legact tag notation + To support a legacy tag notation , = OR - = NOT - we will perform a replace of that characters into + we replace those characters into new notation. | = OR & = AND ! = NOT */ - function replace_legacy_tag_notation(a_tags varchar2 - ) return varchar2 is + function replace_legacy_tag_notation(a_tags varchar2) return varchar2 is l_tags ut_varchar2_list := ut_utils.string_to_table(a_tags,','); l_tags_include varchar2(4000); l_tags_exclude varchar2(4000); @@ -64,7 +71,7 @@ create or replace package body ut_suite_tag_filter is from table(l_tags) t where t.column_value not like '-%'; - select '('||listagg( replace(t.column_value,'-','!'),' & ') + select '('||listagg( replace(t.column_value,'-','!'),'&') within group( order by column_value)||')' into l_tags_exclude from table(l_tags) t @@ -74,7 +81,7 @@ create or replace package body ut_suite_tag_filter is l_return_tag:= case when l_tags_include <> '()' and l_tags_exclude <> '()' - then l_tags_include || ' & ' || l_tags_exclude + then l_tags_include || '&' || l_tags_exclude when l_tags_include <> '()' then l_tags_include when l_tags_exclude <> '()' @@ -98,7 +105,7 @@ create or replace package body ut_suite_tag_filter is l_idx pls_integer; begin l_idx := a_tags.first; - --Exuecute modified shunting algorithm + --Execute modified shunting algorithm WHILE (l_idx is not null) loop l_token := a_tags(l_idx); if (l_token member of gc_operators and l_token member of gc_binary_operators) then @@ -134,6 +141,10 @@ create or replace package body ut_suite_tag_filter is l_rnp_tokens.extend; l_rnp_tokens(l_rnp_tokens.last) := l_operator_stack.pop; end loop; + --no open bracket left on the stack: unmatched right bracket + if l_operator_stack.peek is null then + raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); + end if; l_operator_stack.pop; --Pop the open bracket and discard it l_expect_operand := false; l_expect_operator:= true; @@ -150,6 +161,11 @@ create or replace package body ut_suite_tag_filter is l_idx := a_tags.next(l_idx); end loop; + --an empty expression, or one ending with an operator or a left bracket, is incomplete + if not(l_expect_operator) then + raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); + end if; + while l_operator_stack.peek is not null loop if l_operator_stack.peek in ('(',')') then raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg); @@ -161,123 +177,74 @@ create or replace package body ut_suite_tag_filter is return l_rnp_tokens; end shunt_logical_expression; - function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list,a_tags_column_name in varchar2) - return varchar2 is - l_infix_stack ut_stack := ut_stack(); - l_right_side varchar2(32767); - l_left_side varchar2(32767); - l_infix_exp varchar2(32767); - l_member_token varchar2(20) := ' member of '||a_tags_column_name; - l_idx pls_integer; - begin - l_idx := a_postfix_exp.first; - while ( l_idx is not null) loop - --If the token we got is a none or any keyword - if a_postfix_exp(l_idx) member of gc_reserved_tag_words then - - l_infix_stack.push( - case - when a_postfix_exp(l_idx) = 'none' then '('||a_tags_column_name||' is empty or '||a_tags_column_name||' is null)' - else a_tags_column_name||' is not empty' - end - ); - --If token is operand but also single tag - elsif regexp_count(a_postfix_exp(l_idx),'[!()|&]') = 0 then - l_infix_stack.push(q'[']'||a_postfix_exp(l_idx)||q'[']'||l_member_token); - --If token is unary operator not - elsif a_postfix_exp(l_idx) member of gc_unary_operators then - l_right_side := l_infix_stack.pop; - l_infix_exp := a_postfix_exp(l_idx)||'('||l_right_side||')'; - l_infix_stack.push(l_infix_exp); - --If token is binary operator - elsif a_postfix_exp(l_idx) member of gc_binary_operators then - l_right_side := l_infix_stack.pop; - l_left_side := l_infix_stack.pop; - l_infix_exp := '('||l_left_side||a_postfix_exp(l_idx)||l_right_side||')'; - l_infix_stack.push(l_infix_exp); - end if; - l_idx := a_postfix_exp.next(l_idx); - end loop; - - return l_infix_stack.pop; - end conv_postfix_to_infix_sql; - - function create_where_filter(a_tags varchar2 - ) return varchar2 is - l_tags varchar2(4000); + /* + Returns a tag expression in postfix notation (Reverse Polish Notation). + is_matching is called for each test with the same expression, so the result for the last expression is cached. + Raises ut_utils.gc_invalid_tag_expression for an invalid expression. + */ + function get_postfix_expression(a_tag_expression varchar2) return ut_varchar2_list is + l_postfix ut_varchar2_list; begin - l_tags := replace(replace_legacy_tag_notation(a_tags),' '); - l_tags := conv_postfix_to_infix_sql(shunt_logical_expression(tokenize_tags_string(l_tags)),'tags'); - l_tags := replace(l_tags, '|',' or '); - l_tags := replace(l_tags ,'&',' and '); - l_tags := replace(l_tags ,'!','not'); - return l_tags; + if g_last_tag_expression = a_tag_expression then + return g_last_postfix; + end if; + l_postfix := shunt_logical_expression( + tokenize_tags_string( replace_legacy_tag_notation( a_tag_expression ) ) + ); + g_last_tag_expression := a_tag_expression; + g_last_postfix := l_postfix; + return l_postfix; end; - /* - Having a base set of suites we will do a further filter down if there are - any tags defined. + Evaluates a valid postfix expression against a list of tags, using a stack of operand values. + The values follow the three-valued logic of SQL: "x member of a_tags" is null when a_tags has a null element + and no element x, and "not null" is null, as in a SQL condition. */ - function get_tags_suites ( - a_suite_items ut_suite_cache_rows, - a_tags varchar2 - ) return ut_suite_cache_rows is - l_results ut_suite_cache_rows; - l_sql varchar2(32000); - l_tags_filter_clause varchar2(4000):= create_where_filter(a_tags); + function evaluate_postfix(a_postfix ut_varchar2_list, a_tags ut_varchar2_list) return boolean is + type t_boolean_stack is table of boolean index by pls_integer; + l_stack t_boolean_stack; + l_top pls_integer := 0; + l_token varchar2(32767); begin - l_sql := - q'[ - with - suites_mv as ( - select c.id,value(c) as obj,c.path as path,c.self_type,c.object_owner,c.tags as tags - from table(:suite_items) c - ), - propagate_tags_from_ancestors as ( - select c.id, c.self_type, c.path, c.object_owner, cast(collect(c_tags.tag) as ut_varchar2_rows) as tags - from suites_mv c - left join suites_mv t - on t.self_type in ('UT_SUITE','UT_SUITE_CONTEXT') - and c.path like t.path||'.%' /* all descendants */ - and c.object_owner = t.object_owner - outer apply (select column_value tag from table(c.tags) union select column_value tag from table(t.tags) ) c_tags - group by c.id, c.self_type, c.path, c.object_owner - ), - filter_by_tags as ( - select * - from propagate_tags_from_ancestors x - where ( ]'||l_tags_filter_clause||q'[ ) - ), - only_items_with_tests as ( - select item.obj - from suites_mv item - where exists ( - select 1 - from filter_by_tags tst - where tst.self_type in ('UT_TEST') - and (tst.path||'.' like item.path || '.%' /*all descendants and self*/ and item.object_owner = tst.object_owner) - ) - ) - select obj from only_items_with_tests]'; - execute immediate l_sql bulk collect into l_results using a_suite_items; - - return l_results; + for i in 1 .. a_postfix.count loop + l_token := a_postfix(i); + case l_token + when '!' then + l_stack(l_top) := not l_stack(l_top); + when '&' then + l_top := l_top - 1; + l_stack(l_top) := l_stack(l_top) and l_stack(l_top + 1); + when '|' then + l_top := l_top - 1; + l_stack(l_top) := l_stack(l_top) or l_stack(l_top + 1); + else + l_top := l_top + 1; + l_stack(l_top) := + case l_token + when 'none' then a_tags is empty + when 'any' then a_tags is not empty + else l_token member of a_tags + end; + end case; + end loop; + return l_stack(1); end; - function apply( - a_unfiltered_rows ut_suite_cache_rows, - a_tags varchar2 := null - ) return ut_suite_cache_rows is - l_suite_items ut_suite_cache_rows := a_unfiltered_rows; + function is_matching(a_tags varchar2, a_tag_expression varchar2) return integer deterministic is + l_tag_expression varchar2(32767) := remove_whitespace(a_tag_expression); begin - if length(a_tags) > 0 then - l_suite_items := get_tags_suites(l_suite_items,a_tags); - end if; - - return l_suite_items; + return + case + when l_tag_expression is null + then 1 + when evaluate_postfix( get_postfix_expression(l_tag_expression), ut_utils.string_to_table(a_tags, ',') ) + then 1 + else 0 + end; end; + begin --Define operators precedence g_precedence('!'):=4; diff --git a/source/core/ut_suite_tag_filter.pks b/source/core/ut_suite_tag_filter.pks index 0493bd194..3520c33c6 100644 --- a/source/core/ut_suite_tag_filter.pks +++ b/source/core/ut_suite_tag_filter.pks @@ -1,10 +1,10 @@ -create or replace package ut_suite_tag_filter authid definer is +create or replace noneditionable package ut_suite_tag_filter authid definer is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -17,13 +17,14 @@ create or replace package ut_suite_tag_filter authid definer is */ /** - * Package that will filter suites by tags + * Package that evaluates tag expressions against the tags of suite items. + * is_matching is called from SQL by ut_suite_cache_manager.get_suite_rows to filter suites by tags. * */ /* * Return table of tokens character by character - */ + */ function tokenize_tags_string(a_tags in varchar2) return ut_varchar2_list; /* @@ -34,22 +35,22 @@ create or replace package ut_suite_tag_filter authid definer is function shunt_logical_expression(a_tags in ut_varchar2_list) return ut_varchar2_list; /* - * Function that converts postfix notation into infix and creating a string of sql filter - * that checking a tags collections for tags according to posted logic. - */ - function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list,a_tags_column_name in varchar2) - return varchar2; - + * Returns the tag expression without spaces and tabs. + * Tags cannot contain whitespace, so it only separates the tokens of an expression. + * An expression made only of spaces and tabs becomes null, which is no tag filter. + */ + function remove_whitespace(a_tag_expression varchar2) return varchar2; + /* - * Generates a part where clause sql - */ - function create_where_filter(a_tags varchar2) - return varchar2; - - function apply( - a_unfiltered_rows ut_suite_cache_rows, - a_tags varchar2 := null - ) return ut_suite_cache_rows; + * Returns 1 when the tags match the tag expression, 0 otherwise. + * An empty tag expression (see remove_whitespace) matches any tags. + * a_tags is a comma-separated list of tags (tags cannot contain commas), null for no tags. + * Takes text, not a collection: Oracle caches results of a deterministic function called from SQL + * only when all arguments are scalars, so items with the same tags are evaluated once per statement. + * Raises ut_utils.gc_invalid_tag_expression for an invalid expression. + */ + function is_matching(a_tags varchar2, a_tag_expression varchar2) + return integer deterministic; end ut_suite_tag_filter; / diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index 32cbb3f8c..865e9e17c 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_utils is +create or replace noneditionable package body ut_utils is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 092c25583..d23659243 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -1,10 +1,10 @@ -create or replace package ut_utils authid definer is +create or replace noneditionable package ut_utils authid definer is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -21,8 +21,11 @@ create or replace package ut_utils authid definer is * */ - gc_version constant varchar2(50) := 'v3.2.01.4414-develop'; - + gc_version constant varchar2(50) := 'v3.2.4.4670-develop'; + + gc_support_url constant varchar2(100) := 'https://utplsql.org/support'; + gc_support_text constant varchar2(200) := 'Using utPLSQL at work? Get support and help keep it maintained'; + subtype t_executable_type is varchar2(30); gc_before_all constant t_executable_type := 'beforeall'; gc_before_each constant t_executable_type := 'beforeeach'; diff --git a/source/create_cbac_role.sql b/source/create_cbac_role.sql new file mode 100644 index 000000000..23082e34b --- /dev/null +++ b/source/create_cbac_role.sql @@ -0,0 +1,38 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Creates the code based access control (CBAC) role that gives invoker rights framework packages + access to framework tables, which are not granted to the users calling the framework. + The role is granted to the framework owner, as Oracle only allows granting a role to a program unit + when the role is granted to the owner of that program unit. + Each framework owner gets its own role, so packages of one utPLSQL installation cannot access tables of another one. + The role is created only if it does not exist yet, so the installation can be repeated without uninstalling first. +*/ + +prompt Creating role &&ut3_owner._cbac_modify_objects_role and granting it to &&ut3_owner + +declare + e_role_exists exception; + pragma exception_init(e_role_exists, -1921); +begin + execute immediate 'create role &&ut3_owner._cbac_modify_objects_role'; +exception + when e_role_exists then + null; +end; +/ + +grant &&ut3_owner._cbac_modify_objects_role to &&ut3_owner; diff --git a/source/create_grants.sql b/source/create_grants.sql index 0656ec82f..5cf7cfaaa 100644 --- a/source/create_grants.sql +++ b/source/create_grants.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -64,6 +64,12 @@ grant execute on &&ut3_owner..ut_suite_cache_rows to &ut3_user; grant execute on &&ut3_owner..ut_run_info to &ut3_user; grant execute on &&ut3_owner..ut_coverage_options to &ut3_user; +--SQL macros used in SQL statements of the framework. +--On Oracle 21c XE, expanding a macro requires the calling user to have execute privilege on it. +--The macros only return SQL text; the tables they reference stay accessible only through the code based access control role. +grant execute on &&ut3_owner..ut_annotation_cache_macros to &ut3_user; +grant execute on &&ut3_owner..ut_suite_cache_macros to &ut3_user; + --generic types grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user; grant execute on &&ut3_owner..ut_varchar2_rows to &ut3_user; @@ -108,7 +114,6 @@ grant execute on &&ut3_owner..ut_tap_reporter to &ut3_user; --reporters - coverage grant execute on &&ut3_owner..ut_coverage_html_reporter to &ut3_user; grant execute on &&ut3_owner..ut_coverage_sonar_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_coveralls_reporter to &ut3_user; grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to &ut3_user; --reporters - debug grant execute on &&ut3_owner..ut_debug_reporter to &ut3_user; diff --git a/source/create_synonyms.sql b/source/create_synonyms.sql index 3cc642921..c862a389c 100644 --- a/source/create_synonyms.sql +++ b/source/create_synonyms.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -36,10 +36,10 @@ set termout off spool params.sql.tmp select case - when upper('&&ut3_user') = 'PUBLIC' then q'[define action_type='or replace public' + when upper('&&ut3_user') = 'PUBLIC' then q'[define action_type='or replace noneditionable public' ]'||q'[define ut3_user='' ]'||q'[define grantee='PUBLIC']' - else q'[define action_type='or replace' + else q'[define action_type='or replace noneditionable' ]'||q'[define grantee='&&ut3_user'] ]'||q'[define ut3_user='&&ut3_user..']' end @@ -123,7 +123,6 @@ create &action_type. synonym &ut3_user.ut_tap_reporter for &&ut3_owner..ut_tap_r --reporters - coverage create &action_type. synonym &ut3_user.ut_coverage_html_reporter for &&ut3_owner..ut_coverage_html_reporter; create &action_type. synonym &ut3_user.ut_coverage_sonar_reporter for &&ut3_owner..ut_coverage_sonar_reporter; -create &action_type. synonym &ut3_user.ut_coveralls_reporter for &&ut3_owner..ut_coveralls_reporter; create &action_type. synonym &ut3_user.ut_coverage_cobertura_reporter for &&ut3_owner..ut_coverage_cobertura_reporter; --reporters - debug create &action_type. synonym &ut3_user.ut_debug_reporter for &&ut3_owner..ut_debug_reporter; diff --git a/source/create_synonyms_and_grants_for_public.sql b/source/create_synonyms_and_grants_for_public.sql index 25f14217e..572ed7d8f 100644 --- a/source/create_synonyms_and_grants_for_public.sql +++ b/source/create_synonyms_and_grants_for_public.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/create_user_grants.sql b/source/create_user_grants.sql index c1b81efa4..60b2725b5 100644 --- a/source/create_user_grants.sql +++ b/source/create_user_grants.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/create_user_synonyms.sql b/source/create_user_synonyms.sql index 7b0e49553..7fbc5b247 100644 --- a/source/create_user_synonyms.sql +++ b/source/create_user_synonyms.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/create_utplsql_owner.sql b/source/create_utplsql_owner.sql index a5b70ffda..0720a0d06 100644 --- a/source/create_utplsql_owner.sql +++ b/source/create_utplsql_owner.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/define_ut3_owner_param.sql b/source/define_ut3_owner_param.sql index 192e810b7..27fbfe705 100644 --- a/source/define_ut3_owner_param.sql +++ b/source/define_ut3_owner_param.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/dummy.sql b/source/dummy.sql deleted file mode 100644 index 36d9f8778..000000000 --- a/source/dummy.sql +++ /dev/null @@ -1 +0,0 @@ -whenever sqlerror exit failure rollback diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index edd27f766..cffa5fd26 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -2,8 +2,8 @@ create global temporary table ut_compound_data_diff_tmp( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 42feb2a47..ac429e408 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_compound_data_helper is +create or replace noneditionable package body ut_compound_data_helper is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index dd2e2ec3d..3c13c85e8 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -1,10 +1,10 @@ -create or replace package ut_compound_data_helper authid definer is +create or replace noneditionable package ut_compound_data_helper authid definer is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_compound_data_tmp.sql b/source/expectations/data_values/ut_compound_data_tmp.sql index 01cedd97b..902bf29fc 100644 --- a/source/expectations/data_values/ut_compound_data_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_tmp.sql @@ -2,8 +2,8 @@ create global temporary table ut_compound_data_tmp( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index 5fd3154b1..27c19455b 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_compound_data_value as +create or replace noneditionable type body ut_compound_data_value as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_compound_data_value.tps b/source/expectations/data_values/ut_compound_data_value.tps index ca2206e2a..6272e04a7 100644 --- a/source/expectations/data_values/ut_compound_data_value.tps +++ b/source/expectations/data_values/ut_compound_data_value.tps @@ -1,10 +1,10 @@ -create or replace type ut_compound_data_value force under ut_data_value( +create or replace noneditionable type ut_compound_data_value force under ut_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_cursor_column.tpb b/source/expectations/data_values/ut_cursor_column.tpb index 13fbb86b7..01ec72f41 100644 --- a/source/expectations/data_values/ut_cursor_column.tpb +++ b/source/expectations/data_values/ut_cursor_column.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_cursor_column as +create or replace noneditionable type body ut_cursor_column as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -47,21 +47,22 @@ create or replace type body ut_cursor_column as a_access_path||'/'||self.xml_valid_name end; --Access path used for XMLTABLE query self.filter_path := '/'||self.access_path; --Filter path will differ from access path in anydata type - --Transformed name needs to be build on full access path to avoid ambiguity when there is 3 or more levels of nesting. - self.transformed_name := case when length(self.xml_valid_name) > 30 then - '"'||ut_compound_data_helper.get_fixed_size_hash(self.access_path)||'"' - when self.parent_name is null then + --Transformed name is used as a column alias in generated SQL. + --Nested columns and names longer than the maximum identifier length are replaced by a hash of the full access path, + -- to avoid ambiguity when there is 3 or more levels of nesting. + self.transformed_name := case when self.parent_name is null and lengthb(self.xml_valid_name) <= ora_max_name_len_supported then '"'||self.xml_valid_name||'"' - else + else '"'||ut_compound_data_helper.get_fixed_size_hash(self.access_path)||'"' - end; --when is nestd we need to hash name to make sure we dont exceed 30 char + end; self.column_type := a_col_type; --column type e.g. user_defined , varchar2 self.column_schema := a_col_schema_name; -- schema name self.is_sql_diffable := case when lower(self.column_type) = 'user_defined_type' then 0 - -- Due to bug in 11g/12.1 collection fails on varchar 4000+ - when (lower(self.column_type) in ('varchar2','char')) and (self.column_len > 4000) then + -- Columns can be described as longer than SQL varchar2 allows (e.g. a dynamic bind over 4000 chars), + -- XMLTABLE rejects such a length (ORA-00910), so these values are compared by hash. + when (lower(self.column_type) in ('varchar2','char')) and (self.column_len > ut_utils.gc_max_storage_varchar2_len) then 0 else ut_utils.boolean_to_int(ut_compound_data_helper.is_sql_compare_allowed(self.column_type)) diff --git a/source/expectations/data_values/ut_cursor_column.tps b/source/expectations/data_values/ut_cursor_column.tps index 98ca78b6e..45c14c154 100644 --- a/source/expectations/data_values/ut_cursor_column.tps +++ b/source/expectations/data_values/ut_cursor_column.tps @@ -1,10 +1,10 @@ -create or replace type ut_cursor_column authid current_user as object ( +create or replace noneditionable type ut_cursor_column authid current_user as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_cursor_column_tab.tps b/source/expectations/data_values/ut_cursor_column_tab.tps index 258624691..6dfe98824 100644 --- a/source/expectations/data_values/ut_cursor_column_tab.tps +++ b/source/expectations/data_values/ut_cursor_column_tab.tps @@ -1,10 +1,10 @@ -create or replace type ut_cursor_column_tab as +create or replace noneditionable type ut_cursor_column_tab as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_cursor_details.tpb b/source/expectations/data_values/ut_cursor_details.tpb index cce0751d1..bfbe435e5 100644 --- a/source/expectations/data_values/ut_cursor_details.tpb +++ b/source/expectations/data_values/ut_cursor_details.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_cursor_details as +create or replace noneditionable type body ut_cursor_details as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -108,11 +108,7 @@ create or replace type body ut_cursor_details as a_cursor_number in number ) return self as result is l_columns_count pls_integer; - $if dbms_db_version.version = 12 and dbms_db_version.release = 1 or dbms_db_version.version < 12 $then - l_columns_desc dbms_sql.desc_tab3; - $else l_columns_desc dbms_sql.desc_tab4; - $end l_is_collection boolean; l_hierarchy_level integer := 1; begin diff --git a/source/expectations/data_values/ut_cursor_details.tps b/source/expectations/data_values/ut_cursor_details.tps index 981fda8e5..19f5b3f39 100644 --- a/source/expectations/data_values/ut_cursor_details.tps +++ b/source/expectations/data_values/ut_cursor_details.tps @@ -1,10 +1,10 @@ -create or replace type ut_cursor_details authid current_user as object ( +create or replace noneditionable type ut_cursor_details authid current_user as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value.tpb b/source/expectations/data_values/ut_data_value.tpb index 6eb352b77..a94e88660 100644 --- a/source/expectations/data_values/ut_data_value.tpb +++ b/source/expectations/data_values/ut_data_value.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value as +create or replace noneditionable type body ut_data_value as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value.tps b/source/expectations/data_values/ut_data_value.tps index 91a07e463..d5f00489e 100644 --- a/source/expectations/data_values/ut_data_value.tps +++ b/source/expectations/data_values/ut_data_value.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value force authid current_user as object ( +create or replace noneditionable type ut_data_value force authid current_user as object ( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_anydata.tpb b/source/expectations/data_values/ut_data_value_anydata.tpb index 189d2e032..6794beaa9 100644 --- a/source/expectations/data_values/ut_data_value_anydata.tpb +++ b/source/expectations/data_values/ut_data_value_anydata.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_anydata as +create or replace noneditionable type body ut_data_value_anydata as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_anydata.tps b/source/expectations/data_values/ut_data_value_anydata.tps index ee9725d58..3c56ce178 100644 --- a/source/expectations/data_values/ut_data_value_anydata.tps +++ b/source/expectations/data_values/ut_data_value_anydata.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_anydata under ut_data_value_refcursor( +create or replace noneditionable type ut_data_value_anydata under ut_data_value_refcursor( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_blob.tpb b/source/expectations/data_values/ut_data_value_blob.tpb index 42e35fc55..bf52d4056 100644 --- a/source/expectations/data_values/ut_data_value_blob.tpb +++ b/source/expectations/data_values/ut_data_value_blob.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_blob as +create or replace noneditionable type body ut_data_value_blob as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_blob.tps b/source/expectations/data_values/ut_data_value_blob.tps index 08813371e..5c93a5fac 100644 --- a/source/expectations/data_values/ut_data_value_blob.tps +++ b/source/expectations/data_values/ut_data_value_blob.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_blob under ut_data_value( +create or replace noneditionable type ut_data_value_blob under ut_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_boolean.tpb b/source/expectations/data_values/ut_data_value_boolean.tpb index 84af1c34c..5a499afb6 100644 --- a/source/expectations/data_values/ut_data_value_boolean.tpb +++ b/source/expectations/data_values/ut_data_value_boolean.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_boolean as +create or replace noneditionable type body ut_data_value_boolean as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_boolean.tps b/source/expectations/data_values/ut_data_value_boolean.tps index 4d7af837b..35c05b384 100644 --- a/source/expectations/data_values/ut_data_value_boolean.tps +++ b/source/expectations/data_values/ut_data_value_boolean.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_boolean under ut_data_value( +create or replace noneditionable type ut_data_value_boolean under ut_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_clob.tpb b/source/expectations/data_values/ut_data_value_clob.tpb index 2dd00c023..6d5a9764d 100644 --- a/source/expectations/data_values/ut_data_value_clob.tpb +++ b/source/expectations/data_values/ut_data_value_clob.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_clob as +create or replace noneditionable type body ut_data_value_clob as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_clob.tps b/source/expectations/data_values/ut_data_value_clob.tps index abcc635c9..8027e4481 100644 --- a/source/expectations/data_values/ut_data_value_clob.tps +++ b/source/expectations/data_values/ut_data_value_clob.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_clob under ut_data_value( +create or replace noneditionable type ut_data_value_clob under ut_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_date.tpb b/source/expectations/data_values/ut_data_value_date.tpb index dc1c4d22f..f6a588940 100644 --- a/source/expectations/data_values/ut_data_value_date.tpb +++ b/source/expectations/data_values/ut_data_value_date.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_date as +create or replace noneditionable type body ut_data_value_date as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_date.tps b/source/expectations/data_values/ut_data_value_date.tps index 8db1850c2..7e3379f31 100644 --- a/source/expectations/data_values/ut_data_value_date.tps +++ b/source/expectations/data_values/ut_data_value_date.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_date under ut_data_value( +create or replace noneditionable type ut_data_value_date under ut_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_dsinterval.tpb b/source/expectations/data_values/ut_data_value_dsinterval.tpb index bcfb48a2b..a01766425 100644 --- a/source/expectations/data_values/ut_data_value_dsinterval.tpb +++ b/source/expectations/data_values/ut_data_value_dsinterval.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_dsinterval as +create or replace noneditionable type body ut_data_value_dsinterval as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_dsinterval.tps b/source/expectations/data_values/ut_data_value_dsinterval.tps index 5add4adf9..9fc81bb6a 100644 --- a/source/expectations/data_values/ut_data_value_dsinterval.tps +++ b/source/expectations/data_values/ut_data_value_dsinterval.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_dsinterval under ut_data_value( +create or replace noneditionable type ut_data_value_dsinterval under ut_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_json.tpb b/source/expectations/data_values/ut_data_value_json.tpb index 9f65ef618..da4f3ac79 100644 --- a/source/expectations/data_values/ut_data_value_json.tpb +++ b/source/expectations/data_values/ut_data_value_json.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_json as +create or replace noneditionable type body ut_data_value_json as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_json.tps b/source/expectations/data_values/ut_data_value_json.tps index 46a78e00e..e8778051b 100644 --- a/source/expectations/data_values/ut_data_value_json.tps +++ b/source/expectations/data_values/ut_data_value_json.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_json under ut_compound_data_value( +create or replace noneditionable type ut_data_value_json under ut_compound_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_number.tpb b/source/expectations/data_values/ut_data_value_number.tpb index 53b8ce413..da17e51c9 100644 --- a/source/expectations/data_values/ut_data_value_number.tpb +++ b/source/expectations/data_values/ut_data_value_number.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_number as +create or replace noneditionable type body ut_data_value_number as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_number.tps b/source/expectations/data_values/ut_data_value_number.tps index 914252b9f..8bd590515 100644 --- a/source/expectations/data_values/ut_data_value_number.tps +++ b/source/expectations/data_values/ut_data_value_number.tps @@ -1,10 +1,10 @@ -create or replace type ut_data_value_number under ut_data_value( +create or replace noneditionable type ut_data_value_number under ut_data_value( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index ee1408b56..af6d1791b 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_data_value_refcursor as +create or replace noneditionable type body ut_data_value_refcursor as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -51,12 +51,8 @@ create or replace type body ut_data_value_refcursor as loop l_xml := dbms_xmlgen.getxmltype(l_ctx); exit when dbms_xmlgen.getNumRowsProcessed(l_ctx) = 0; - --Bug in oracle 12.2+ where XML binary storage trimming insignificant whitespaces. - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - l_xml := xmltype( replace(l_xml.getClobVal(),'= 2 - or dbms_db_version.version > 12 - then - :V_FILE_NAME := '&&FILE_NAME'; - else - :V_FILE_NAME := 'dummy.sql'; - end if; -end; -/ - -set verify off -select :V_FILE_NAME as SCRIPT_NAME from dual; -set termout on - -set heading off -set feedback off -exec dbms_output.put_line('Installing component '||upper(regexp_substr('&&1','\/(\w*)\.',1,1,'i',1))); -@@&&SCRIPT_NAME -exec dbms_output.put_line('&&line_separator'); - - - diff --git a/source/install_component.sql b/source/install_component.sql index 1189df496..a7394fe9a 100644 --- a/source/install_component.sql +++ b/source/install_component.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/install_ddl_trigger.sql b/source/install_ddl_trigger.sql index b23b4bc63..a9ede374f 100644 --- a/source/install_ddl_trigger.sql +++ b/source/install_ddl_trigger.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/install_headless.sql b/source/install_headless.sql index be1e5becf..04c0109b0 100644 --- a/source/install_headless.sql +++ b/source/install_headless.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/install_headless_with_trigger.sql b/source/install_headless_with_trigger.sql index 2c05403c5..7953b0205 100644 --- a/source/install_headless_with_trigger.sql +++ b/source/install_headless_with_trigger.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_ansiconsole_helper.pkb b/source/reporters/ut_ansiconsole_helper.pkb index 46960cf5c..b6610b778 100644 --- a/source/reporters/ut_ansiconsole_helper.pkb +++ b/source/reporters/ut_ansiconsole_helper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_ansiconsole_helper as +create or replace noneditionable package body ut_ansiconsole_helper as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_ansiconsole_helper.pks b/source/reporters/ut_ansiconsole_helper.pks index fd4549965..f06f96a7e 100644 --- a/source/reporters/ut_ansiconsole_helper.pks +++ b/source/reporters/ut_ansiconsole_helper.pks @@ -1,10 +1,10 @@ -create or replace package ut_ansiconsole_helper as +create or replace noneditionable package ut_ansiconsole_helper as /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_coverage_cobertura_reporter.tpb b/source/reporters/ut_coverage_cobertura_reporter.tpb index 833ca09be..36c22c68b 100644 --- a/source/reporters/ut_coverage_cobertura_reporter.tpb +++ b/source/reporters/ut_coverage_cobertura_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_coverage_cobertura_reporter is +create or replace noneditionable type body ut_coverage_cobertura_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -181,10 +181,9 @@ create or replace type body ut_coverage_cobertura_reporter is overriding member function get_description return varchar2 as begin - return 'Generates a Cobertura coverage report providing information on code coverage with line numbers.' || chr(10) || - 'Designed for Jenkins and TFS to report coverage. ' || chr(10) || - 'Cobertura Document Type Definition can be found: http://cobertura.sourceforge.net/xml/coverage-04.dtd.'|| chr(10) || - 'Sample file: https://github.com/leobalter/testing-examples/blob/master/solutions/3/report/cobertura-coverage.xml.'; + return 'Generates Cobertura report on code coverage with line numbers. +Compatible with GitHub Actions, Jenkins, Azure Pipelines, GitLab CI, and any tool that reads the popular Cobertura format. +Cobertura Document Type Definition is located [here](https://github.com/cobertura/cobertura/blob/master/cobertura/src/site/htdocs/xml/coverage-04.dtd).'; end; end; diff --git a/source/reporters/ut_coverage_cobertura_reporter.tps b/source/reporters/ut_coverage_cobertura_reporter.tps index ee2d9b71d..8e4586c38 100644 --- a/source/reporters/ut_coverage_cobertura_reporter.tps +++ b/source/reporters/ut_coverage_cobertura_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_coverage_cobertura_reporter under ut_coverage_reporter_base( +create or replace noneditionable type ut_coverage_cobertura_reporter under ut_coverage_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_coverage_html_reporter.tpb b/source/reporters/ut_coverage_html_reporter.tpb index 253c067e5..49f412cb1 100644 --- a/source/reporters/ut_coverage_html_reporter.tpb +++ b/source/reporters/ut_coverage_html_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_coverage_html_reporter is +create or replace noneditionable type body ut_coverage_html_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -39,7 +39,8 @@ create or replace type body ut_coverage_html_reporter is a_coverage_data => l_coverage_data, a_assets_path => self.assets_path, a_project_name => self.project_name, - a_charset => a_run.client_character_set + a_charset => a_run.client_character_set, + a_support_info => a_run.get_support_info_flag() ) ); end; diff --git a/source/reporters/ut_coverage_html_reporter.tps b/source/reporters/ut_coverage_html_reporter.tps index db65e1e00..13365efe9 100644 --- a/source/reporters/ut_coverage_html_reporter.tps +++ b/source/reporters/ut_coverage_html_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_coverage_html_reporter under ut_coverage_reporter_base( +create or replace noneditionable type ut_coverage_html_reporter under ut_coverage_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_coverage_report_html_helper.pkb b/source/reporters/ut_coverage_report_html_helper.pkb index d81211f03..2ab989eea 100644 --- a/source/reporters/ut_coverage_report_html_helper.pkb +++ b/source/reporters/ut_coverage_report_html_helper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_coverage_report_html_helper is +create or replace noneditionable package body ut_coverage_report_html_helper is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -285,7 +285,8 @@ create or replace package body ut_coverage_report_html_helper is a_assets_path varchar2, a_project_name varchar2 := null, a_command_line varchar2 := null, - a_charset varchar2 := null + a_charset varchar2 := null, + a_support_info boolean := true ) return ut_varchar2_rows is l_file_part varchar2(32767); @@ -329,9 +330,12 @@ create or replace package body ut_coverage_report_html_helper is ut_utils.append_to_list(l_result, file_list('All files', a_coverage_data)); l_file_part := chr(10) || '
'; ut_utils.append_to_list(l_result, l_file_part); diff --git a/source/reporters/ut_coverage_report_html_helper.pks b/source/reporters/ut_coverage_report_html_helper.pks index c028168a8..a6dd7eb30 100644 --- a/source/reporters/ut_coverage_report_html_helper.pks +++ b/source/reporters/ut_coverage_report_html_helper.pks @@ -1,10 +1,10 @@ -create or replace package ut_coverage_report_html_helper authid current_user is +create or replace noneditionable package ut_coverage_report_html_helper authid current_user is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -36,7 +36,8 @@ create or replace package ut_coverage_report_html_helper authid current_user is a_assets_path varchar2, a_project_name varchar2 := null, a_command_line varchar2 := null, - a_charset varchar2 := null + a_charset varchar2 := null, + a_support_info boolean := true ) return ut_varchar2_rows; end; diff --git a/source/reporters/ut_coverage_sonar_reporter.tpb b/source/reporters/ut_coverage_sonar_reporter.tpb index 8148fc7fc..8eb4c57aa 100644 --- a/source/reporters/ut_coverage_sonar_reporter.tpb +++ b/source/reporters/ut_coverage_sonar_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_coverage_sonar_reporter is +create or replace noneditionable type body ut_coverage_sonar_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -103,9 +103,9 @@ create or replace type body ut_coverage_sonar_reporter is overriding member function get_description return varchar2 as begin - return 'Generates a XML coverage report providing information on code coverage with line numbers.' || chr(10) || - 'Designed for [SonarQube](https://www.sonarqube.org/) to report coverage.' || chr(10) || - 'XML format returned conforms with the Sonar specification: https://docs.sonarqube.org/latest/analysis/generic-test/'; + return 'Generates an XML coverage report providing information on code coverage with line numbers. +Designed for [SonarQube](https://www.sonarsource.com/products/sonarqube/) to report coverage. +XML format returned conforms with the [Sonar specification](https://docs.sonarsource.com/sonarqube-server/analyzing-source-code/test-coverage/generic-test-data).'; end; end; diff --git a/source/reporters/ut_coverage_sonar_reporter.tps b/source/reporters/ut_coverage_sonar_reporter.tps index b5e964a3a..0268fee64 100644 --- a/source/reporters/ut_coverage_sonar_reporter.tps +++ b/source/reporters/ut_coverage_sonar_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_coverage_sonar_reporter under ut_coverage_reporter_base( +create or replace noneditionable type ut_coverage_sonar_reporter under ut_coverage_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_coveralls_reporter.tpb b/source/reporters/ut_coveralls_reporter.tpb deleted file mode 100644 index fc459c906..000000000 --- a/source/reporters/ut_coveralls_reporter.tpb +++ /dev/null @@ -1,104 +0,0 @@ -create or replace type body ut_coveralls_reporter is - /* - utPLSQL - Version 3 - Copyright 2016 - 2026 utPLSQL Project - - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - - constructor function ut_coveralls_reporter( - self in out nocopy ut_coveralls_reporter - ) return self as result is - begin - self.init($$plsql_unit,ut_output_bulk_buffer()); - return; - end; - - overriding member procedure after_calling_run(self in out nocopy ut_coveralls_reporter, a_run in ut_run) as - - function get_lines_json(a_unit_coverage ut_coverage.t_unit_coverage) return ut_varchar2_rows is - l_file_part varchar2(32767); - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_last_line_no binary_integer; - c_coverage_header constant varchar2(30) := '"coverage": ['; - c_null constant varchar2(4) := 'null'; - begin - ut_utils.append_to_list(l_result, c_coverage_header); - - l_last_line_no := a_unit_coverage.lines.last; - if l_last_line_no is null then - ut_utils.append_to_list( - l_result - , rpad( to_clob( '0' ), ( a_unit_coverage.total_lines * 3 ) - 2, ','||chr(10)||'0' ) - ); - else - for line_no in 1 .. l_last_line_no loop - if a_unit_coverage.lines.exists(line_no) then - l_file_part := to_char(a_unit_coverage.lines(line_no).executions); - else - l_file_part := c_null; - end if; - if line_no < l_last_line_no then - l_file_part := l_file_part ||','; - end if; - ut_utils.append_to_list(l_result, l_file_part); - end loop; - end if; - ut_utils.append_to_list(l_result, ']'); - return l_result; - end; - - function get_coverage_json( - a_coverage_data ut_coverage.t_coverage - ) return ut_varchar2_rows is - l_result ut_varchar2_rows := ut_varchar2_rows(); - l_unit ut_coverage.t_object_name; - c_coverage_header constant varchar2(30) := '{"source_files":['; - c_coverage_footer constant varchar2(30) := ']}'||chr(10)||' '; - begin - ut_utils.append_to_list(l_result, c_coverage_header); - l_unit := a_coverage_data.objects.first; - while l_unit is not null loop - ut_utils.append_to_list(l_result, '{ "name": "'||l_unit||'",'); - - ut_utils.append_to_list(l_result,get_lines_json(a_coverage_data.objects(l_unit))); - - ut_utils.append_to_list(l_result, '}'); - - l_unit := a_coverage_data.objects.next(l_unit); - if l_unit is not null then - ut_utils.append_to_list(l_result, ','); - end if; - end loop; - ut_utils.append_to_list(l_result, c_coverage_footer); - return l_result; - end; - begin - ut_coverage.coverage_stop(); - - self.print_text_lines( - get_coverage_json( - ut_coverage.get_coverage_data(a_run.coverage_options) - ) - ); - end; - - overriding member function get_description return varchar2 as - begin - return 'Generates a JSON coverage report providing information on code coverage with line numbers.' || chr(10) || - 'Designed for [Coveralls](https://coveralls.io/).' || chr(10) || - 'JSON format conforms with specification: https://docs.coveralls.io/api-introduction'; - end; - -end; -/ diff --git a/source/reporters/ut_coveralls_reporter.tps b/source/reporters/ut_coveralls_reporter.tps deleted file mode 100644 index e547793d1..000000000 --- a/source/reporters/ut_coveralls_reporter.tps +++ /dev/null @@ -1,31 +0,0 @@ -create or replace type ut_coveralls_reporter under ut_coverage_reporter_base( - /* - utPLSQL - Version 3 - Copyright 2016 - 2026 utPLSQL Project - - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - - /** - * Builds a coverage XML report that follows rules described in - * https://docs.coveralls.io/api-introduction - */ - constructor function ut_coveralls_reporter( - self in out nocopy ut_coveralls_reporter - ) return self as result, - - overriding member procedure after_calling_run(self in out nocopy ut_coveralls_reporter, a_run in ut_run), - - overriding member function get_description return varchar2 -) -/ diff --git a/source/reporters/ut_debug_reporter.tpb b/source/reporters/ut_debug_reporter.tpb index b17f039ea..a2b797021 100644 --- a/source/reporters/ut_debug_reporter.tpb +++ b/source/reporters/ut_debug_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_debug_reporter is +create or replace noneditionable type body ut_debug_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_debug_reporter.tps b/source/reporters/ut_debug_reporter.tps index 85c0eeb54..26e42cbc4 100644 --- a/source/reporters/ut_debug_reporter.tps +++ b/source/reporters/ut_debug_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_debug_reporter under ut_output_reporter_base( +create or replace noneditionable type ut_debug_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_documentation_reporter.tpb b/source/reporters/ut_documentation_reporter.tpb index 489b6efd2..ad3d1fb69 100644 --- a/source/reporters/ut_documentation_reporter.tpb +++ b/source/reporters/ut_documentation_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_documentation_reporter is +create or replace noneditionable type body ut_documentation_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -216,13 +216,16 @@ create or replace type body ut_documentation_reporter is if a_run.random_test_order_seed is not null then self.print_text('Tests were executed with random order seed '''||a_run.random_test_order_seed||'''.'); end if; + if a_run.get_support_info_flag() then + self.print_cyan_text(ut_utils.gc_support_text || ': ' || ut_utils.gc_support_url); + end if; self.print_text(' '); (self as ut_reporter_base).after_calling_run(a_run); end; overriding member function get_description return varchar2 as begin - return 'A textual pretty-print of unit test results (usually use for console output)'; + return 'Creates a textual, pretty-print, human-readable report mirroring the suite hierarchy. Used for console runs, interactive development and log review.'; end; end; diff --git a/source/reporters/ut_documentation_reporter.tps b/source/reporters/ut_documentation_reporter.tps index 23b86226f..52a7911ce 100644 --- a/source/reporters/ut_documentation_reporter.tps +++ b/source/reporters/ut_documentation_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_documentation_reporter under ut_console_reporter_base( +create or replace noneditionable type ut_documentation_reporter under ut_console_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_junit_reporter.tpb b/source/reporters/ut_junit_reporter.tpb index a2cffd287..e7741926d 100644 --- a/source/reporters/ut_junit_reporter.tpb +++ b/source/reporters/ut_junit_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_junit_reporter is +create or replace noneditionable type body ut_junit_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_junit_reporter.tps b/source/reporters/ut_junit_reporter.tps index 5999c33f5..88292acbb 100644 --- a/source/reporters/ut_junit_reporter.tps +++ b/source/reporters/ut_junit_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_junit_reporter force under ut_output_reporter_base( +create or replace noneditionable type ut_junit_reporter force under ut_output_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_realtime_reporter.tpb b/source/reporters/ut_realtime_reporter.tpb index fac7cd9b8..b0ec5d2e2 100644 --- a/source/reporters/ut_realtime_reporter.tpb +++ b/source/reporters/ut_realtime_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_realtime_reporter is +create or replace noneditionable type body ut_realtime_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -204,11 +204,6 @@ create or replace type body ut_realtime_reporter is self.flush_print_buffer('post-test'); end after_calling_test; - overriding member function get_description return varchar2 is - begin - return 'Provides test results in a XML format, for clients such as SQL Developer interested in showing progressing details.'; - end get_description; - member procedure print_start_node( self in out nocopy ut_realtime_reporter, a_node_name in varchar2, @@ -284,5 +279,10 @@ create or replace type body ut_realtime_reporter is print_buffer.delete; end flush_print_buffer; + overriding member function get_description return varchar2 is + begin + return 'Provides live test execution progress that can be consumed from another session, enabling clients such as SQL Developer to show progress in real time as tests run.'; + end get_description; + end; / diff --git a/source/reporters/ut_realtime_reporter.tps b/source/reporters/ut_realtime_reporter.tps index 5ab350162..7efdd1bb3 100644 --- a/source/reporters/ut_realtime_reporter.tps +++ b/source/reporters/ut_realtime_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_realtime_reporter force under ut_output_reporter_base( +create or replace noneditionable type ut_realtime_reporter force under ut_output_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_sonar_test_reporter.tpb b/source/reporters/ut_sonar_test_reporter.tpb index dfa6a7421..6b8003ecb 100644 --- a/source/reporters/ut_sonar_test_reporter.tpb +++ b/source/reporters/ut_sonar_test_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_sonar_test_reporter is +create or replace noneditionable type body ut_sonar_test_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -106,9 +106,9 @@ create or replace type body ut_sonar_test_reporter is overriding member function get_description return varchar2 as begin - return 'Generates a XML report providing detailed information on test execution.' || chr(10) || - 'Designed for [SonarQube](https://www.sonarqube.org/) to report test execution.' || chr(10) || - 'XML format returned conforms with the Sonar specification: https://docs.sonarqube.org/latest/analysis/generic-test/'; + return 'Generates an XML report providing detailed information on test execution. +Designed for [SonarQube](https://www.sonarsource.com/products/sonarqube/) to report test execution. +XML format returned conforms with the [Sonar specification](https://docs.sonarsource.com/sonarqube-server/analyzing-source-code/test-coverage/generic-test-data).'; end; end; diff --git a/source/reporters/ut_sonar_test_reporter.tps b/source/reporters/ut_sonar_test_reporter.tps index d9f98071d..f7f5aeb39 100644 --- a/source/reporters/ut_sonar_test_reporter.tps +++ b/source/reporters/ut_sonar_test_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_sonar_test_reporter under ut_output_reporter_base( +create or replace noneditionable type ut_sonar_test_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_tap_reporter.tpb b/source/reporters/ut_tap_reporter.tpb index 02246b97e..e1b3b617d 100644 --- a/source/reporters/ut_tap_reporter.tpb +++ b/source/reporters/ut_tap_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_tap_reporter is +create or replace noneditionable type body ut_tap_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -25,7 +25,7 @@ create or replace type body ut_tap_reporter is 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')); + self.print_clob(regexp_replace(a_comment, '^(.+)', '# \1', 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 @@ -134,6 +134,9 @@ create or replace type body ut_tap_reporter is overriding member procedure after_calling_run(self in out nocopy ut_tap_reporter, a_run in ut_run) as begin self.lvl := 0; + if a_run.get_support_info_flag() then + self.print_comment(ut_utils.gc_support_text || ': ' || ut_utils.gc_support_url); + end if; end; end; / diff --git a/source/reporters/ut_tap_reporter.tps b/source/reporters/ut_tap_reporter.tps index 94423b6fc..127256cf8 100644 --- a/source/reporters/ut_tap_reporter.tps +++ b/source/reporters/ut_tap_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_tap_reporter under ut_documentation_reporter( +create or replace noneditionable type ut_tap_reporter under ut_documentation_reporter( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_teamcity_reporter.tpb b/source/reporters/ut_teamcity_reporter.tpb index 2e09c7103..2e76e3e3f 100644 --- a/source/reporters/ut_teamcity_reporter.tpb +++ b/source/reporters/ut_teamcity_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_teamcity_reporter is +create or replace noneditionable type body ut_teamcity_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_teamcity_reporter.tps b/source/reporters/ut_teamcity_reporter.tps index e5c43b59e..e70ad4a4b 100644 --- a/source/reporters/ut_teamcity_reporter.tps +++ b/source/reporters/ut_teamcity_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_teamcity_reporter under ut_output_reporter_base( +create or replace noneditionable type ut_teamcity_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_teamcity_reporter_helper.pkb b/source/reporters/ut_teamcity_reporter_helper.pkb index 575af645d..ac9d4b567 100644 --- a/source/reporters/ut_teamcity_reporter_helper.pkb +++ b/source/reporters/ut_teamcity_reporter_helper.pkb @@ -1,10 +1,10 @@ -create or replace package body ut_teamcity_reporter_helper is +create or replace noneditionable package body ut_teamcity_reporter_helper is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_teamcity_reporter_helper.pks b/source/reporters/ut_teamcity_reporter_helper.pks index 727d02913..03c655c33 100644 --- a/source/reporters/ut_teamcity_reporter_helper.pks +++ b/source/reporters/ut_teamcity_reporter_helper.pks @@ -1,10 +1,10 @@ -create or replace package ut_teamcity_reporter_helper is +create or replace noneditionable package ut_teamcity_reporter_helper is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_tfs_junit_reporter.tpb b/source/reporters/ut_tfs_junit_reporter.tpb index 8c2bd6333..38aa41bfa 100644 --- a/source/reporters/ut_tfs_junit_reporter.tpb +++ b/source/reporters/ut_tfs_junit_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_tfs_junit_reporter is +create or replace noneditionable type body ut_tfs_junit_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -171,9 +171,9 @@ create or replace type body ut_tfs_junit_reporter is overriding member function get_description return varchar2 as begin - return 'Provides outcomes in a format conforming with JUnit version for TFS / VSTS. - As defined by specs :https://docs.microsoft.com/en-us/vsts/build-release/tasks/test/publish-test-results?view=vsts - Version is based on windy road junit https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd.'; + return 'Provides outcomes in a format conforming with JUnit version for TFS / VSTS +as defined by [specification](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/publish-test-results-v2?view=azure-pipelines) +The implementation is based on [windyroad junit schema](https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd).'; end; end; diff --git a/source/reporters/ut_tfs_junit_reporter.tps b/source/reporters/ut_tfs_junit_reporter.tps index 3af2226a5..3212085ea 100644 --- a/source/reporters/ut_tfs_junit_reporter.tps +++ b/source/reporters/ut_tfs_junit_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_tfs_junit_reporter under ut_output_reporter_base( +create or replace noneditionable type ut_tfs_junit_reporter under ut_output_reporter_base( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_xunit_reporter.tpb b/source/reporters/ut_xunit_reporter.tpb index 164703917..4b6007994 100644 --- a/source/reporters/ut_xunit_reporter.tpb +++ b/source/reporters/ut_xunit_reporter.tpb @@ -1,10 +1,10 @@ -create or replace type body ut_xunit_reporter is +create or replace noneditionable type body ut_xunit_reporter is /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/reporters/ut_xunit_reporter.tps b/source/reporters/ut_xunit_reporter.tps index 970e4d162..2e7a84f95 100644 --- a/source/reporters/ut_xunit_reporter.tps +++ b/source/reporters/ut_xunit_reporter.tps @@ -1,10 +1,10 @@ -create or replace type ut_xunit_reporter under ut_junit_reporter( +create or replace noneditionable type ut_xunit_reporter under ut_junit_reporter( /* utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/set_install_params.sql b/source/set_install_params.sql index b559b8023..1d58ab09a 100644 --- a/source/set_install_params.sql +++ b/source/set_install_params.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/uninstall.sql b/source/uninstall.sql index 712845fb7..ba1582844 100644 --- a/source/uninstall.sql +++ b/source/uninstall.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/uninstall_all.sql b/source/uninstall_all.sql index d3d3f3fbe..af94716c1 100644 --- a/source/uninstall_all.sql +++ b/source/uninstall_all.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/uninstall_coverage_tables.sql b/source/uninstall_coverage_tables.sql index df3c19627..6912330ae 100644 --- a/source/uninstall_coverage_tables.sql +++ b/source/uninstall_coverage_tables.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 diff --git a/source/uninstall_objects.sql b/source/uninstall_objects.sql index 8ef644aa9..5c6e41dc3 100644 --- a/source/uninstall_objects.sql +++ b/source/uninstall_objects.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -74,8 +74,6 @@ drop synonym be_within; drop synonym be_within_pct; -drop type ut_coveralls_reporter force; - drop type ut_coverage_sonar_reporter force; drop type ut_coverage_cobertura_reporter force; @@ -116,6 +114,8 @@ drop package ut_suite_tag_filter; drop package ut_suite_cache_manager; +drop package ut_suite_cache_macros; + drop table ut_suite_cache purge; drop type ut_suite_cache_rows force; @@ -242,6 +242,8 @@ drop package ut_annotation_parser; drop package ut_annotation_cache_manager; +drop package ut_annotation_cache_macros; + drop table ut_annotation_cache cascade constraints purge; drop table ut_annotation_cache_info cascade constraints purge; @@ -275,12 +277,6 @@ begin $if dbms_db_version.version < 21 $then begin execute immediate 'drop type json force'; exception when others then null; end; $end - $if dbms_db_version.version = 12 and dbms_db_version.release = 1 or dbms_db_version.version < 12 $then - begin execute immediate 'drop type json_element_t force'; exception when others then null; end; - begin execute immediate 'drop type json_object_t force'; exception when others then null; end; - begin execute immediate 'drop type json_array_t force'; exception when others then null; end; - begin execute immediate 'drop type json_key_list force'; exception when others then null; end; - $end end; / @@ -419,7 +415,7 @@ set feedback off declare i integer := 0; begin - dbms_output.put_line('Dropping packages created for 12.2+ ' || upper('&&ut3_owner')); + dbms_output.put_line('Dropping block coverage packages ' || upper('&&ut3_owner')); for pkg in ( select object_name, owner from all_objects @@ -446,3 +442,15 @@ begin dbms_output.put_line(i || ' packages dropped'); end; / + +declare + e_role_not_exists exception; + pragma exception_init(e_role_not_exists, -1919); +begin + execute immediate 'drop role &&ut3_owner._cbac_modify_objects_role'; + dbms_output.put_line('Role ' || upper('&&ut3_owner._cbac_modify_objects_role') || ' dropped'); +exception + when e_role_not_exists then + dbms_output.put_line('Role ' || upper('&&ut3_owner._cbac_modify_objects_role') || ' does not exist'); +end; +/ diff --git a/source/uninstall_synonyms.sql b/source/uninstall_synonyms.sql index 4a12340f6..783ac51e8 100644 --- a/source/uninstall_synonyms.sql +++ b/source/uninstall_synonyms.sql @@ -2,8 +2,8 @@ utPLSQL - Version 3 Copyright 2016 - 2026 utPLSQL Project - Licensed under the Apache License, Version 2.0 (the "License"): - you may not use this file except in compliance with the License. + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -49,7 +49,7 @@ end; declare i integer := 0; begin - dbms_output.put_line('Dropping synonyms pointing to PL/SQL code coverage objects on 12.2 ' || upper('&&ut3_owner')); + dbms_output.put_line('Dropping synonyms pointing to PL/SQL code coverage objects ' || upper('&&ut3_owner')); for syn in ( select case when owner = 'PUBLIC' then 'public synonym ' diff --git a/source/ut3_cbac_modify_objects_role_grants.sql b/source/ut3_cbac_modify_objects_role_grants.sql new file mode 100644 index 000000000..b8748c46a --- /dev/null +++ b/source/ut3_cbac_modify_objects_role_grants.sql @@ -0,0 +1,62 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2026 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"). + You may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Code based access control for the invoker rights packages ut_annotation_cache_manager, ut_annotation_manager, + ut_suite_cache_manager and ut_suite_manager. + The packages access the annotation and suite cache tables through the role _cbac_modify_objects_role, + directly or through the SQL macros of ut_annotation_cache_macros and ut_suite_cache_macros, + so the users calling the framework do not need any privileges on those tables. + The types and packages used in SQL statements of those packages are granted to the role too, + so they do not need to be granted to the users calling the framework. +*/ + +prompt Granting privileges to role &&ut3_owner._cbac_modify_objects_role + +--annotation cache +grant select, insert, update, delete on &&ut3_owner..ut_annotation_cache to &&ut3_owner._cbac_modify_objects_role; +grant select, insert, update, delete on &&ut3_owner..ut_annotation_cache_info to &&ut3_owner._cbac_modify_objects_role; +grant select, insert, update, delete on &&ut3_owner..ut_annotation_cache_schema to &&ut3_owner._cbac_modify_objects_role; +grant select on &&ut3_owner..ut_annotation_cache_seq to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_annotation_obj_cache_info to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_annotated_object to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_annotation to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_annotations to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_annotation_cache_macros to &&ut3_owner._cbac_modify_objects_role; + +--suite cache +grant select, insert, update, delete on &&ut3_owner..ut_suite_cache to &&ut3_owner._cbac_modify_objects_role; +grant select, insert, update, delete on &&ut3_owner..ut_suite_cache_package to &&ut3_owner._cbac_modify_objects_role; +grant select, insert, update, delete on &&ut3_owner..ut_suite_cache_schema to &&ut3_owner._cbac_modify_objects_role; +grant select on &&ut3_owner..ut_suite_cache_seq to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_suite_cache_row to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_suite_item_info to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_suite to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_test to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_executables to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_executable_test to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_varchar2_rows to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_integer_list to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_path_item to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_object_name to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_utils to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_suite_tag_filter to &&ut3_owner._cbac_modify_objects_role; +grant execute on &&ut3_owner..ut_suite_cache_macros to &&ut3_owner._cbac_modify_objects_role; + +grant &&ut3_owner._cbac_modify_objects_role to package &&ut3_owner..ut_annotation_cache_manager; +grant &&ut3_owner._cbac_modify_objects_role to package &&ut3_owner..ut_annotation_manager; +grant &&ut3_owner._cbac_modify_objects_role to package &&ut3_owner..ut_suite_cache_manager; +grant &&ut3_owner._cbac_modify_objects_role to package &&ut3_owner..ut_suite_manager; + diff --git a/test/install_above_12_1.sql b/test/install_above_12_1.sql deleted file mode 100644 index fe20cf816..000000000 --- a/test/install_above_12_1.sql +++ /dev/null @@ -1,28 +0,0 @@ -set termout off -set echo off -spool dummy.sql -prompt whenever sqlerror exit failure rollback -spool off - - -def FILE_NAME = '&&1' -column SCRIPT_NAME new_value SCRIPT_NAME noprint - -VAR V_FILE_NAME VARCHAR2(1000); -begin - if dbms_db_version.version = 12 and dbms_db_version.release >= 2 - or dbms_db_version.version > 12 - then - :V_FILE_NAME := '&&FILE_NAME'; - else - :V_FILE_NAME := 'dummy.sql'; - end if; -end; -/ -set verify off -select :V_FILE_NAME as SCRIPT_NAME from dual; -set termout on - - -@@&&SCRIPT_NAME - diff --git a/test/install_and_run_tests.sh b/test/install_and_run_tests.sh index 0c17b08b7..24932d663 100755 --- a/test/install_and_run_tests.sh +++ b/test/install_and_run_tests.sh @@ -1,9 +1,10 @@ #!/bin/bash -set -ev +set -e #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" . ./development/env.sh +set -v cd test time . ./install_tests.sh diff --git a/test/install_below_12_2.sql b/test/install_below_12_2.sql deleted file mode 100644 index 669ae75fc..000000000 --- a/test/install_below_12_2.sql +++ /dev/null @@ -1,28 +0,0 @@ -set termout off -set echo off -spool dummy.sql -prompt whenever sqlerror exit failure rollback -spool off - - -def FILE_NAME = '&&1' -column SCRIPT_NAME new_value SCRIPT_NAME noprint - -VAR V_FILE_NAME VARCHAR2(1000); -begin - if dbms_db_version.version = 12 and dbms_db_version.release < 2 - or dbms_db_version.version < 12 - then - :V_FILE_NAME := '&&FILE_NAME'; - else - :V_FILE_NAME := 'dummy.sql'; - end if; -end; -/ -set verify off -select :V_FILE_NAME as SCRIPT_NAME from dual; -set termout on - - -@@&&SCRIPT_NAME - diff --git a/test/install_ut3_tester_tests.sql b/test/install_ut3_tester_tests.sql index cc96b2b64..fa1331e00 100644 --- a/test/install_ut3_tester_tests.sql +++ b/test/install_ut3_tester_tests.sql @@ -25,6 +25,8 @@ alter session set plsql_optimize_level=0; @@ut3_tester/core/test_file_mapper.pks @@ut3_tester/core/test_output_buffer.pks @@ut3_tester/core/test_suite_builder.pks +@@ut3_tester/core/test_ut_metadata.pks +@@ut3_tester/core/test_coverage_report_html_helper.pks @@ut3_tester/core.pkb @@ -44,6 +46,8 @@ alter session set plsql_optimize_level=0; @@ut3_tester/core/test_file_mapper.pkb @@ut3_tester/core/test_output_buffer.pkb @@ut3_tester/core/test_suite_builder.pkb +@@ut3_tester/core/test_ut_metadata.pkb +@@ut3_tester/core/test_coverage_report_html_helper.pkb diff --git a/test/install_ut3_user_tests.sql b/test/install_ut3_user_tests.sql index 518e07841..36966b3f6 100644 --- a/test/install_ut3_user_tests.sql +++ b/test/install_ut3_user_tests.sql @@ -30,9 +30,7 @@ prompt Install user tests @@ut3_user/expectations/test_matchers.pks @@ut3_user/expectations/test_expectation_anydata.pks @@ut3_user/expectations/test_expectations_cursor.pks -set define on -@@install_above_12_1.sql 'ut3_user/expectations/test_expectations_json.pks' -set define off +@@ut3_user/expectations/test_expectations_json.pks @@ut3_user/api/test_ut_runner.pks @@ut3_user/api/test_ut_run.pks @@ut3_user/reporters.pks @@ -50,7 +48,6 @@ set define on @@ut3_user/reporters/test_coverage/test_extended_coverage.pks @@ut3_user/reporters/test_coverage/test_html_coverage_reporter.pks set define off -@@ut3_user/reporters/test_coverage/test_coveralls_reporter.pks @@ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pks @@ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pks set define on @@ -74,9 +71,7 @@ set define off @@ut3_user/expectations/test_matchers.pkb @@ut3_user/expectations/test_expectation_anydata.pkb @@ut3_user/expectations/test_expectations_cursor.pkb -set define on -@@install_above_12_1.sql 'ut3_user/expectations/test_expectations_json.pkb' -set define off +@@ut3_user/expectations/test_expectations_json.pkb @@ut3_user/api/test_ut_runner.pkb @@ut3_user/api/test_ut_run.pkb @@ut3_user/reporters.pkb @@ -93,7 +88,6 @@ set define on @@ut3_user/reporters/test_coverage/test_extended_coverage.pkb @@ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb set define off -@@ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb @@ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb @@ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb set define on diff --git a/test/run_tests.sh b/test/run_tests.sh index 7d0431aec..1a6970283 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -2,7 +2,7 @@ set -ev #goto git root directory -git rev-parse && cd "$(git rev-parse --show-cdup)" +git rev-parse && cd "$(git rev-parse --show-toplevel)" export NLS_LANG=AMERICAN_AMERICA.AL32UTF8 @@ -17,7 +17,6 @@ time utPLSQL-cli/bin/utplsql run UT3_TESTER_HELPER/ut3@//${CONNECTION_STR} -D \ -f=ut_coverage_sonar_reporter -o=coverage.xml \ -f=ut_coverage_cobertura_reporter -o=cobertura.xml \ -f=ut_coverage_html_reporter -o=coverage.html \ --f=ut_coveralls_reporter -o=coverage.json \ -f=ut_sonar_test_reporter -o=test_results.xml \ -f=ut_junit_reporter -o=junit_test_results.xml \ -f=ut_tfs_junit_reporter -o=tfs_test_results.xml \ diff --git a/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb b/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb index ac51d3a49..761377765 100644 --- a/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb +++ b/test/ut3_tester/core/annotations/test_annot_throws_exception.pkb @@ -1,6 +1,7 @@ create or replace package body test_annot_throws_exception is g_tests_results clob; + g_results_other_schema clob; procedure recollect_tests_results is pragma autonomous_transaction; @@ -25,10 +26,18 @@ is e_some_exception exception; pragma exception_init(e_some_exception, -20207); - end;]'; + end; + ]'; - l_package_spec := ' - create package annotated_package_with_throws is + l_package_spec := q'[ + create or replace package annotated_package_with_throws is + + c_local_error_no constant number := -20211; + e_some_local_exception exception; + pragma exception_init(e_some_local_exception, -20212); + + e_uninitialized_exception_variable exception; + --%suite(Dummy package to test annotation throws) --%test(Throws same annotated exception) @@ -95,6 +104,22 @@ is --%throws(exc_pkg.c_e_mix_missin,utter_rubbish) procedure mixed_list_notexi; + --%test(Success referencing an exception variable when running from another schema) + --%throws(exc_pkg.e_some_exception) + procedure named_exc_pragma_run_from_another_schema; + + --%test(Success referencing a numeric exception variable when running from another schema) + --%throws(exc_pkg.c_e_list_1) + procedure exc_number_var_run_from_another_schema; + + --%test(Success referencing an exception variable without package name when running from another schema) + --%throws(e_some_local_exception) + procedure named_exc_pragma_run_from_another_schema_no_package_name; + + --%test(Success referencing a numeric exception variable without package name when running from another schema) + --%throws(c_local_error_no) + procedure exc_number_var_run_from_another_schema_no_package_name; + --%test(Success resolve and match named exception defined in pragma exception init) --%throws(exc_pkg.e_some_exception) procedure named_exc_pragma; @@ -122,11 +147,20 @@ is --%test(Bad exception constant) --%throws(exc_pkg.c_e_dummy); procedure bad_exc_const; + + --%test(Uninitialized exception variable can be used successfully in a test) + --%throws(e_uninitialized_exception_variable) + procedure referencing_uninitialized_exception; + + --%test(Failure report shows all expected exceptions) + --%throws(c_local_error_no,e_some_local_exception,e_uninitialized_exception_variable) + procedure not_throwing_expected_exceptions; + end; - '; + ]'; l_package_body := ' - create package body annotated_package_with_throws is + create or replace package body annotated_package_with_throws is procedure raised_same_exception is begin raise_application_error(-20145, ''Test error''); @@ -208,6 +242,26 @@ is raise_application_error(exc_pkg.c_e_mix_missin,''Test''); end; + procedure named_exc_pragma_run_from_another_schema is + begin + raise exc_pkg.e_some_exception; + end; + + procedure exc_number_var_run_from_another_schema is + begin + raise_application_error(exc_pkg.c_e_list_1,''Test''); + end; + + procedure named_exc_pragma_run_from_another_schema_no_package_name is + begin + raise e_some_local_exception; + end; + + procedure exc_number_var_run_from_another_schema_no_package_name is + begin + raise_application_error(c_local_error_no,''Test''); + end; + procedure named_exc_pragma is begin raise exc_pkg.e_some_exception; @@ -243,6 +297,15 @@ is raise_application_error(-20143, ''Test error''); end; + procedure referencing_uninitialized_exception is + begin + raise e_uninitialized_exception_variable; + end; + + procedure not_throwing_expected_exceptions is + begin + raise_application_error(-20143, ''Test error''); + end; end; '; @@ -256,6 +319,14 @@ is g_tests_results := ut3_develop.ut_utils.table_to_clob(l_test_results); end; + procedure drop_test_package is + pragma autonomous_transaction; + begin + execute immediate 'drop package annotated_package_with_throws'; + execute immediate 'drop package exc_pkg'; + end; + + procedure throws_same_annotated_except is begin ut.expect(g_tests_results).to_match('^\s*Throws same annotated exception \[[,\.0-9]+ sec\]\s*$','m'); @@ -312,7 +383,7 @@ is procedure one_valid_exception_number is begin - ut.expect(g_tests_results).to_match('^\s*Detects a valid exception number within many invalid ones \[[\.0-9]+ sec\]\s*$','m'); + ut.expect(g_tests_results).to_match('^\s*Detects a valid exception number within many invalid ones \[[,\.0-9]+ sec\]\s*$','m'); ut.expect(g_tests_results).to_match('one_valid_exception_number\s*Invalid parameter value ".*" for "--%throws" annotation. Parameter ignored.','m'); end; @@ -357,7 +428,37 @@ is ut.expect(g_tests_results).to_match('^\s*Success resolve and match named exception defined in pragma exception init \[[,\.0-9]+ sec\]\s*$','m'); ut.expect(g_tests_results).not_to_match('named_exc_pragma'); end; - + + procedure run_from_another_schema is + begin + ut3_tester_helper.run_helper.run(('ut3_tester.annotated_package_with_throws')); + g_results_other_schema := ut3_tester_helper.main_helper.get_dbms_output_as_clob(); + end; + + procedure named_exc_pragma_run_from_another_schema is + begin + ut.expect(g_results_other_schema).to_match('^\s*Success referencing an exception variable when running from another schema \[[,\.0-9]+ sec\]\s*$', 'm'); + ut.expect(g_results_other_schema).not_to_match('named_exc_pragma_run_from_another_schema'); + end; + + procedure named_exc_pragma_run_from_another_schema_no_package_name is + begin + ut.expect(g_results_other_schema).to_match('^\s*Success referencing an exception variable without package name when running from another schema \[[,\.0-9]+ sec\]\s*$', 'm'); + ut.expect(g_results_other_schema).not_to_match('named_exc_pragma_run_from_another_schema_no_package_name'); + end; + + procedure exc_number_var_run_from_another_schema_no_package_name is + begin + ut.expect(g_results_other_schema).to_match('^\s*Success referencing a numeric exception variable without package name when running from another schema \[[,\.0-9]+ sec\]\s*$', 'm'); + ut.expect(g_results_other_schema).not_to_match('exc_number_var_run_from_another_schema_no_package_name'); + end; + + procedure exc_number_var_run_from_another_schema is + begin + ut.expect(g_results_other_schema).to_match('^\s*Success referencing a numeric exception variable when running from another schema \[[,\.0-9]+ sec\]\s*$', 'm'); + ut.expect(g_results_other_schema).not_to_match('exc_number_var_run_from_another_schema'); + end; + procedure named_exc_ora is begin ut.expect(g_tests_results).to_match('^\s*Success resolve and match oracle named exception \[[,\.0-9]+ sec\]\s*$','m'); @@ -392,13 +493,23 @@ is begin ut.expect(g_tests_results).to_match('^\s*Bad exception constant \[[,\.0-9]+ sec\] \(FAILED - [0-9]+\)\s*$','m'); ut.expect(g_tests_results).to_match('bad_exc_const\s*ORA-20143: Test error\s*ORA-06512: at "UT3_TESTER.ANNOTATED_PACKAGE_WITH_THROWS"'); - end; - - procedure drop_test_package is - pragma autonomous_transaction; + end; + + procedure referencing_uninitialized_exception is + l_test_results ut3_develop.ut_varchar2_list; + l_actual clob; begin - execute immediate 'drop package annotated_package_with_throws'; - execute immediate 'drop package exc_pkg'; + select * bulk collect into l_test_results from table(ut3_develop.ut.run(('annotated_package_with_throws.referencing_uninitialized_exception'))); + + l_actual := ut3_develop.ut_utils.table_to_clob(l_test_results); + ut.expect(l_actual).to_match('^\s*Uninitialized exception variable can be used successfully in a test \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect(l_actual).not_to_match('referencing_uninitialized_exception'); + end; + + procedure not_throwing_expected_exceptions is + begin + ut.expect(g_tests_results).to_match('not_throwing_expected_exceptions'); + ut.expect(g_tests_results).to_match('Actual: -20143 was expected to be one of: \(annotated_package_with_throws.e_some_local_exception, annotated_package_with_throws.e_uninitialized_exception_variable, -20211\)'); end; end; diff --git a/test/ut3_tester/core/annotations/test_annot_throws_exception.pks b/test/ut3_tester/core/annotations/test_annot_throws_exception.pks index a9d20183d..a41c18d2b 100644 --- a/test/ut3_tester/core/annotations/test_annot_throws_exception.pks +++ b/test/ut3_tester/core/annotations/test_annot_throws_exception.pks @@ -5,7 +5,11 @@ is --%beforeall procedure recollect_tests_results; - + + --%afterall + procedure drop_test_package; + + --%test(Gives success when annotated number exception is thrown) procedure throws_same_annotated_except; @@ -18,7 +22,7 @@ is --%test(Gives failure when the raised exception is different that the annotated one) procedure throws_diff_annotated_except; - --%test(Ignores when the annotation throws is empty) + --%test(Ignores the throws annotation when it is empty) procedure throws_empty; --%test(Ignores when only bad parameters are passed, the test raise a exception and it shows errored test) @@ -36,7 +40,7 @@ is --%test(Detects a valid exception number within many invalid ones) procedure one_valid_exception_number; - --%test(Gives failure when a exception is expected and nothing is thrown) + --%test(Gives failure when an exception is expected and nothing is thrown) procedure nothing_thrown; --%test(Single exception defined as a constant number in package) @@ -45,19 +49,19 @@ is --%test(Gives success when one of annotated exception using constant is thrown) procedure list_of_exc_constant; - --%test(Gives failure when the raised exception is different that the annotated one using variable) + --%test(Gives failure when the raised exception is different than the annotated one using variable) procedure fail_not_match_exc; - --%test(Success when one of exception from mixed list of number and constant is thrown) + --%test(Success when one of exception from a mixed list of number and constant is thrown) procedure mixed_exc_list; - --%test(Success when match exception even if other variable on list dont exists) + --%test(Success when match exception even if another variable on list doesn't exists) procedure mixed_list_notexi; --%test(Success resolve and match named exception defined in pragma exception init) procedure named_exc_pragma; - - --%test(Success resolve and match oracle named exception no data) + + --%test(Success resolve and match oracle named exception no data) procedure named_exc_ora; --%test(Success resolve and match oracle named exception dup val index) @@ -73,10 +77,32 @@ is procedure non_existing_const; --%test(Bad exception constant) - procedure bad_exc_const; + procedure bad_exc_const; + + --%test(Uninitialized exception variable can be used successfully in a test) + procedure referencing_uninitialized_exception; + + --%test(a Failure report shows all expected exceptions) + procedure not_throwing_expected_exceptions; - --%afterall - procedure drop_test_package; + --%context(referencing exceptions when running from another schema) + + --%beforeall + procedure run_from_another_schema; + + --%test(Success referencing an exception variable when running from another schema) + procedure named_exc_pragma_run_from_another_schema; + + --%test(Success referencing a numeric exception variable when running from another schema) + procedure exc_number_var_run_from_another_schema; + + --%test(Success referencing an exception variable without a package name when running from another schema) + procedure named_exc_pragma_run_from_another_schema_no_package_name; + + --%test(Success referencing a numeric exception variable without a package name when running from another schema) + procedure exc_number_var_run_from_another_schema_no_package_name; + + --%endcontext end; / diff --git a/test/ut3_tester/core/annotations/test_annotation_cache.pkb b/test/ut3_tester/core/annotations/test_annotation_cache.pkb index eefaf8800..36f8f983d 100644 --- a/test/ut3_tester/core/annotations/test_annotation_cache.pkb +++ b/test/ut3_tester/core/annotations/test_annotation_cache.pkb @@ -517,5 +517,134 @@ create or replace package body test_annotation_cache is cache_populated_for_packages( ut_varchar2_rows( 'GRANTED_TEST_SUITE', 'NOT_GRANTED_TEST_SUITE' ) ); end; + procedure user_runs_child_of_hidden_suite is + l_actual clob; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner.child_suite' ); + --Assert + ut.expect( l_actual ).to_be_like( '%parent_suite%child_test%1 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%parent_test%' ); + rollback; + end; + + procedure user_warned_about_hidden_parent is + l_actual clob; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner.child_suite' ); + --Assert + ut.expect( l_actual ).to_be_like( + '%Warnings:%parent_suite%Suite ut3_cache_test_owner.parent_suite is not run, as it does not exist or you have no EXECUTE privilege on it.%' + ); + ut.expect( l_actual ).to_be_like( '%1 tests, 0 failed, 0 errored, 0 disabled, 1 warning(s)%' ); + rollback; + end; + + procedure user_runs_child_without_parent_tags is + l_actual clob; + pragma autonomous_transaction; + begin + --Act - child_suite inherits parent_tag only when parent_suite is accessible + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner', '!parent_tag' ); + --Assert + ut.expect( l_actual ).to_be_like( '%child_test%1 tests, 0 failed%' ); + --Act + l_actual := annotation_cache_helper.run_tests_as( 'ut3_cache_test_owner', 'ut3_cache_test_owner', '!parent_tag' ); + --Assert + ut.expect( l_actual ).not_to_be_like( '%child_test%' ); + ut.expect( l_actual ).not_to_be_like( '%parent_test%' ); + rollback; + end; + + procedure user_runs_hidden_suite_path is + l_actual clob; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner:parent_suite' ); + --Assert + ut.expect( l_actual ).to_be_like( '%child_test%1 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%parent_test%' ); + rollback; + end; + + procedure user_no_empty_logical_suites is + l_actual clob; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.get_suites_info_as( 'ut3_no_extra_priv_user' ); + --Assert + ut.expect( l_actual ).to_be_like( '%UT_TEST parent_suite.child_suite.child_test%' ); + ut.expect( l_actual ).not_to_be_like( '%hidden_path%' ); + ut.expect( l_actual ).not_to_be_like( '%parent_test%' ); + rollback; + end; + + procedure user_runs_granted_by_wildcard is + l_actual clob; + pragma autonomous_transaction; + begin + --Act - matches child_suite (granted) and lone_suite (not granted) + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner.*l*_suite' ); + --Assert + ut.expect( l_actual ).to_be_like( '%child_test%1 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%lone_test%' ); + rollback; + end; + + procedure user_runs_granted_tests_by_wildcard is + l_actual clob; + pragma autonomous_transaction; + begin + --Act - matches child_suite.child_test (granted) and lone_suite.lone_test (not granted) + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner.*l*_suite.*_test' ); + --Assert + ut.expect( l_actual ).to_be_like( '%child_test%1 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%lone_test%' ); + rollback; + end; + + procedure user_runs_granted_by_path_wildcard is + l_actual clob; + pragma autonomous_transaction; + begin + --Act - matches parent_suite (not granted) and parent_suite.child_suite (granted) + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner:parent*' ); + --Assert + ut.expect( l_actual ).to_be_like( '%child_test%1 tests, 0 failed%' ); + ut.expect( l_actual ).not_to_be_like( '%parent_test%' ); + rollback; + end; + + procedure user_hidden_path_wildcard_not_found is + l_actual clob; + pragma autonomous_transaction; + begin + --Act - matches only hidden_path.sub.lone_suite (not granted) + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner:hidden*' ); + rollback; + exception + when others then + rollback; + raise; + end; + + procedure user_hidden_path_not_found is + l_actual clob; + pragma autonomous_transaction; + begin + --Act + l_actual := annotation_cache_helper.run_tests_as( 'ut3_no_extra_priv_user', 'ut3_cache_test_owner:hidden_path' ); + rollback; + exception + when others then + rollback; + raise; + end; + end; / diff --git a/test/ut3_tester/core/annotations/test_annotation_cache.pks b/test/ut3_tester/core/annotations/test_annotation_cache.pks index 5a3fdd8ca..fec89cf3b 100644 --- a/test/ut3_tester/core/annotations/test_annotation_cache.pks +++ b/test/ut3_tester/core/annotations/test_annotation_cache.pks @@ -276,5 +276,44 @@ create or replace package test_annotation_cache is --%endcontext + --%context(Suites spread across packages, user without elevated privileges) + --%beforeall(annotation_cache_helper.enable_ddl_trigger) + --%beforeall(annotation_cache_helper.setup_suite_hierarchy) + --%afterall(annotation_cache_helper.cleanup_suite_hierarchy) + + --%test(Runs a granted package whose parent suite is in a package that is not granted) + procedure user_runs_child_of_hidden_suite; + + --%test(Warns that the parent suite in a package that is not granted is not run) + procedure user_warned_about_hidden_parent; + + --%test(Does not apply tags of the parent suite in a package that is not granted) + procedure user_runs_child_without_parent_tags; + + --%test(Runs a granted package when its parent suitepath is given) + procedure user_runs_hidden_suite_path; + + --%test(Lists no logical suites without granted packages below them) + procedure user_no_empty_logical_suites; + + --%test(Raises an error for a suitepath without granted packages below it) + --%throws(-20204) + procedure user_hidden_path_not_found; + + --%test(Runs only granted packages matched by a package name with wildcards) + procedure user_runs_granted_by_wildcard; + + --%test(Runs only tests of granted packages matched by procedure name with wildcards) + procedure user_runs_granted_tests_by_wildcard; + + --%test(Runs granted packages below a suitepath with wildcards) + procedure user_runs_granted_by_path_wildcard; + + --%test(Raises an error for a suitepath with wildcards without granted packages below it) + --%throws(-20204) + procedure user_hidden_path_wildcard_not_found; + + --%endcontext + end; / diff --git a/test/ut3_tester/core/expectations/test_expectation_processor.pkb b/test/ut3_tester/core/expectations/test_expectation_processor.pkb index 63ce3c791..e93d93141 100644 --- a/test/ut3_tester/core/expectations/test_expectation_processor.pkb +++ b/test/ut3_tester/core/expectations/test_expectation_processor.pkb @@ -1,6 +1,8 @@ create or replace package body test_expectation_processor is gc_user constant varchar2(128) := sys_context('userenv','current_schema'); + gc_long_line_package constant varchar2(128) := 'TEST_EXPECTATION_LONG_LINE'; + gc_long_line constant varchar2(4000) := 'ut.expect(1).to_equal(2); /*'||rpad('*', 3900, '*')||'*/'; procedure who_called_expectation is l_stack_trace varchar2(4000); @@ -13,7 +15,7 @@ create or replace package body test_expectation_processor is 353dfeb2f8 26 SCH_TEST.UT_EXPECTATION_RESULT cba2493ce0 112 SCH_TEST.UT_EXPECTATION 3539881cf0 21 SCH_TEST.UT_EXPECTATION_NUMBER -351a608008 7 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR +351a608008 9 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR 351a608018 12 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR 351a608018 24 package body ]'||gc_user||q'[.TEST_EXPECTATION_PROCESSOR 351a6862b8 6 anonymous block @@ -34,7 +36,7 @@ cba24bfad0 75 SCH_TEST.UT_LOGICAL_SUITE ]'; ut.expect( ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace) - ).to_equal('at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 7 l_source_line varchar2(4000); + ).to_equal('at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 9 l_source_line varchar2(4000); at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 12 at "'||gc_user||'.TEST_EXPECTATION_PROCESSOR", line 24'); end; @@ -101,5 +103,71 @@ handle number name ).to_be_like('at "SCOTT.TEST_BETWNSTR.BASIC_USAGE", line 7 %'); end; + procedure create_long_line_package is + pragma autonomous_transaction; + begin + execute immediate 'create or replace package '||gc_long_line_package||' is + procedure long_line; +end;'; + execute immediate 'create or replace package body '||gc_long_line_package||' is + procedure long_line is + begin + '||gc_long_line||' + end; +end;'; + end; + + procedure drop_long_line_package is + pragma autonomous_transaction; + begin + execute immediate 'drop package '||gc_long_line_package; + end; + + procedure who_called_exp_long_line is + l_stack_trace varchar2(4000); + l_result varchar2(32767); + begin + l_stack_trace := q'[----- PL/SQL Call Stack ----- + object line object + handle number name +0x80e701d8 26 UT3_DEVELOP.UT_EXPECTATION_RESULT +0x85e10150 112 UT3_DEVELOP.UT_EXPECTATION +0x8b54bad8 21 UT3_DEVELOP.UT_EXPECTATION_NUMBER +0x85cfd238 4 package body ]'||gc_user||'.'||gc_long_line_package||q'[ +0x85def380 6 anonymous block +]'; + l_result := ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace); + + ut.expect( l_result ).to_equal( + 'at "'||gc_user||'.'||gc_long_line_package||'", line 4 ' + || substr( gc_long_line, 1, 500 - length('[...]') ) || '[...]' + || chr(10) || 'at "anonymous block", line 6' + ); + end; + + procedure who_called_exp_long_stack is + l_stack_trace varchar2(32767); + l_result varchar2(32767); + begin + l_stack_trace := q'[----- PL/SQL Call Stack ----- + object line object + handle number name +0x80e701d8 26 UT3_DEVELOP.UT_EXPECTATION_RESULT +0x85e10150 112 UT3_DEVELOP.UT_EXPECTATION +0x8b54bad8 21 UT3_DEVELOP.UT_EXPECTATION_NUMBER +0x85cfd238 4 package body ]'||gc_user||'.'||gc_long_line_package||chr(10); + -- distinct callers, so the stack after the first frame is long + for i in 1 .. 100 loop + l_stack_trace := l_stack_trace + || '0x85cfd238 '||to_char(1000 + i)||' package body '||gc_user||'.'||gc_long_line_package||chr(10); + end loop; + + l_result := ut3_develop.ut_expectation_processor.who_called_expectation(l_stack_trace); + + ut.expect( lengthb( l_result ) ).to_be_less_or_equal( 4000 ); + ut.expect( l_result ).to_be_like( 'at "'||gc_user||'.'||gc_long_line_package||'", line 4 ut.expect(1).to_equal(2); /*%' ); + ut.expect( l_result ).to_be_like( '%[...]' ); + end; + end; / diff --git a/test/ut3_tester/core/expectations/test_expectation_processor.pks b/test/ut3_tester/core/expectations/test_expectation_processor.pks index 6087eb045..4797dd613 100644 --- a/test/ut3_tester/core/expectations/test_expectation_processor.pks +++ b/test/ut3_tester/core/expectations/test_expectation_processor.pks @@ -19,5 +19,21 @@ create or replace package test_expectation_processor is --%endcontext + --%context(who_called_expectation_long_lines) + + --%beforeall + procedure create_long_line_package; + + --%afterall + procedure drop_long_line_package; + + --%test(truncates a long source line of the calling code - regression for #1397) + procedure who_called_exp_long_line; + + --%test(limits caller info to 4000 bytes when the call stack is long - regression for #1397) + procedure who_called_exp_long_stack; + + --%endcontext + end; / diff --git a/test/ut3_tester/core/test_coverage_report_html_helper.pkb b/test/ut3_tester/core/test_coverage_report_html_helper.pkb new file mode 100644 index 000000000..a4cd36ed1 --- /dev/null +++ b/test/ut3_tester/core/test_coverage_report_html_helper.pkb @@ -0,0 +1,29 @@ +create or replace package body test_coverage_report_html_helper is + + gc_support_link constant varchar2(4000) := + '' || ut3_develop.ut_utils.gc_support_text || ''; + + function get_index(a_support_info boolean) return clob is + l_coverage_data ut3_develop.ut_coverage.t_coverage; + begin + return ut3_develop.ut_utils.table_to_clob( + ut3_develop.ut_coverage_report_html_helper.get_index( + a_coverage_data => l_coverage_data, + a_assets_path => null, + a_support_info => a_support_info + ) + ); + end; + + procedure index_includes_support_link is + begin + ut.expect( get_index(a_support_info => true) ).to_be_like( '%%' ); + end; + + procedure index_omits_support_link is + begin + ut.expect( get_index(a_support_info => false) ).not_to_be_like( '%' || ut3_develop.ut_utils.gc_support_url || '%' ); + end; + +end; +/ diff --git a/test/ut3_tester/core/test_coverage_report_html_helper.pks b/test/ut3_tester/core/test_coverage_report_html_helper.pks new file mode 100644 index 000000000..bad1192b8 --- /dev/null +++ b/test/ut3_tester/core/test_coverage_report_html_helper.pks @@ -0,0 +1,13 @@ +create or replace package test_coverage_report_html_helper is + + --%suite(coverage_report_html_helper) + --%suitepath(utplsql.ut3_tester.core) + + --%test(Index page footer includes support link by default) + procedure index_includes_support_link; + + --%test(Index page footer omits support link when switched off) + procedure index_omits_support_link; + +end; +/ diff --git a/test/ut3_tester/core/test_output_buffer.pkb b/test/ut3_tester/core/test_output_buffer.pkb index 55670b8b8..de53b957a 100644 --- a/test/ut3_tester/core/test_output_buffer.pkb +++ b/test/ut3_tester/core/test_output_buffer.pkb @@ -1,5 +1,14 @@ create or replace package body test_output_buffer is + -- Writer action that waits (up to 30 seconds) until the reader removes the buffer info. + -- It keeps the writer only as long as the test needs it, so it does not delay jobs of the following tests. + gc_wait_for_reader_to_finish constant varchar2(4000) := q'[ + for i in 1 .. 300 loop + select count(1) into l_info_count from ut3_develop.ut_output_buffer_info_tmp b where b.output_id = l_buffer.output_id; + exit when l_info_count = 0; + dbms_session.sleep(0.1); + end loop;]'; + function long_text return varchar2 is l_txt varchar2(32767); begin @@ -8,6 +17,56 @@ create or replace package body test_output_buffer is end loop; return l_txt; end; + + -- Runs a_writer_actions in a separate session (scheduler job) on a buffer sharing output_id with a_reader. + -- The writer buffer is available to the actions as l_buffer. + procedure start_writer(a_reader ut3_develop.ut_output_buffer_base, a_writer_actions varchar2) is + begin + ut3_tester_helper.run_helper.run_as_job( + 'declare + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.'||a_reader.self_type||'(a_output_id => '''||a_reader.output_id||'''); + l_info_count integer; + begin + '||a_writer_actions||' + end;' + ); + end; + + procedure wait_for_writer_lock(a_reader ut3_develop.ut_output_buffer_base) is + c_max_wait_sec constant number := 30; + l_waited_sec number := 0; + begin + while a_reader.get_lock_status() = 0 and l_waited_sec < c_max_wait_sec loop + dbms_session.sleep(0.1); + l_waited_sec := l_waited_sec + 0.1; + end loop; + ut.expect(a_reader.get_lock_status(), 'Writer session holds the buffer lock').not_to_equal(0); + end; + + procedure reads_lines_from_writer(a_reader ut3_develop.ut_output_buffer_base) is + l_actual sys_refcursor; + l_expected sys_refcursor; + begin + --Arrange - writer stays silent for 1 second longer than reader's initial timeout + start_writer( + a_reader, + q'[l_buffer.lock_buffer(); + dbms_session.sleep(1.2); + l_buffer.send_line('line 1'); + l_buffer.send_line('line 2'); + l_buffer.close();]' + ); + wait_for_writer_lock(a_reader); + --Act + open l_actual for + select to_char(text) as text from table(a_reader.get_lines(a_initial_timeout => 0.2, a_timeout_sec => 30)); + --Assert + open l_expected for + select 'line 1' as text from dual union all + select 'line 2' as text from dual; + ut.expect(l_actual).to_equal(l_expected); + end; + procedure test_receive is l_actual_text clob; l_actual_item_type varchar2(1000); @@ -213,5 +272,99 @@ create or replace package body test_output_buffer is l_consumer_buffer_instance := ut3_develop.ut_output_table_buffer(a_output_id => l_shared_output_id); end; + procedure table_buffer_reads_from_writer is + begin + reads_lines_from_writer(ut3_develop.ut_output_table_buffer()); + end; + + procedure clob_buffer_reads_from_writer is + begin + reads_lines_from_writer(ut3_develop.ut_output_clob_table_buffer()); + end; + + procedure bulk_buffer_reads_from_writer is + begin + reads_lines_from_writer(ut3_develop.ut_output_bulk_buffer()); + end; + + procedure reader_stops_when_writer_ends is + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); + l_lines ut3_develop.ut_varchar2_rows; + l_start timestamp; + l_duration interval day to second; + begin + --Arrange - writer keeps the lock for a while after sending and its session ends without calling close() + start_writer( + l_buffer, + q'[l_buffer.lock_buffer(); + l_buffer.send_line('line 1'); + dbms_session.sleep(0.5);]' + ); + wait_for_writer_lock(l_buffer); + l_start := localtimestamp; + --Act + begin + select to_char(text) bulk collect into l_lines + from table(l_buffer.get_lines(a_initial_timeout => 1, a_timeout_sec => 2)); + exception + when others then + ut.fail('Reader did not stop after writer session ended: '||sqlerrm); + end; + l_duration := localtimestamp - l_start; + --Assert + ut.expect(anydata.convertCollection(l_lines)).to_equal(anydata.convertCollection(ut3_develop.ut_varchar2_rows('line 1'))); + ut.expect(l_buffer.get_lock_status(), 'Writer lock released by session end').to_equal(0); + ut.expect(l_duration, 'Reader waited for writer session to end').to_be_greater_or_equal(interval '0.3' second); + end; + + procedure reader_times_out_on_idle_writer is + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); + l_count integer; + begin + --Arrange - writer holds the lock without sending data until the reader gives up + start_writer( + l_buffer, + q'[l_buffer.lock_buffer(); + l_buffer.send_line('line 1');]' + ||gc_wait_for_reader_to_finish||q'[ + l_buffer.close();]' + ); + wait_for_writer_lock(l_buffer); + --Act + begin + select count(1) into l_count from table(l_buffer.get_lines(a_initial_timeout => 1, a_timeout_sec => 1)); + ut.fail('Expected a timeout exception but nothing was raised'); + exception + when others then + --Assert + ut.expect(dbms_utility.format_error_stack()).to_match('ORA'||ut3_develop.ut_utils.gc_out_buffer_timeout); + end; + end; + + procedure second_writer_cannot_lock is + l_buffer ut3_develop.ut_output_buffer_base := ut3_develop.ut_output_table_buffer(); + begin + --Arrange - writer holds the lock until the test is done + start_writer( + l_buffer, + q'[l_buffer.lock_buffer();]' + ||gc_wait_for_reader_to_finish||q'[ + l_buffer.close();]' + ); + wait_for_writer_lock(l_buffer); + --Act + begin + l_buffer.lock_buffer(); + l_buffer.close(); + ut.fail('Expected lock_buffer to fail but it succeeded'); + exception + when others then + --Assert + ut.expect(sqlerrm).to_be_like('%Cannot allocate lock for output buffer of reporter%'); + end; + --Cleanup - let the writer finish + l_buffer.remove_buffer_info(); + end; + end test_output_buffer; / diff --git a/test/ut3_tester/core/test_output_buffer.pks b/test/ut3_tester/core/test_output_buffer.pks index aa5c830d3..1b5a04762 100644 --- a/test/ut3_tester/core/test_output_buffer.pks +++ b/test/ut3_tester/core/test_output_buffer.pks @@ -4,59 +4,68 @@ create or replace package test_output_buffer is --%suitepath(utplsql.ut3_tester.core) - --%context(Read and write within the same session) + --%context(Buffer is read in a different session than buffer write) + + --%test(Text buffer reader waits beyond initial timeout for writer holding the lock and reads all lines) + procedure table_buffer_reads_from_writer; + + --%test(Clob buffer reader waits beyond initial timeout for writer holding the lock and reads all lines) + procedure clob_buffer_reads_from_writer; + + --%test(Bulk buffer reader waits beyond initial timeout for writer holding the lock and reads all lines) + procedure bulk_buffer_reads_from_writer; + --%test(Reader stops when writer session ends without closing the buffer) + procedure reader_stops_when_writer_ends; + + --%test(Reader times out when writer holds the lock and sends no data) + procedure reader_times_out_on_idle_writer; + + --%test(Writer cannot lock buffer that is locked by another session) + procedure second_writer_cannot_lock; --%endcontext - - --%context(Buffer is read in a different session than buffer write) - --reader will wait for a_initial_timeout seconds for the writer process to start and then it will finish with error + --%context(Read and write within the same session) + - --reader will wait forever (beyond a_initial_timeout) if the writer process is started and end of data row was not received from the buffer + --%test(Receives a line from buffer table and deletes) + procedure test_receive; - --reader stops after reading the end of data signal from the buffer + --%test(Waits specified time for producer to lock the buffer ) + --%throws(-20218) + procedure test_wait_for_producer; - --reader stops when writer process ends and all data was read from the buffer + --%test(Does not send line if null text given) + procedure test_doesnt_send_on_null_text; + --%test(Does not send line if null text given for multiline case) + procedure test_doesnt_send_on_null_elem; - --%endcontext + --%test(Sends a line into buffer table) + procedure test_send_line; + + --%test(Waits For The Data To Appear For Specified Time) + procedure test_waiting_for_data; + + --%test(Purges text buffer data older than one day and leaves the rest) + procedure test_purge_text_buffer; + + --%test(Purges clob buffer data older than one day and leaves the rest) + procedure test_purge_clob_buffer; - --%test(Receives a line from buffer table and deletes) - procedure test_receive; - - --%test(Waits specified time for producer to lock the buffer ) - --%throws(-20218) - procedure test_wait_for_producer; - - --%test(Does not send line if null text given) - procedure test_doesnt_send_on_null_text; - - --%test(Does not send line if null text given for multiline case) - procedure test_doesnt_send_on_null_elem; - - --%test(Sends a line into buffer table) - procedure test_send_line; - - --%test(Waits For The Data To Appear For Specified Time) - procedure test_waiting_for_data; - - --%test(Purges text buffer data older than one day and leaves the rest) - procedure test_purge_text_buffer; - - --%test(Purges clob buffer data older than one day and leaves the rest) - procedure test_purge_clob_buffer; - - --%test(Successfully sends multibyte long line into text buffer) - procedure text_buffer_send_multibyte; - - --%test(Successfully sends multibyte long clob line into text buffer) - procedure text_buffer_send_clob_multib; - - --%beforetest(ut3_tester_helper.run_helper.slow_down_insert_into_table_buffer) - --%aftertest(ut3_tester_helper.run_helper.cleanup_slow_down_insert_into_table_buffer) - --%test(concurrent calls to init() procedure do not cause errors - Issue #985) - procedure concurrent_calls_do_not_cause_exception; + --%test(Successfully sends multibyte long line into text buffer) + procedure text_buffer_send_multibyte; + + --%test(Successfully sends multibyte long clob line into text buffer) + procedure text_buffer_send_clob_multib; + + --%beforetest(ut3_tester_helper.run_helper.slow_down_insert_into_table_buffer) + --%aftertest(ut3_tester_helper.run_helper.cleanup_slow_down_insert_into_table_buffer) + --%test(concurrent calls to init() procedure do not cause errors - Issue #985) + procedure concurrent_calls_do_not_cause_exception; + + --%endcontext end test_output_buffer; / diff --git a/test/ut3_tester/core/test_suite_builder.pkb b/test/ut3_tester/core/test_suite_builder.pkb index 570d86a0d..15aac2d01 100644 --- a/test/ut3_tester/core/test_suite_builder.pkb +++ b/test/ut3_tester/core/test_suite_builder.pkb @@ -20,8 +20,7 @@ create or replace package body test_suite_builder is a_owner_name => 'UT3_TESTER', a_annotated_objects => l_cursor, a_path => null, - a_object_name => a_package_name, - a_skip_all_objects => true + a_object_name => a_package_name ); l_suite := treat( l_suites(l_suites.first) as ut3_develop.ut_logical_suite); @@ -1370,6 +1369,54 @@ create or replace package body test_suite_builder is ); end; + procedure context_name_case_insensitive is + l_actual clob; + l_annotations ut3_develop.ut_annotations; + begin + --Arrange + l_annotations := ut3_develop.ut_annotations( + ut3_develop.ut_annotation(1, 'suite','Cool', null), + ut3_develop.ut_annotation(2, 'beforeall',null, 'suite_level_beforeall'), + ut3_develop.ut_annotation(3, 'test','In suite', 'suite_level_test'), + ut3_develop.ut_annotation(4, 'context','A context', null), + ut3_develop.ut_annotation(5, 'name','a_Context', null), + ut3_develop.ut_annotation(6, 'beforeall',null, 'context_setup'), + ut3_develop.ut_annotation(7, 'test', 'In context', 'test_in_a_context'), + ut3_develop.ut_annotation(8, 'endcontext',null, null) + ); + --Act + l_actual := invoke_builder_for_annotations(l_annotations, 'SOME_PACKAGE'); + --Assert + ut.expect(l_actual).to_be_like( + ''|| + '' || + '%' || + '%' || + '' || + '%suite_level_testIn suitesome_package.suite_level_test' || + '%' || + '' || + '%a_contextA contextsome_package.a_context' || + '%' || + '' || + '%test_in_a_contextIn contextsome_package.a_context.test_in_a_context' || + '%' || + '' || + '' || + '%some_packagecontext_setup' || + '%' || + '' || + '' || + '' || + '' || + '%some_packagesuite_level_beforeall' || + '%' || + '' || + ''|| + '' + ); + end; + procedure throws_value_empty is l_actual clob; l_annotations ut3_develop.ut_annotations; diff --git a/test/ut3_tester/core/test_suite_builder.pks b/test/ut3_tester/core/test_suite_builder.pks index 4cbfcad74..09ff3c0b3 100644 --- a/test/ut3_tester/core/test_suite_builder.pks +++ b/test/ut3_tester/core/test_suite_builder.pks @@ -142,7 +142,7 @@ create or replace package test_suite_builder is --%test(Falls back to default context name and gives warning when name contains spaces) procedure name_with_spaces_invalid; - --%test(Raises warning when more than one name annotation used ) + --%test(Raises warning when more than one name annotation used) procedure duplicate_name_annotation; --%test(Is ignored when used outside of context - no warning given) @@ -154,6 +154,9 @@ create or replace package test_suite_builder is --%test(Is applied to corresponding context when multiple contexts used) procedure multiple_contexts; + --%test(Context name is case insensitive) + procedure context_name_case_insensitive; + --%endcontext --%context(--%throws annotation) diff --git a/test/ut3_tester/core/test_suite_manager.pkb b/test/ut3_tester/core/test_suite_manager.pkb index c818ad212..8ab9b96d9 100644 --- a/test/ut3_tester/core/test_suite_manager.pkb +++ b/test/ut3_tester/core/test_suite_manager.pkb @@ -502,6 +502,36 @@ end test2_multi_wildcard;]'; end; + function count_tests(a_items ut3_develop.ut_suite_items) return integer is + l_count integer := 0; + begin + for i in 1 .. a_items.count loop + if a_items(i) is of (ut3_develop.ut_test) then + l_count := l_count + 1; + else + l_count := l_count + count_tests(treat(a_items(i) as ut3_develop.ut_logical_suite).items); + end if; + end loop; + return l_count; + end; + + procedure test_overlapping_paths is + c_owner varchar2(128) := sys_context('USERENV', 'CURRENT_USER'); + l_expected_items ut3_develop.ut_suite_items; + l_objects_to_run ut3_develop.ut_suite_items; + begin + --Arrange + l_expected_items := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_owner||':tests')); + --Act - the packages are part of the suitepath + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path( + ut3_develop.ut_varchar2_list(c_owner||':tests', c_owner||'.test_package_1', c_owner||'.test_package_2') + ); + --Assert + ut.expect(count_tests(l_expected_items)).to_be_greater_than(0); + ut.expect(l_objects_to_run.count).to_equal(1); + ut.expect(count_tests(l_objects_to_run)).to_equal(count_tests(l_expected_items)); + end; + procedure test_top2_by_name is c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_2'; l_objects_to_run ut3_develop.ut_suite_items; @@ -1254,7 +1284,7 @@ end;'; l_test_report ut3_develop.ut_varchar2_list; begin - select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.test_dependencies')); + select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER')||'.test_dependencies', a_support_info => 0)); ut.expect(l_test_report(l_test_report.count-1)).to_be_like('1 test_, 0 failed, 0 errored, 0 disabled, 0 warning(s)'); --execute immediate 'select * from table(ut3_develop.ut.run(''UT3_DEVELOP.test_dependencies'', ut3_develop.utplsql_test_reporter()))' into l_result; @@ -1732,6 +1762,7 @@ end;]'; begin select * bulk collect into l_test_report from table(ut3_develop.ut.run(sys_context('USERENV', 'CURRENT_USER') || '.test_removing_annotation')); + ut.fail('Expected exception ORA-20204 was not raised'); exception when others then ut.expect(sqlerrm).to_be_like('%ORA-20204: Suite package ut3_tester.test_removing_annotation does not exist%'); @@ -2218,6 +2249,115 @@ end;]'; end; --%test(Path validation does not fail on Estonian NLS_SORT - fix #1252) + /* + Names that differ only where a "_" or "." is: + tst_char_a / tstxchar_a, test_a / testxa, chars.sub_a / chars.subxa, chars.sub / chars_sub + */ + procedure create_char_test_packages is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package tst_char_a is + --%suite + --%suitepath(chars.sub_a) + + --%test + procedure test_a; + + --%test + procedure testxa; + end;]'; + execute immediate q'[create or replace package tstxchar_a is + --%suite + --%suitepath(chars.subxa) + + --%test + procedure test_a; + end;]'; + execute immediate q'[create or replace package tst_char_b is + --%suite + --%suitepath(chars_sub) + + --%test + procedure test_b; + end;]'; + end; + + procedure drop_char_test_packages is + pragma autonomous_transaction; + begin + execute immediate 'drop package tst_char_a'; + execute immediate 'drop package tstxchar_a'; + execute immediate 'drop package tst_char_b'; + end; + + --returns the paths of all tests, sorted and separated by commas + function get_test_paths(a_items ut3_develop.ut_suite_items) return varchar2 is + l_paths ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(); + l_result varchar2(32767); + + procedure add_test_paths(a_suite_items ut3_develop.ut_suite_items) is + begin + for i in 1 .. a_suite_items.count loop + if a_suite_items(i) is of (ut3_develop.ut_test) then + l_paths.extend; + l_paths(l_paths.last) := a_suite_items(i).path; + else + add_test_paths(treat(a_suite_items(i) as ut3_develop.ut_logical_suite).items); + end if; + end loop; + end; + begin + add_test_paths(a_items); + select listagg(column_value, ',') within group (order by column_value) into l_result from table(l_paths); + return l_result; + end; + + procedure underscore_in_package_name is + l_objects_to_run ut3_develop.ut_suite_items; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path( + ut3_develop.ut_varchar2_list(sys_context('USERENV', 'CURRENT_USER')||'.tst_char_a') + ); + --Assert + ut.expect(get_test_paths(l_objects_to_run)).to_equal('chars.sub_a.tst_char_a.test_a,chars.sub_a.tst_char_a.testxa'); + end; + + procedure underscore_in_procedure_name is + l_objects_to_run ut3_develop.ut_suite_items; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path( + ut3_develop.ut_varchar2_list(sys_context('USERENV', 'CURRENT_USER')||'.tst_char_a.test_a') + ); + --Assert + ut.expect(get_test_paths(l_objects_to_run)).to_equal('chars.sub_a.tst_char_a.test_a'); + end; + + procedure underscore_in_suitepath is + l_objects_to_run ut3_develop.ut_suite_items; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path( + ut3_develop.ut_varchar2_list(sys_context('USERENV', 'CURRENT_USER')||':chars.sub_a') + ); + --Assert + ut.expect(get_test_paths(l_objects_to_run)).to_equal('chars.sub_a.tst_char_a.test_a,chars.sub_a.tst_char_a.testxa'); + end; + + procedure dot_in_suitepath_wildcard is + l_objects_to_run ut3_develop.ut_suite_items; + begin + --Act + l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path( + ut3_develop.ut_varchar2_list(sys_context('USERENV', 'CURRENT_USER')||':chars.sub*') + ); + --Assert + ut.expect(get_test_paths(l_objects_to_run)).to_equal( + 'chars.sub_a.tst_char_a.test_a,chars.sub_a.tst_char_a.testxa,chars.subxa.tstxchar_a.test_a' + ); + end; + procedure path_validate_nls_sort is l_schema_names ut3_develop.ut_varchar2_rows; begin diff --git a/test/ut3_tester/core/test_suite_manager.pks b/test/ut3_tester/core/test_suite_manager.pks index 44f102716..a7d3bcc20 100644 --- a/test/ut3_tester/core/test_suite_manager.pks +++ b/test/ut3_tester/core/test_suite_manager.pks @@ -15,6 +15,9 @@ create or replace package test_suite_manager is --%test(Prepare runner for the top 2 package by package user.package_name) procedure test_top2_by_name; + --%test(Prepare runner includes each suite item once when given paths overlap) + procedure test_overlapping_paths; + --%test(Prepare runner for the top2 package by name cur user) procedure test_top2_bt_name_cur_user; @@ -211,7 +214,7 @@ create or replace package test_suite_manager is --%test(Execute test_packages using a procedure name with wildcard in the front) procedure test_wild_card_front_prc_name; - -- %test(Execute test_packages using a path name with wildcard in the front) + --%test(Execute test_packages using a path name with wildcard in the front) procedure test_wild_card_front_path_name; --%test(Execute test_packages using a object_name with wildcard in the middle) @@ -220,7 +223,7 @@ create or replace package test_suite_manager is --%test(Execute test_packages using a procedure name with wildcard in the middle) procedure test_wild_card_mid_prc_name; - -- %test(Execute test_packages using a path name with wildcard in the middle) + --%test(Execute test_packages using a path name with wildcard in the middle) procedure test_wild_card_mid_path_name; --%test(Execute test_packages using a object_name with multiple wildcards) @@ -229,14 +232,36 @@ create or replace package test_suite_manager is --%test(Execute test_packages using a procedure name with multiple wildcards) procedure test_wild_card_mul_prc_name; - -- %test(Execute test_packages using a path name with multiple wildcards) + --%test(Execute test_packages using a path name with multiple wildcards) procedure test_wild_card_mul_path_name; - -- %test(Execute test_packages using a path name with multiple wildcards on different level) + --%test(Execute test_packages using a path name with multiple wildcards on different level) procedure tst_wild_card_mul_lv_path_name; --%endcontext + --%context(literal_characters) + --%displayname(Characters other than * in a path match only themselves) + + --%beforeall + procedure create_char_test_packages; + --%afterall + procedure drop_char_test_packages; + + --%test(Underscore in a package name is not a wildcard) + procedure underscore_in_package_name; + + --%test(Underscore in a procedure name is not a wildcard) + procedure underscore_in_procedure_name; + + --%test(Underscore in a suitepath is not a wildcard) + procedure underscore_in_suitepath; + + --%test(Dot in a suitepath with a wildcard is not a wildcard) + procedure dot_in_suitepath_wildcard; + + --%endcontext + --%context(paths validation) --%test(Path validation does not fail on Estonian NLS_SORT - fix #1252) diff --git a/test/ut3_tester/core/test_ut_metadata.pkb b/test/ut3_tester/core/test_ut_metadata.pkb new file mode 100644 index 000000000..905f31081 --- /dev/null +++ b/test/ut3_tester/core/test_ut_metadata.pkb @@ -0,0 +1,109 @@ +create or replace package body test_ut_metadata is + + c_cr constant varchar2(1) := chr(13); + c_lf constant varchar2(2) := chr(10); + c_crlf constant varchar2(2) := chr(13)||chr(10); + + c_pks_lf constant varchar2(1000) := + 'create or replace package test_package1 is'||c_lf + ||' procedure test_max_length;'||c_lf + ||'end;' + ; + c_pkg_lf constant varchar2(20000) := + q'[create or replace package body test_package1 is]'||c_lf + ||q'[ procedure test_max_length is]'||c_lf + ||q'[ begin]'||c_lf + ||q'[ /* long comment over 4000 characters 1]'||rpad('*', 8000, '*')||'*/'||c_lf + ||substrb(q'[ /* long comment 3999 and linebreak]'||rpad('*', 4000, '*'), 1, 3997)||'*/'||c_lf + ||q'[ dbms_output.put_line('test_max_length called.');]'||c_lf + ||q'[ end;]'||c_lf + ||q'[ end;]' + ; + + procedure test_over_varchar2_limit_trim_first_4000_lf + is + l_actual varchar2(32767); + l_expect varchar2(32767); + begin + l_expect := trim(substrb(q'[ /* long comment over 4000 characters 1]'||rpad('*', 8000, '*')||'*/'||c_lf, 1, 4000)); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 4); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := trim(substrb(q'[ /* long comment 3999 and linebreak]'||rpad('*', 4000, '*'), 1, 3997)||'*/'||c_lf); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 5); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := 'dbms_output.put_line(''test_max_length called.'');'||c_lf; + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 6); + ut.expect(l_actual).to_equal(l_expect); + end; + + procedure test_over_varchar2_limit_trim_first_4000_crlf is + l_actual varchar2(32767); + l_expect varchar2(32767); + begin + l_expect := trim(substrb(q'[ /* long comment over 4000 characters 1]'||rpad('*', 8000, '*')||'*/'||c_crlf, 1, 4000)); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 4); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := trim(substrb(q'[ /* long comment 3999 and linebreak]'||rpad('*', 4000, '*'), 1, 3997)||'*/'||c_cr); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 5); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := 'dbms_output.put_line(''test_max_length called.'');'||c_crlf; + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 6); + ut.expect(l_actual).to_equal(l_expect); + end; + + procedure test_over_varchar2_limit_trim_first_4000_cr + is + l_actual varchar2(32767); + l_expect varchar2(32767); + begin + l_expect := trim(substrb(q'[ /* long comment over 4000 characters 1]'||rpad('*', 8000, '*')||'*/'||c_cr, 1, 4000)); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 4); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := trim(substrb(q'[ /* long comment 3999 and linebreak]'||rpad('*', 4000, '*'), 1, 3997)||'*/'||c_cr); + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 5); + ut.expect(l_actual).to_equal(l_expect); + + l_expect := 'ut.expect(l_actual).to_equal(l_expect);'||c_cr; + l_actual := ut3_develop.ut_metadata.get_source_definition_line('UT3_TESTER', 'TEST_PACKAGE1', 6); + ut.expect(l_actual).to_equal(l_expect); + end; + + procedure clear_cache is + begin + ut3_develop.ut_metadata.reset_source_definition_cache(); + end; + + procedure drop_test_package is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_package1'; + end; + + procedure create_test_package_lf is + pragma autonomous_transaction; + begin + execute immediate c_pks_lf; + execute immediate c_pkg_lf; + end; + + procedure create_test_package_crlf is + pragma autonomous_transaction; + begin + execute immediate replace(c_pks_lf, c_lf, c_crlf); + execute immediate replace(c_pkg_lf, c_lf, c_crlf); + end; + + procedure create_test_package_cr is + pragma autonomous_transaction; + begin + execute immediate replace(c_pks_lf, c_lf, c_cr); + execute immediate replace(c_pkg_lf, c_lf, c_cr); + end; + +end; +/ \ No newline at end of file diff --git a/test/ut3_tester/core/test_ut_metadata.pks b/test/ut3_tester/core/test_ut_metadata.pks new file mode 100644 index 000000000..b4a1d601c --- /dev/null +++ b/test/ut3_tester/core/test_ut_metadata.pks @@ -0,0 +1,34 @@ +create or replace package test_ut_metadata is + --%suite(ut_metadata) + --%suitepath(utplsql.ut3_tester.core) + + --%context(get_source_definition_line) + + --%test(source line over 4000 limit is trimmed to first 4000 [linebreeak lf]) + --%beforetest(create_test_package_lf) + procedure test_over_varchar2_limit_trim_first_4000_lf; + + --%test(source line over 4000 limit is trimmed to first 4000 [linebreeak:crlf]) + --%beforetest(create_test_package_crlf) + procedure test_over_varchar2_limit_trim_first_4000_crlf; + + --%disabled(PLS-00103 occurs when execute immediate CR package) + --%test(source line over 4000 limit is trimmed to first 4000 [linebreeak cr]) + --%beforetest(create_test_package_cr) + procedure test_over_varchar2_limit_trim_first_4000_cr; + + --%beforeeach + procedure clear_cache; + --%aftereach + procedure drop_test_package; + + procedure create_test_package_lf; + + procedure create_test_package_crlf; + + procedure create_test_package_cr; + + --%endcontext + +end; +/ \ No newline at end of file diff --git a/test/ut3_tester/core/test_ut_suite_tag_filter.pkb b/test/ut3_tester/core/test_ut_suite_tag_filter.pkb index 7ce6a1c3e..34af60549 100644 --- a/test/ut3_tester/core/test_ut_suite_tag_filter.pkb +++ b/test/ut3_tester/core/test_ut_suite_tag_filter.pkb @@ -71,52 +71,285 @@ create or replace package body test_ut_suite_tag_filter is ut.fail('Expected exception but nothing was raised'); end; - procedure conv_from_tag_to_sql_filter is - l_sql_filter varchar2(4000); + procedure conversion_throws_when_unmatched_rb is + l_postfix ut3_develop.ut_varchar2_list; + l_input_token ut3_develop.ut_varchar2_list; + begin + l_input_token := ut3_develop.ut_varchar2_list('(','a',')',')'); + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(l_input_token); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure conversion_throws_when_empty is + l_postfix ut3_develop.ut_varchar2_list; + begin + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(ut3_develop.ut_varchar2_list()); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure conversion_throws_when_trailing_opr is + l_postfix ut3_develop.ut_varchar2_list; + begin + l_postfix := ut3_develop.ut_suite_tag_filter.shunt_logical_expression(ut3_develop.ut_varchar2_list('a','|')); + ut.fail('Expected exception but nothing was raised'); + end; + + procedure tokenize_empty_string is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.tokenize_tags_string(null).count ).to_equal(0); + end; + + procedure is_matching_or_and_not is begin - l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1'); - ut.expect(l_sql_filter).to_equal(q'['test1' member of tags]'); - - l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1|test2'); - ut.expect(l_sql_filter).to_equal(q'[('test1' member of tags or 'test2' member of tags)]'); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test1', 'test1') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test2', 'test1') ).to_equal(0); - l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1|!test2'); - ut.expect(l_sql_filter).to_equal(q'[('test1' member of tags or not('test2' member of tags))]'); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test2', 'test1|test2') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test3', 'test1|test2') ).to_equal(0); - l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1&!test2'); - ut.expect(l_sql_filter).to_equal(q'[('test1' member of tags and not('test2' member of tags))]'); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test3', 'test1|!test2') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test2', 'test1|!test2') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test1,test2', 'test1|!test2') ).to_equal(1); + + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test1', 'test1&!test2') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test1,test2', 'test1&!test2') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('test3', 'test1&!test2') ).to_equal(0); + end; + + procedure is_matching_evaluates_tags is + l_tags varchar2(100) := 'db,slow'; + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'slow') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'fast') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'slow&db') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'slow&!db') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'fast|db') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, '!fast') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, '(fast|slow)&!(db&fast)') ).to_equal(1); + --legacy notation: "," is or, "-" is not + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'fast,slow') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'fast,-slow') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'none') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(l_tags, 'any') ).to_equal(1); + end; + + procedure is_matching_without_tags is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, 'none') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, 'any') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, '!slow') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, 'slow') ).to_equal(0); + end; + + procedure is_matching_operator_precedence is + begin + --"&" binds stronger than "|" + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'a|b&c') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('b', 'a|b&c') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('b,c', 'a|b&c') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('c', 'b&c|a') ).to_equal(0); + --brackets + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', '(a|b)&c') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,c', '(a|b)&c') ).to_equal(1); + --"!" binds stronger than "&" + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('b', '!a&b') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,b', '!a&b') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', '!(a&b)') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,b', '!(a&b)') ).to_equal(0); + --double negation + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', '!!a') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('b', '!!a') ).to_equal(0); + end; + + procedure is_matching_none_and_any_combined is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', 'none|slow') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, 'none|slow') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db', 'none|slow') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', '!none') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, '!none') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, '!any') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', 'any&!slow') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db', 'any&!slow') ).to_equal(1); + end; + + procedure is_matching_is_case_sensitive is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('Slow', 'slow') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', 'SLOW') ).to_equal(0); + --upper case keywords are tags, not the none and any keywords + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, 'NONE') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', 'ANY') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('ANY', 'ANY') ).to_equal(1); + end; + + procedure is_matching_ignores_whitespace is + c_tab constant varchar2(1) := chr(9); + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db,slow', ' slow & db ') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db,slow', ' ( fast | slow ) & ! db ') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db,slow', c_tab||'slow'||c_tab||'&'||c_tab||'db'||c_tab) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db,slow', 'slow'||c_tab||'&'||c_tab||'!'||c_tab||'db') ).to_equal(0); + --legacy notation + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('db,slow', 'fast, slow') ).to_equal(1); + end; + + procedure is_matching_empty_expression is + c_tab constant varchar2(1) := chr(9); + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', null) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, null) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', ' ') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, ' ') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', c_tab) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(null, ' '||c_tab||' ') ).to_equal(1); + end; + + procedure remove_whitespace_from_expression is + c_tab constant varchar2(1) := chr(9); + begin + ut.expect( ut3_develop.ut_suite_tag_filter.remove_whitespace(null) ).to_be_null(); + ut.expect( ut3_develop.ut_suite_tag_filter.remove_whitespace(' ') ).to_be_null(); + ut.expect( ut3_develop.ut_suite_tag_filter.remove_whitespace(' '||c_tab||c_tab||' ') ).to_be_null(); + ut.expect( ut3_develop.ut_suite_tag_filter.remove_whitespace(' slow &'||c_tab||'db ') ).to_equal('slow&db'); + end; + + procedure is_matching_tag_with_quote is + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(q'[it's]', q'[it's]') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', q'[slow&!it's]') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', q'[it's]') ).to_equal(0); + end; + + procedure is_matching_many_tags is + c_tag_prefix constant varchar2(30) := 'a_long_tag_name_for_testing_'; + l_expression varchar2(32767); + begin + --80 tags of 31 characters, joined with "|": a condition with "member of" for each tag would be over 4000 characters + for i in 1 .. 80 loop + l_expression := l_expression || case when i > 1 then '|' end || c_tag_prefix || lpad(i, 3, '0'); + end loop; + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching(c_tag_prefix||'080', l_expression) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow,'||c_tag_prefix||'001', l_expression) ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('slow', l_expression) ).to_equal(0); + end; + + procedure is_matching_null_tag_element is + begin + --'a,,b' has a null element, so "x member of" it is unknown (null) instead of false when x is not in the list + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', 'a') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', 'x') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', '!x') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', 'a|!x') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', 'a&!x') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a,,b', '!a&!x') ).to_equal(0); + end; + + procedure is_matching_follows_expression_change is + l_result integer; + begin + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'a') ).to_equal(1); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'b') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'a') ).to_equal(1); + begin + l_result := ut3_develop.ut_suite_tag_filter.is_matching('a', 'a&'); + ut.fail('Expected exception but nothing was raised'); + exception + when others then + ut.expect( sqlcode ).to_equal( ut3_develop.ut_utils.gc_invalid_tag_expression ); + end; + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'b') ).to_equal(0); + ut.expect( ut3_develop.ut_suite_tag_filter.is_matching('a', 'a') ).to_equal(1); + end; + + procedure is_matching_invalid_expression is + l_result integer; + begin + l_result := ut3_develop.ut_suite_tag_filter.is_matching('slow', 'slow&|db'); + end; + + procedure is_matching_incomplete_expression is + --legacy notation turns ',' into an empty expression + l_expressions ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list('slow|', 'slow&!', '!', '(slow', ','); + l_result integer; + begin + for i in 1 .. l_expressions.count loop + begin + l_result := ut3_develop.ut_suite_tag_filter.is_matching('slow', l_expressions(i)); + ut.fail('Expected exception for tag expression "'||l_expressions(i)||'" but nothing was raised'); + exception + when others then + ut.expect( sqlcode, 'Tag expression "'||l_expressions(i)||'"' ).to_equal( ut3_develop.ut_utils.gc_invalid_tag_expression ); + end; + end loop; + end; + + procedure create_tags_suite is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package test_tags_1324 as + --%suite + --%suitepath(some.path) + --%tags(slow) + + --%context(tags_are_applied_in_contexts) + --%tags(context_tag) + + --%test + --%tags(test_tag) + procedure create_new_mapping; + + --%endcontext + end;]'; + execute immediate q'[create or replace package body test_tags_1324 as + procedure create_new_mapping is begin null; end; + end;]'; + end; + + procedure drop_tags_suite is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_tags_1324'; end; procedure filtering_is_correctly_applied_to_all_items is - l_input_data ut3_develop.ut_suite_cache_rows; - l_expected sys_refcursor; - l_actual sys_refcursor; - begin - l_input_data := ut3_develop.ut_suite_cache_rows( - ut3_develop.ut_suite_cache_row( - 1, 'UT_SUITE', 'some.path.test_tags', 'TEST_USER', 'TEST_TAGS', 'TEST_TAGS', 3, timestamp '2026-05-06 10:23:38.461299', NULL, NULL, 0, NULL, null, null, null, null, null, null, null, null, - ut3_develop.ut_varchar2_rows('slow'), null), - ut3_develop.ut_suite_cache_row( - 2, 'UT_SUITE_CONTEXT', 'some.path.test_tags.nested_context_#1', 'TEST_USER', 'TEST_TAGS', 'NESTED_CONTEXT_#1', 9, timestamp '2026-05-06 10:23:38.461299', 'tags_are_applied_in_contexts', NULL, 0, NULL, null, null, null, null, null, null, null, null, - ut3_develop.ut_varchar2_rows('context_tag'), null), - ut3_develop.ut_suite_cache_row( - 3, 'UT_TEST', 'some.path.test_tags.nested_context_#1.create_new_mapping', 'TEST_USER', 'TEST_TAGS', 'CREATE_NEW_MAPPING', 11, timestamp '2026-05-06 10:23:38.461299', NULL, NULL, 0, NULL, null, null, null, null, null, null, null, null, - ut3_develop.ut_varchar2_rows('test_tag'), ut3_develop.ut_executable_test('UT_EXECUTABLE_TEST', 'test', 'TEST_USER', 'test_tags', 'create_new_mapping', NULL, NULL, NULL, NULL)) - ); - - ut.expect(ut3_develop.ut_suite_tag_filter.apply( l_input_data, 'slow').count).to_equal(3 ); - - open l_expected for select * from table( l_input_data ); - open l_actual for select * from table( ut3_develop.ut_suite_tag_filter.apply( l_input_data, 'slow') ); - ut.expect(l_actual).to_equal(l_expected).join_by('ID'); - - ut.expect( ut3_develop.ut_suite_tag_filter.apply(l_input_data, '!slow').count ).to_equal(0); - ut.expect( ut3_develop.ut_suite_tag_filter.apply(l_input_data, 'bad').count ).to_equal(0); - ut.expect( ut3_develop.ut_suite_tag_filter.apply(l_input_data, '!bad').count ).to_equal(3); - ut.expect( ut3_develop.ut_suite_tag_filter.apply(l_input_data, '!context_tag').count ).to_equal(0); - ut.expect( ut3_develop.ut_suite_tag_filter.apply(l_input_data, 'context_tag').count ).to_equal(3); - ut.expect( ut3_develop.ut_suite_tag_filter.apply(l_input_data, '!test_tag').count ).to_equal(0); - ut.expect( ut3_develop.ut_suite_tag_filter.apply(l_input_data, 'test_tag').count ).to_equal(3); + l_paths ut3_develop.ut_path_items; + l_suites ut3_develop.ut_suite_items; + l_items ut3_develop.ut_suite_cache_rows; + l_expected sys_refcursor; + l_actual sys_refcursor; + + --suite items selected by the tag expression, without the logical suites "some" and "some.path" + function get_items(a_tags varchar2) return ut3_develop.ut_suite_cache_rows is + l_rows ut3_develop.ut_suite_cache_rows; + l_result ut3_develop.ut_suite_cache_rows; + begin + l_rows := ut3_develop.ut_suite_cache_manager.get_suite_rows( l_paths, true, a_tags ); + select value(r) bulk collect into l_result from table(l_rows) r where r.self_type != 'UT_LOGICAL_SUITE'; + return l_result; + end; + begin + --refresh the suite cache of the schema + l_suites := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_tester.test_tags_1324')); + l_paths := ut3_develop.ut_suite_cache_manager.get_schema_paths(ut3_develop.ut_varchar2_list('ut3_tester.test_tags_1324')); + + l_items := get_items('slow'); + ut.expect( l_items.count ).to_equal(3); + + open l_expected for + select 'some.path.test_tags_1324' as path from dual union all + select 'some.path.test_tags_1324.nested_context_#1' from dual union all + select 'some.path.test_tags_1324.nested_context_#1.create_new_mapping' from dual; + open l_actual for select r.path from table( l_items ) r; + ut.expect(l_actual).to_equal(l_expected).unordered(); + + ut.expect( get_items('!slow').count ).to_equal(0); + ut.expect( get_items('bad').count ).to_equal(0); + ut.expect( get_items('!bad').count ).to_equal(3); + ut.expect( get_items('!context_tag').count ).to_equal(0); + ut.expect( get_items('context_tag').count ).to_equal(3); + ut.expect( get_items('!test_tag').count ).to_equal(0); + ut.expect( get_items('test_tag').count ).to_equal(3); end; end test_ut_suite_tag_filter; diff --git a/test/ut3_tester/core/test_ut_suite_tag_filter.pks b/test/ut3_tester/core/test_ut_suite_tag_filter.pks index e7b255d4b..92c8cc744 100644 --- a/test/ut3_tester/core/test_ut_suite_tag_filter.pks +++ b/test/ut3_tester/core/test_ut_suite_tag_filter.pks @@ -5,35 +5,98 @@ create or replace package test_ut_suite_tag_filter is --%context( Conversion to Reverse Polish Notation) - --%test( Test conversion of expression into Reverse Polish Notation) - procedure test_conversion_to_rpn; + --%test( Test conversion of expression into Reverse Polish Notation) + procedure test_conversion_to_rpn; - --%test( Operator is followed by operator) - --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) - procedure test_conversion_opr_by_opr; + --%test( Operator is followed by operator) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure test_conversion_opr_by_opr; - --%test( Operand is followed by operand) - --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) - procedure test_conversion_oprd_by_opd; + --%test( Operand is followed by operand) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure test_conversion_oprd_by_opd; - --%test( Left Bracket is followed by operator) - --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) - procedure test_conversion_lb_by_oper; + --%test( Left Bracket is followed by operator) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure test_conversion_lb_by_oper; - --%test( Right Bracket is followed by operand) - --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) - procedure test_conversion_rb_by_oprd; + --%test( Right Bracket is followed by operand) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure test_conversion_rb_by_oprd; - --%test(Conversion raises exception when empty brackets) - --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) - procedure conversion_throws_when_lb_rb; + --%test(Conversion raises exception when empty brackets) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure conversion_throws_when_lb_rb; + + --%test(Conversion raises exception when a right bracket has no left bracket) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure conversion_throws_when_unmatched_rb; + + --%test(Conversion raises exception for an empty list of tokens) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure conversion_throws_when_empty; + + --%test(Conversion raises exception when the expression ends with an operator) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure conversion_throws_when_trailing_opr; + + --%test(Tokenizing an empty string returns no tokens) + procedure tokenize_empty_string; --%endcontext - --%test( Test conversion of expression from tag into custom where filter for SQL) - procedure conv_from_tag_to_sql_filter; + --%test( Evaluates or, and and not in tag expressions) + procedure is_matching_or_and_not; + + --%test( Evaluates tag expressions against a list of tags) + procedure is_matching_evaluates_tags; + + --%test( Evaluates none and any for items without tags) + procedure is_matching_without_tags; + + --%test( Applies operator precedence, brackets and double negation) + procedure is_matching_operator_precedence; + + --%test( Combines none and any with other tags) + procedure is_matching_none_and_any_combined; + + --%test( Compares tags and the none and any keywords case sensitively) + procedure is_matching_is_case_sensitive; + + --%test( Ignores spaces and tabs in the tag expression) + procedure is_matching_ignores_whitespace; + + --%test( Matches any tags when the tag expression is empty or made of spaces and tabs) + procedure is_matching_empty_expression; + + --%test( Removes spaces and tabs from a tag expression, returning null for one made only of them) + procedure remove_whitespace_from_expression; + + --%test( Evaluates a tag containing a quote) + procedure is_matching_tag_with_quote; + + --%test( Evaluates an expression with many tags) + procedure is_matching_many_tags; + + --%test( Follows three-valued logic for an empty element in the list of tags) + procedure is_matching_null_tag_element; + + --%test( Evaluates the current expression after the expression changes or an invalid expression is given) + procedure is_matching_follows_expression_change; + + --%test( Raises exception for an invalid tag expression) + --%throws(ut3_develop.ut_utils.gc_invalid_tag_expression) + procedure is_matching_invalid_expression; + + --%test( Raises exception for an incomplete tag expression) + procedure is_matching_incomplete_expression; + + procedure create_tags_suite; + procedure drop_tags_suite; --%test( Regression for issue #1324 - corect filtering by tags with suitepath and contexts) + --%beforetest(create_tags_suite) + --%aftertest(drop_tags_suite) procedure filtering_is_correctly_applied_to_all_items; end test_ut_suite_tag_filter; diff --git a/test/ut3_tester/core/test_ut_utils.pkb b/test/ut3_tester/core/test_ut_utils.pkb index 4dc10492b..d46835f66 100644 --- a/test/ut3_tester/core/test_ut_utils.pkb +++ b/test/ut3_tester/core/test_ut_utils.pkb @@ -287,7 +287,7 @@ end;'; l_varchar2_byte_limit integer := 32767; l_workaround_byte_limit integer := 8191; l_singlebyte_string_max_size varchar2(32767 char) := rpad('x',l_varchar2_byte_limit,'x'); - l_twobyte_character char(1 char) := 'οΏ½?'; + l_twobyte_character char(1 char) := unistr('\00E4'); l_clob_multibyte clob := l_twobyte_character||l_singlebyte_string_max_size; --here we have 32769(2+32767) bytes and 32768 chars l_expected ut3_develop.ut_varchar2_list := ut3_develop.ut_varchar2_list(); l_result ut3_develop.ut_varchar2_list; diff --git a/test/ut3_tester/core/test_ut_utils.pks b/test/ut3_tester/core/test_ut_utils.pks index ca2e7b304..82145f908 100644 --- a/test/ut3_tester/core/test_ut_utils.pks +++ b/test/ut3_tester/core/test_ut_utils.pks @@ -93,7 +93,6 @@ create or replace package test_ut_utils is procedure clean_append_with_multibyte; --%test(clob_to_table - converts multibyte CLOB to ut_varchar2_list) - --%disabled(We cannot run this test successfully on 12.1 until we change NLSCHARACTERSET from US7ASCII to AL32UTF8) procedure test_clob_to_table_multibyte; --%test(to_version - splits version string into individual version components) diff --git a/test/ut3_tester_helper/annotation_cache_helper.pkb b/test/ut3_tester_helper/annotation_cache_helper.pkb index 0715b6af1..63e20159d 100644 --- a/test/ut3_tester_helper/annotation_cache_helper.pkb +++ b/test/ut3_tester_helper/annotation_cache_helper.pkb @@ -90,6 +90,67 @@ create or replace package body annotation_cache_helper as end; end; + /* + Suites spread across packages, only child_suite is granted: + parent_suite package parent_suite, not granted, tagged parent_tag + parent_suite.child_suite package child_suite, granted + hidden_path.sub.lone_suite package lone_suite, not granted, below logical suites hidden_path and hidden_path.sub + */ + procedure setup_suite_hierarchy is + pragma autonomous_transaction; + begin + execute immediate + 'create or replace package ut3_cache_test_owner.parent_suite authid definer is + --%suite + --%tags(parent_tag) + + --%test + procedure parent_test; + end;'; + execute immediate + 'create or replace package body ut3_cache_test_owner.parent_suite is + procedure parent_test is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + end;'; + execute immediate + 'create or replace package ut3_cache_test_owner.child_suite authid definer is + --%suite + --%suitepath(parent_suite) + + --%test + procedure child_test; + end;'; + execute immediate + 'create or replace package body ut3_cache_test_owner.child_suite is + procedure child_test is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + end;'; + execute immediate + 'create or replace package ut3_cache_test_owner.lone_suite authid definer is + --%suite + --%suitepath(hidden_path.sub) + + --%test + procedure lone_test; + end;'; + execute immediate + 'create or replace package body ut3_cache_test_owner.lone_suite is + procedure lone_test is begin ut3_develop.ut.expect( 1 ).to_equal( 1 ); end; + end;'; + execute immediate 'grant execute on ut3_cache_test_owner.child_suite to ut3_no_extra_priv_user'; + end; + + procedure cleanup_suite_hierarchy is + pragma autonomous_transaction; + begin + for i in ( select column_value as package_name from table(ut3_develop.ut_varchar2_list('parent_suite','child_suite','lone_suite')) ) loop + begin + execute immediate 'drop package ut3_cache_test_owner.'||i.package_name; + exception + when others then + null; + end; + end loop; + end; + procedure cleanup_new_suite is pragma autonomous_transaction; begin @@ -122,21 +183,34 @@ create or replace package body annotation_cache_helper as pragma autonomous_transaction; begin execute immediate - 'create or replace function ' || a_user || '.call_ut_run return clob is + 'create or replace function ' || a_user || '.call_ut_run(a_path varchar2 := ''ut3_cache_test_owner'', a_tags varchar2 := null) return clob is l_data ut3_develop.ut_varchar2_list; l_results clob; begin - select * bulk collect into l_data from table (ut3_develop.ut.run( ''ut3_cache_test_owner'' )); + select * bulk collect into l_data from table (ut3_develop.ut.run( a_path, a_tags => a_tags )); return ut3_tester_helper.main_helper.table_to_clob( l_data ); end; '; execute immediate 'grant execute on ' || a_user || '.call_ut_run to public '; + execute immediate + 'create or replace function ' || a_user || '.call_suites_info return clob is + l_data ut3_develop.ut_varchar2_list; + begin + select i.item_type || '' '' || i.path + bulk collect into l_data + from table (ut3_develop.ut_runner.get_suites_info( ''UT3_CACHE_TEST_OWNER'' )) i + order by i.path; + return ut3_tester_helper.main_helper.table_to_clob( l_data ); + end; + '; + execute immediate 'grant execute on ' || a_user || '.call_suites_info to public '; end; procedure drop_run_function_for_user(a_user varchar2) is pragma autonomous_transaction; begin execute immediate 'drop function ' || a_user || '.call_ut_run'; + execute immediate 'drop function ' || a_user || '.call_suites_info'; end; procedure create_run_function_for_users is @@ -159,10 +233,17 @@ create or replace package body annotation_cache_helper as drop_run_function_for_user( 'ut3_develop' ); end; - function run_tests_as(a_user varchar2) return clob is + function run_tests_as(a_user varchar2, a_path varchar2 := 'ut3_cache_test_owner', a_tags varchar2 := null) return clob is + l_results clob; + begin + execute immediate 'begin :x := '||a_user||'.call_ut_run(:a_path, :a_tags); end;' using out l_results, a_path, a_tags; + return l_results; + end; + + function get_suites_info_as(a_user varchar2) return clob is l_results clob; begin - execute immediate 'begin :x := '||a_user||'.call_ut_run; end;' using out l_results; + execute immediate 'begin :x := '||a_user||'.call_suites_info; end;' using out l_results; return l_results; end; end; diff --git a/test/ut3_tester_helper/annotation_cache_helper.pks b/test/ut3_tester_helper/annotation_cache_helper.pks index d6ab1f8e2..88b82d872 100644 --- a/test/ut3_tester_helper/annotation_cache_helper.pks +++ b/test/ut3_tester_helper/annotation_cache_helper.pks @@ -12,10 +12,14 @@ create or replace package annotation_cache_helper as procedure disable_ddl_trigger; procedure enable_ddl_trigger; + procedure setup_suite_hierarchy; + procedure cleanup_suite_hierarchy; + procedure create_run_function_for_users; procedure drop_run_function_for_users; - function run_tests_as(a_user varchar2) return clob; + function run_tests_as(a_user varchar2, a_path varchar2 := 'ut3_cache_test_owner', a_tags varchar2 := null) return clob; + function get_suites_info_as(a_user varchar2) return clob; end; / \ No newline at end of file diff --git a/test/ut3_tester_helper/coverage_helper.pkb b/test/ut3_tester_helper/coverage_helper.pkb index ef14c586f..8c978d046 100644 --- a/test/ut3_tester_helper/coverage_helper.pkb +++ b/test/ut3_tester_helper/coverage_helper.pkb @@ -2,22 +2,9 @@ create or replace package body coverage_helper is g_job_no integer := 0; - function block_coverage_available return boolean is - begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - return true; - $else - return false; - $end - end; - function covered_package_name return varchar2 is begin - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - return 'dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long'; - $else - return 'dummy_coverage'; - $end + return 'dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long'; end; function substitute_covered_package( a_text varchar2, a_substitution varchar2 ) return varchar2 is @@ -314,7 +301,7 @@ create or replace package body coverage_helper is begin g_job_no := g_job_no + 1; l_job_name := 'utPLSQL_selftest_job_'||g_job_no; - dbms_lock.sleep(0.15); + dbms_session.sleep(0.15); dbms_scheduler.create_job( job_name => l_job_name, job_type => 'PLSQL_BLOCK', @@ -326,7 +313,7 @@ create or replace package body coverage_helper is ); while (l_job_run_info.status is null or l_job_run_info.status not in ('SUCCEEDED','FAILED')) and i < 6000 loop l_job_run_info := get_job_status( l_job_name, l_timestamp ); - dbms_lock.sleep(0.1); + dbms_session.sleep(0.1); i := i + 1; end loop; commit; @@ -369,7 +356,7 @@ create or replace package body coverage_helper is pragma autonomous_transaction; begin run_job_and_wait_for_finish( a_plsql_block ); - dbms_lock.sleep(0.1); + dbms_session.sleep(0.1); execute immediate q'[ declare l_results ut3_develop.ut_varchar2_list; diff --git a/test/ut3_tester_helper/coverage_helper.pks b/test/ut3_tester_helper/coverage_helper.pks index 8d2c1c150..d6a57a143 100644 --- a/test/ut3_tester_helper/coverage_helper.pks +++ b/test/ut3_tester_helper/coverage_helper.pks @@ -1,7 +1,5 @@ create or replace package coverage_helper is - function block_coverage_available return boolean; - function covered_package_name return varchar2; function substitute_covered_package( a_text varchar2, a_substitution varchar2 := '{p}' ) return varchar2; diff --git a/test/ut3_tester_helper/run_helper.pkb b/test/ut3_tester_helper/run_helper.pkb index c56f31dc0..6bd88bfa8 100644 --- a/test/ut3_tester_helper/run_helper.pkb +++ b/test/ut3_tester_helper/run_helper.pkb @@ -146,6 +146,28 @@ create or replace package body run_helper is ut3_develop.ut_annotation_manager.rebuild_annotation_cache('UT3_TESTER_HELPER','PROCEDURE'); end; + procedure setup_cache_context_disabled is + pragma autonomous_transaction; + begin + --the procedures that cleanup_cache drops + setup_cache_objects(); + execute immediate q'[create or replace package ut3_user.dummy_test_package as + --%suite(dummy_test_suite) + --%suitepath(some.path) + + --%test(dummy_test) + procedure some_dummy_test_procedure; + + --%context(dummy_context) + + --%test(disabled_test) + --%disabled(not ready) + procedure disabled_test_procedure; + + --%endcontext + end;]'; + end; + procedure cleanup_cache is pragma autonomous_transaction; begin diff --git a/test/ut3_tester_helper/run_helper.pks b/test/ut3_tester_helper/run_helper.pks index 6c5dd4a3b..c46b99a3f 100644 --- a/test/ut3_tester_helper/run_helper.pks +++ b/test/ut3_tester_helper/run_helper.pks @@ -7,6 +7,7 @@ create or replace package run_helper is procedure setup_cache_objects; procedure setup_cache_objectstag; procedure setup_cache_twotags; + procedure setup_cache_context_disabled; procedure setup_cache; procedure cleanup_cache; procedure create_db_link; diff --git a/test/ut3_user/api/test_ut_run.pkb b/test/ut3_user/api/test_ut_run.pkb index b4040bb43..12ab6cdba 100644 --- a/test/ut3_user/api/test_ut_run.pkb +++ b/test/ut3_user/api/test_ut_run.pkb @@ -23,6 +23,45 @@ create or replace package body test_ut_run is ut3_tester_helper.run_helper.drop_ut3_user_tests(); end; + --a suite on suitepath "tests", as test_package_1 in ut3_tester_helper (see run_helper.create_ut3_user_tests) + procedure create_test_suite_in_ut3_user is + pragma autonomous_transaction; + begin + execute immediate q'[create or replace package test_suite_in_ut3_user is + --%suite + --%suitepath(tests) + + --%test + procedure test1; + end;]'; + execute immediate q'[create or replace package body test_suite_in_ut3_user is + procedure test1 is + begin + dbms_output.put_line('test_suite_in_ut3_user.test1 executed'); + end; + end;]'; + end; + + procedure drop_test_suite_in_ut3_user is + pragma autonomous_transaction; + begin + execute immediate 'drop package test_suite_in_ut3_user'; + end; + + procedure run_groups_suites_by_schema is + l_results clob; + begin + --Act - ut3_user:tests sorts between ut3_tester_helper:tests and ut3_tester_helper:tests2 by path + l_results := ut3_tester_helper.main_helper.table_to_clob( + ut3_tester_helper.run_helper.run( + ut3_develop.ut_varchar2_list('ut3_user:tests', 'ut3_tester_helper:tests', 'ut3_tester_helper:tests2'), + a_tags => null + ) + ); + --Assert - UT3_TESTER_HELPER comes before UT3_USER + ut.expect( l_results ).to_be_like( '%test_package_2.test1 executed%test_package_3.test1 executed%test_suite_in_ut3_user.test1 executed%' ); + end; + procedure ut_version is begin ut.expect(ut3_develop.ut.version()).to_match('^v\d+\.\d+\.\d+\.\d+(-\w+)?$'); @@ -551,7 +590,7 @@ Failures:% ORA-04068: existing state of packages (DB_LOOPBACK%) has been discarded ORA-04061: existing state of package body "%.STATEFUL_PACKAGE" has been invalidated ORA-04065: not executed, altered or dropped package body "%.STATEFUL_PACKAGE"% - ORA-06512: at line 6% + ORA-06512: at line 7% 1 tests, 0 failed, 1 errored, 0 disabled, 0 warning(s)%'; --Act @@ -896,6 +935,38 @@ Failures:% ut.expect(anydata.convertCollection(l_actual)).to_equal(anydata.convertCollection(l_expected)); end; + + procedure run_proc_prints_support_info is + begin + ut3_develop.ut.run('ut3_tester_helper.test_package_1'); + + ut.expect( ut3_tester_helper.main_helper.get_dbms_output_as_clob() ).to_be_like( '%' || reporters.gc_support_line || '%' ); + end; + + procedure run_proc_omits_support_info is + begin + ut3_develop.ut.run('ut3_tester_helper.test_package_1', a_support_info => false); + + ut.expect( ut3_tester_helper.main_helper.get_dbms_output_as_clob() ).not_to_be_like( '%' || reporters.gc_support_line || '%' ); + end; + + procedure run_func_prints_support_info is + l_results ut3_develop.ut_varchar2_list; + begin + select * bulk collect into l_results + from table ( ut3_develop.ut.run('ut3_tester_helper.test_package_1') ); + + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_be_like( '%' || reporters.gc_support_line || '%' ); + end; + + procedure run_func_omits_support_info is + l_results ut3_develop.ut_varchar2_list; + begin + select * bulk collect into l_results + from table ( ut3_develop.ut.run('ut3_tester_helper.test_package_1', a_support_info => 0) ); + + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like( '%' || reporters.gc_support_line || '%' ); + end; procedure test_run_by_one_tag is l_results clob; @@ -1296,9 +1367,83 @@ procedure tag_exclude_run_fun_pth_lst_lg is ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); l_results := ut3_tester_helper.run_helper.run(a_tags => '(development|end_to_end))'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); - ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m'); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%'); + + end; + + procedure invalid_tag_expression_no_tests is + l_results ut3_develop.ut_varchar2_list; + begin + --the package does not exist, so no test is there to evaluate the tag expression on + l_results := ut3_tester_helper.run_helper.run('ut3_tester_helper.no_such_test_package', a_tags => '(development|end_to_end))'); + end; + procedure tag_run_pkg_wildcard is + l_results clob; + begin + --test_tag_pkg_3 has no test tagged fast + l_results := ut3_tester_helper.main_helper.table_to_clob( + ut3_tester_helper.run_helper.run('ut3_tester_helper.test_tag_pkg_*', a_tags => 'fast') + ); + --Assert + ut.expect( l_results ).to_be_like( '%test_tag_pkg_1.test1 executed%' ); + ut.expect( l_results ).to_be_like( '%test_tag_pkg_2.test3 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_1.test2 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_2.test4 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_3%' ); + end; + + procedure tag_run_proc_wildcard is + l_results clob; + begin + --test_tag_pkg_1.test2 is not tagged fast + l_results := ut3_tester_helper.main_helper.table_to_clob( + ut3_tester_helper.run_helper.run('ut3_tester_helper.test_tag_pkg_1.test*', a_tags => 'fast') + ); + --Assert + ut.expect( l_results ).to_be_like( '%test_tag_pkg_1.test1 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_1.test2 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_2%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_3%' ); + end; + + procedure tag_run_suitepath_wildcard is + l_results clob; + begin + --suitepath suite3 (test_tag_pkg_3) has no test tagged fast + l_results := ut3_tester_helper.main_helper.table_to_clob( + ut3_tester_helper.run_helper.run('ut3_tester_helper:suite*', a_tags => 'fast') + ); + --Assert + ut.expect( l_results ).to_be_like( '%test_tag_pkg_1.test1 executed%' ); + ut.expect( l_results ).to_be_like( '%test_tag_pkg_2.test3 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_1.test2 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_2.test4 executed%' ); + ut.expect( l_results ).not_to_be_like( '%test_tag_pkg_3%' ); + end; + + procedure tag_run_wildcard_none_left is + l_results ut3_develop.ut_varchar2_list; + begin + l_results := ut3_tester_helper.run_helper.run('ut3_tester_helper.test_tag_pkg_*', a_tags => 'nonexisting'); + ut.fail('Expected exception ORA-20204 was not raised'); + exception + when others then + ut.expect(sqlerrm).to_be_like('%ORA-20204: Suite package ut3_tester_helper.test_tag_pkg_* does not exist%'); + end; + + procedure blank_tags_run_all_tests is + l_expected ut3_develop.ut_varchar2_list; + l_actual ut3_develop.ut_varchar2_list; + begin + l_expected := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests,:tests2')); + l_actual := ut3_tester_helper.run_helper.run(ut3_develop.ut_varchar2_list(':tests,:tests2'), a_tags => ' '||chr(9)||' '); + + remove_time_from_results(l_expected); + remove_time_from_results(l_actual); + ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_actual) ).to_be_like( '%test_package_1.test1%executed%' ); + ut.expect( anydata.convertCollection(l_actual) ).to_equal( anydata.convertCollection(l_expected) ); end; procedure set_application_info is diff --git a/test/ut3_user/api/test_ut_run.pks b/test/ut3_user/api/test_ut_run.pks index c57788bff..552c5dbf3 100644 --- a/test/ut3_user/api/test_ut_run.pks +++ b/test/ut3_user/api/test_ut_run.pks @@ -181,6 +181,39 @@ create or replace package test_ut_run is --%endcontext + --%context(support_info) + + --%displayname(Support line) + --%beforeall(create_ut3_user_tests) + --%afterall(drop_ut3_user_tests) + + --%test(ut.run() procedure prints support line by default) + procedure run_proc_prints_support_info; + + --%test(ut.run() procedure omits support line when a_support_info is false) + procedure run_proc_omits_support_info; + + --%test(ut.run() function prints support line by default) + procedure run_func_prints_support_info; + + --%test(ut.run() function omits support line when a_support_info is 0) + procedure run_func_omits_support_info; + + --%endcontext + + --%context(run with paths in several schemas) + + --%beforeall(create_ut3_user_tests, create_test_suite_in_ut3_user) + --%afterall(drop_test_suite_in_ut3_user, drop_ut3_user_tests) + + --%test(Runs the suites of each schema together, in order of schema names) + procedure run_groups_suites_by_schema; + + --%endcontext + + procedure create_test_suite_in_ut3_user; + procedure drop_test_suite_in_ut3_user; + --%context(run with tags) --%displayname(Call ut.run with #tags) @@ -266,6 +299,25 @@ create or replace package test_ut_run is --%throws(-20219) procedure invalid_tag_expression; + --%test(Raises an error for an invalid tag expression when the path selects no tests) + --%throws(-20219) + procedure invalid_tag_expression_no_tests; + + --%test(Runs tests matching the tags from packages selected by a wildcard, skipping packages without such tests) + procedure tag_run_pkg_wildcard; + + --%test(Runs tests matching the tags from tests selected by a wildcard, skipping the other tests) + procedure tag_run_proc_wildcard; + + --%test(Runs tests matching the tags from suitepaths selected by a wildcard, skipping suites without such tests) + procedure tag_run_suitepath_wildcard; + + --%test(Raises an error naming the wildcard path when the tags exclude all tests it selects) + procedure tag_run_wildcard_none_left; + + --%test(Runs the same tests as without tags when the tag expression is made of spaces and tabs) + procedure blank_tags_run_all_tests; + --%endcontext --%context(ut3_info context) diff --git a/test/ut3_user/api/test_ut_runner.pkb b/test/ut3_user/api/test_ut_runner.pkb index d665718e1..9ef709e91 100644 --- a/test/ut3_user/api/test_ut_runner.pkb +++ b/test/ut3_user/api/test_ut_runner.pkb @@ -25,6 +25,11 @@ create or replace package body test_ut_runner is ut3_tester_helper.run_helper.cleanup_cache(); end; + procedure setup_cache_context_disabled is + begin + ut3_tester_helper.run_helper.setup_cache_context_disabled(); + end; + procedure create_test_spec as pragma autonomous_transaction; @@ -376,6 +381,80 @@ end;'; ut.expect(l_actual).to_equal(l_expected); end; + procedure test_get_suites_info_context is + l_expected sys_refcursor; + l_actual sys_refcursor; + begin + --Arrange + open l_expected for + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, + 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'dummy_test' item_description, 'UT_TEST' item_type, 5 item_line_no, + 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'NESTED_CONTEXT_#1' item_name, + 'dummy_context' item_description, 'UT_SUITE_CONTEXT' item_type, 8 item_line_no, + 'some.path.dummy_test_package.nested_context_#1' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DISABLED_TEST_PROCEDURE' item_name, + 'disabled_test' item_description, 'UT_TEST' item_type, 10 item_line_no, + 'some.path.dummy_test_package.nested_context_#1.disabled_test_procedure' path, 1 disabled_flag, 'not ready' disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'PATH' object_name, 'PATH' item_name, + null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, + 'some.path' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'SOME' object_name, 'SOME' item_name, + null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, + 'some' path, 0 disabled_flag, null disabled_reason, null tags + from dual; + --Act + open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('UT3_USER','DUMMY_TEST_PACKAGE')); + --Assert + ut.expect(l_actual).to_equal(l_expected); + end; + + procedure test_get_suites_info_by_proc is + l_expected sys_refcursor; + l_actual sys_refcursor; + begin + --Arrange + open l_expected for + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'DUMMY_TEST_PACKAGE' item_name, + 'dummy_test_suite' item_description, 'UT_SUITE' item_type, 2 item_line_no, + 'some.path.dummy_test_package' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'DUMMY_TEST_PACKAGE' object_name, 'SOME_DUMMY_TEST_PROCEDURE' item_name, + 'dummy_test' item_description, 'UT_TEST' item_type, 6 item_line_no, + 'some.path.dummy_test_package.some_dummy_test_procedure' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'PATH' object_name, 'PATH' item_name, + null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, + 'some.path' path, 0 disabled_flag, null disabled_reason, null tags + from dual union all + select + 'UT3_USER' object_owner, 'SOME' object_name, 'SOME' item_name, + null item_description, 'UT_LOGICAL_SUITE' item_type, null item_line_no, + 'some' path, 0 disabled_flag, null disabled_reason, null tags + from dual; + --Act + open l_actual for select * from table(ut3_develop.ut_runner.get_suites_info('ut3_user.dummy_test_package.some_dummy_test_procedure')); + --Assert + ut.expect(l_actual).to_equal(l_expected); + end; + procedure test_get_reporters_list is l_expected sys_refcursor; l_actual sys_refcursor; @@ -386,7 +465,6 @@ end;'; select 'UT3_DEVELOP.UT_DEBUG_REPORTER', 'Y' from dual union all select 'UT3_DEVELOP.UT_COVERAGE_HTML_REPORTER', 'Y' from dual union all select 'UT3_DEVELOP.UT_COVERAGE_SONAR_REPORTER', 'Y' from dual union all - select 'UT3_DEVELOP.UT_COVERALLS_REPORTER', 'Y' from dual union all select 'UT3_DEVELOP.UT_DOCUMENTATION_REPORTER', 'Y' from dual union all select 'UT3_DEVELOP.UT_JUNIT_REPORTER', 'Y' from dual union all select 'UT3_DEVELOP.UT_REALTIME_REPORTER', 'Y' from dual union all diff --git a/test/ut3_user/api/test_ut_runner.pks b/test/ut3_user/api/test_ut_runner.pks index e003ba852..742d4ad1c 100644 --- a/test/ut3_user/api/test_ut_runner.pks +++ b/test/ut3_user/api/test_ut_runner.pks @@ -70,6 +70,18 @@ create or replace package test_ut_runner is --%aftertest(cleanup_cache) procedure test_get_suites_info_by_path; + procedure setup_cache_context_disabled; + + --%test(get_suites_info returns contexts and disabled tests) + --%beforetest(setup_cache_context_disabled) + --%aftertest(cleanup_cache) + procedure test_get_suites_info_context; + + --%test(get_suites_info returns a test and its parents for a procedure path) + --%beforetest(setup_cache_objects) + --%aftertest(cleanup_cache) + procedure test_get_suites_info_by_proc; + --%test(get_reporters_list returns a cursor containing all built-in reporters and information about output-reporter) --%beforetest(setup_cache_objects) --%aftertest(cleanup_cache) diff --git a/test/ut3_user/expectations/binary/test_to_be_within.pkb b/test/ut3_user/expectations/binary/test_to_be_within.pkb index 032b684a5..c9aae6ee2 100644 --- a/test/ut3_user/expectations/binary/test_to_be_within.pkb +++ b/test/ut3_user/expectations/binary/test_to_be_within.pkb @@ -199,7 +199,7 @@ create or replace package body test_to_be_within is begin --Arrange --Act - ut3_develop.ut.expect(sysdate).to_be_within(INTERVAL '1' MONTH).of_(sysdate+ 46); + ut3_develop.ut.expect(sysdate).to_be_within(INTERVAL '1' MONTH).of_(sysdate+ 47); --Assert l_expected_message := q'[Actual: % (date) was expected to be within 1 month of % (date)]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); diff --git a/test/ut3_user/expectations/test_expectation_anydata.pkb b/test/ut3_user/expectations/test_expectation_anydata.pkb index c70d41f9e..5f76e6715 100644 --- a/test/ut3_user/expectations/test_expectation_anydata.pkb +++ b/test/ut3_user/expectations/test_expectation_anydata.pkb @@ -1229,7 +1229,6 @@ Rows: [ 60 differences, showing first 20 ] end; - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then procedure long_names_object_types is pragma autonomous_transaction; begin @@ -1253,7 +1252,6 @@ Rows: [ 60 differences, showing first 20 ] execute immediate 'drop type very_long_type_name_valid_for_oracle_12_so_utPLSQL_should_allow_it_definitely_well_still_not_reached_128_but_wait_we_did_it'; raise; end; - $end end; / \ No newline at end of file diff --git a/test/ut3_user/expectations/test_expectation_anydata.pks b/test/ut3_user/expectations/test_expectation_anydata.pks index 54c246bd3..557eb58db 100644 --- a/test/ut3_user/expectations/test_expectation_anydata.pks +++ b/test/ut3_user/expectations/test_expectation_anydata.pks @@ -237,10 +237,8 @@ create or replace package test_expectation_anydata is --%test ( Reports success when comparing complex nested objects ) procedure complex_nested_object_success; - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then --%test ( Compares object types with long names - Issue #1235 ) procedure long_names_object_types; - $end end; / diff --git a/test/ut3_user/expectations/test_expectations_cursor.pkb b/test/ut3_user/expectations/test_expectations_cursor.pkb index a4ef4e8f2..aa5375500 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pkb +++ b/test/ut3_user/expectations/test_expectations_cursor.pkb @@ -2843,8 +2843,6 @@ Check the query and data for errors.'; l_expected_data(1).col4 := 2016; l_expected_data(1).col5 := -1; - --Select on package level nested table types supported only since Oracle 12 - $if dbms_db_version.version >= 12 $then open l_expected for select * from table (l_expected_data); @@ -2869,7 +2867,6 @@ Check the query and data for errors.'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); ut.expect(l_actual_message).to_be_like(l_expected_message); - $end end; procedure uc_columns_exclude is @@ -2890,19 +2887,57 @@ Check the query and data for errors.'; l_expected sys_refcursor; begin -- populate actual - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then - open l_actual for - select rownum as id, '1' some_column_with_a_pretty_long_enough_name from dual; + open l_actual for + select rownum as id, '1' some_column_with_a_pretty_long_enough_name from dual; - open l_expected for - select rownum as id, '1' some_column_with_a_pretty_long_enough_name from dual; + open l_expected for + select rownum as id, '1' some_column_with_a_pretty_long_enough_name from dual; - ut3_develop.ut.expect(l_actual).to_equal(l_expected).include('ID,SOME_COLUMN_WITH_A_PRETTY_LONG_ENOUGH_NAME').join_by('ID'); - --Assert - ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); - $else - null; - $end + ut3_develop.ut.expect(l_actual).to_equal(l_expected).include('ID,SOME_COLUMN_WITH_A_PRETTY_LONG_ENOUGH_NAME').join_by('ID'); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + end; + + procedure compare_column_names_over_max_identifier is + l_actual sys_refcursor; + l_expected sys_refcursor; + --An unaliased literal gets a column name longer than an identifier can be + l_sql varchar2(4000) := 'select '''||rpad('a',ora_max_name_len_supported + 10,'a')||''' from dual'; + begin + --Act + open l_actual for l_sql; + open l_expected for l_sql; + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + --Act + open l_actual for l_sql; + open l_expected for l_sql||' connect by level <= 2'; + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(1); + end; + + procedure compare_varchar2_described_over_4000 is + l_actual sys_refcursor; + l_expected sys_refcursor; + --A dynamic bind longer than 4000 chars is described as a varchar2 longer than 4000, even with max_string_size=standard + c_sql constant varchar2(100) := 'select :some_text as some_text from dual'; + begin + --Act + open l_actual for c_sql using rpad('x',4001,'x'); + open l_expected for c_sql using rpad('x',4001,'x'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); + + --Act + open l_actual for c_sql using rpad('x',4001,'x'); + open l_expected for c_sql using rpad('y',4001,'y'); + ut3_develop.ut.expect(l_actual).to_equal(l_expected); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(1); end; procedure compare_specific_column_names is diff --git a/test/ut3_user/expectations/test_expectations_cursor.pks b/test/ut3_user/expectations/test_expectations_cursor.pks index 8cceb5e01..d7ff823de 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pks +++ b/test/ut3_user/expectations/test_expectations_cursor.pks @@ -479,6 +479,12 @@ create or replace package test_expectations_cursor is --%test( Compares cursors with long column names - Issue #952 ) procedure compare_long_column_names; + --%test( Compares cursors with column names longer than the maximum identifier length ) + procedure compare_column_names_over_max_identifier; + + --%test( Compares cursors with varchar2 columns described as longer than 4000 ) + procedure compare_varchar2_described_over_4000; + --%test( Compares cursors with specific column names - Issue #997 ) procedure compare_specific_column_names; diff --git a/test/ut3_user/reporters.pks b/test/ut3_user/reporters.pks index c5ad72e22..412091984 100644 --- a/test/ut3_user/reporters.pks +++ b/test/ut3_user/reporters.pks @@ -1,5 +1,7 @@ create or replace package reporters is + gc_support_line constant varchar2(200) := 'Using utPLSQL at work? Get support and help keep it maintained: https://utplsql.org/support'; + --%suite --%suitepath(utplsql.test_user) diff --git a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb index ad6c9dbb4..49e0410ba 100644 --- a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb @@ -12,11 +12,7 @@ create or replace package body test_cov_cobertura_reporter is --Arrange l_name := ut3_tester_helper.coverage_helper.covered_package_name; l_file_path := 'test/ut3_develop.'||ut3_tester_helper.coverage_helper.covered_package_name||'.pkb'; - if ut3_tester_helper.coverage_helper.block_coverage_available then - l_block_cov := ''; - else - l_block_cov := ''; - end if; + l_block_cov := ''; l_expected := q'[ diff --git a/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb index 50d7bfe4c..9f2409637 100644 --- a/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_coverage_sonar_reporter.pkb @@ -6,11 +6,7 @@ create or replace package body test_coverage_sonar_reporter is l_block_cov clob; begin --Arrange - if ut3_tester_helper.coverage_helper.block_coverage_available then - l_block_cov := ''; - else - l_block_cov := ''; - end if; + l_block_cov := ''; l_expected := ' diff --git a/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pkb b/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pkb index 90cfb484e..adf7b51d1 100644 --- a/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pkb +++ b/test/ut3_user/reporters/test_coverage/test_coverage_standalone.pkb @@ -7,11 +7,7 @@ create or replace package body test_coverage_standalone is begin l_file_path := 'package body ut3_develop.'||a_object_name; --Arrange - if ut3_tester_helper.coverage_helper.block_coverage_available then - l_block_cov := ''; - else - l_block_cov := ''; - end if; + l_block_cov := ''; l_expected := q'[ diff --git a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb deleted file mode 100644 index e3806cd97..000000000 --- a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb +++ /dev/null @@ -1,77 +0,0 @@ -create or replace package body test_coveralls_reporter is - - procedure report_on_file is - l_expected clob; - l_actual clob; - l_file_path varchar2(250); - begin - --Arrange - l_file_path := 'test/ut3_develop.'||ut3_tester_helper.coverage_helper.covered_package_name||'.pkb'; - l_expected := q'[{"source_files":[ -{ "name": "]'||l_file_path||q'[", -"coverage": [ -null, -null, -null, -3, -null, -0 -] -} -]} - ]'; - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - a_path => 'ut3_develop.test_dummy_coverage', - a_reporter => ut3_develop.ut_coveralls_reporter( ), - a_source_files => ut3_develop.ut_varchar2_list( ']'||l_file_path||q'[' ), - a_test_files => ut3_develop.ut_varchar2_list( ) - ) - ]' - ); - --Assert - ut.expect(l_actual).to_equal(l_expected); - end; - - procedure report_zero_coverage is - l_expected clob; - l_actual clob; - begin - --Arrange - l_expected := q'[{"source_files":[ -{ "name": "package body ut3_develop.]'||ut3_tester_helper.coverage_helper.covered_package_name||q'[", -"coverage": [ -0, -0, -0, -0, -0, -0, -0, -0, -0 -] -} -]} - ]'; - - --Act - l_actual := - ut3_tester_helper.coverage_helper.run_tests_as_job( - q'[ - ut3_develop.ut.run( - 'ut3_develop.test_dummy_coverage.zero_coverage', - ut3_develop.ut_coveralls_reporter(), - a_include_objects => ut3_develop.ut_varchar2_list('UT3_DEVELOP.]'||ut3_tester_helper.coverage_helper.covered_package_name||q'[') - ) - ]' - ); - --Assert - ut.expect(l_actual).to_equal(l_expected); - - end; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks deleted file mode 100644 index d958b8f12..000000000 --- a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pks +++ /dev/null @@ -1,13 +0,0 @@ -create or replace package test_coveralls_reporter is - - --%suite(ut_coveralls_reporter) - --%suitepath(utplsql.test_user.reporters.test_coverage) - - --%test(reports on a project file mapped to database object) - procedure report_on_file; - - --%test(reports zero coverage on each line of non-executed database object) - procedure report_zero_coverage; - -end; -/ diff --git a/test/ut3_user/reporters/test_coverage/test_extended_coverage.pkb b/test/ut3_user/reporters/test_coverage/test_extended_coverage.pkb index d7f1b61d7..f6f76b62f 100644 --- a/test/ut3_user/reporters/test_coverage/test_extended_coverage.pkb +++ b/test/ut3_user/reporters/test_coverage/test_extended_coverage.pkb @@ -2,13 +2,7 @@ create or replace package body test_extended_coverage is function get_block_coverage_line return clob is begin - return - case - when ut3_tester_helper.coverage_helper.block_coverage_available then - '%' - else - '%' - end; + return '%'; end; procedure coverage_for_object is l_expected clob; @@ -130,8 +124,7 @@ create or replace package body test_extended_coverage is ); --Assert - --The below is a workaround for problem with large CLOB like comparison on 11g XE db. - ut.expect(to_char(substr(l_actual,instr(l_actual,''),2000))).to_be_like(l_expected); + ut.expect(l_actual).to_be_like(l_expected); ut.expect(l_actual).not_to_be_like(l_not_expected); ut.expect(l_actual).not_to_be_like('%ut3_tester_helper.test_regex_dummy_cov%'); end; diff --git a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb index 2f2200116..883909eb5 100644 --- a/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_html_coverage_reporter.pkb @@ -9,9 +9,7 @@ create or replace package body test_html_coverage_reporter is begin --Arrange l_name := ut3_tester_helper.coverage_helper.covered_package_name; - if ut3_tester_helper.coverage_helper.block_coverage_available then - l_block_cov := '(including 1 lines partially covered ) '; - end if; + l_block_cov := '(including 1 lines partially covered ) '; l_expected := '%%

UT3_DEVELOP.'||upper(l_name)||'

' || '%2 relevant lines. 1 lines covered ' || l_block_cov || 'and 1 lines missed%'; @@ -32,6 +30,26 @@ create or replace package body test_html_coverage_reporter is ut.expect(l_actual).to_be_like(l_expected); end; + procedure report_support_link is + l_actual clob; + begin + l_actual := + ut3_tester_helper.coverage_helper.run_tests_as_job( + q'[ + ut3_develop.ut.run( + a_path => 'ut3_develop.test_dummy_coverage', + a_reporter=> ut3_develop.ut_coverage_html_reporter() + ) + ]' + ); + + ut.expect(l_actual).to_be_like( + '%