From bf98cfe2af8276799af0d348afd503b6f355089c Mon Sep 17 00:00:00 2001 From: isc-tleavitt <73311181+isc-tleavitt@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:17:00 -0400 Subject: [PATCH 1/4] fix: defensive coding in ListToBit --- CHANGELOG.md | 5 +++++ cls/TestCoverage/Procedures.cls | 4 +++- .../UnitTest/TestCoverage/Unit/Procedures.cls | 13 +++++++++++++ module.xml | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 internal/testing/unit_tests/UnitTest/TestCoverage/Unit/Procedures.cls diff --git a/CHANGELOG.md b/CHANGELOG.md index c534552..fffca3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.0.4] - Unreleased + +### Fixed +- #54: Defend against possible configuration-dependent possible SQL exceptions in mapping INT to MAC/CLS coverage + ## [4.0.3] - 2024-08-19 ### Fixed diff --git a/cls/TestCoverage/Procedures.cls b/cls/TestCoverage/Procedures.cls index 85542f3..030b2c5 100644 --- a/cls/TestCoverage/Procedures.cls +++ b/cls/TestCoverage/Procedures.cls @@ -82,7 +82,9 @@ ClassMethod ListToBit(pSource As %List) As %Binary [ SqlName = LIST_TO_BIT, SqlP Set tResult = "" Set tPointer = 0 While $ListNext(pSource,tPointer,tBitPosition) { - Set $Bit(tResult,tBitPosition) = 1 + If $Data(tBitPosition)#2 && (tBitPosition '= "") { + Set $Bit(tResult,tBitPosition) = 1 + } } Quit tResult } diff --git a/internal/testing/unit_tests/UnitTest/TestCoverage/Unit/Procedures.cls b/internal/testing/unit_tests/UnitTest/TestCoverage/Unit/Procedures.cls new file mode 100644 index 0000000..a001405 --- /dev/null +++ b/internal/testing/unit_tests/UnitTest/TestCoverage/Unit/Procedures.cls @@ -0,0 +1,13 @@ +Class UnitTest.TestCoverage.Unit.Procedures Extends %UnitTest.TestCase +{ + +Method TestListToBit() +{ + Set compare = "" + For i=1:1:3 { + Set $Bit(compare,i) = 1 + } + Do $$$AssertEquals(##class(TestCoverage.Procedures).ListToBit($lb(1,2,3,,"")),compare) +} + +} \ No newline at end of file diff --git a/module.xml b/module.xml index 4cf105b..5e6d731 100644 --- a/module.xml +++ b/module.xml @@ -2,7 +2,7 @@ TestCoverage - 4.0.3 + 4.0.4 Run your typical ObjectScript %UnitTest tests and see which lines of your code are executed. Includes Cobertura-style reporting for use in continuous integration tools. module From cae91317d19981fab5233b0afd4f4a0cf7f53abf Mon Sep 17 00:00:00 2001 From: isc-tleavitt <73311181+isc-tleavitt@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:18:02 -0400 Subject: [PATCH 2/4] chore: changelog wording --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fffca3f..dd6a4c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [4.0.4] - Unreleased ### Fixed -- #54: Defend against possible configuration-dependent possible SQL exceptions in mapping INT to MAC/CLS coverage +- #54: Defend against possible configuration-dependent SQL exceptions in mapping INT to MAC/CLS coverage ## [4.0.3] - 2024-08-19 From 0f6af11476f45faeaac77e14cb7414ba3ec0386b Mon Sep 17 00:00:00 2001 From: isc-tleavitt <73311181+isc-tleavitt@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:39:20 -0400 Subject: [PATCH 3/4] fix: more defensive coding Don't try to put 0 in a bitstring --- cls/TestCoverage/Procedures.cls | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cls/TestCoverage/Procedures.cls b/cls/TestCoverage/Procedures.cls index 030b2c5..b05c2ba 100644 --- a/cls/TestCoverage/Procedures.cls +++ b/cls/TestCoverage/Procedures.cls @@ -82,8 +82,8 @@ ClassMethod ListToBit(pSource As %List) As %Binary [ SqlName = LIST_TO_BIT, SqlP Set tResult = "" Set tPointer = 0 While $ListNext(pSource,tPointer,tBitPosition) { - If $Data(tBitPosition)#2 && (tBitPosition '= "") { - Set $Bit(tResult,tBitPosition) = 1 + If $Data(tBitPosition)#2 && (+tBitPosition > 0) { + Set $Bit(tResult,+tBitPosition) = 1 } } Quit tResult From a157b9198729a97c400c4e3f1b434f7379fa1c76 Mon Sep 17 00:00:00 2001 From: isc-tleavitt <73311181+isc-tleavitt@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:40:26 -0400 Subject: [PATCH 4/4] chore: update actions/upload-artifact to v4 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 77160ac..832f278 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -77,7 +77,7 @@ jobs: # all tests passed. fail: false - name: Attach the report - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 if: always() with: name: ${{ steps.xunit-viewer.outputs.report-name }}