From 68a0e76883fb4f35db64c87eee39df11ecf1a238 Mon Sep 17 00:00:00 2001 From: Chris Ge Date: Fri, 9 Aug 2024 09:34:22 -0400 Subject: [PATCH 1/4] fix: ignores coverage for line 0 of Python file, which 2024.2 Python shows as covered --- cls/TestCoverage/Utils/LineByLineMonitor.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cls/TestCoverage/Utils/LineByLineMonitor.cls b/cls/TestCoverage/Utils/LineByLineMonitor.cls index fe929d9..858ad7e 100644 --- a/cls/TestCoverage/Utils/LineByLineMonitor.cls +++ b/cls/TestCoverage/Utils/LineByLineMonitor.cls @@ -68,7 +68,7 @@ ClassMethod PyStartWithScope(pCoverageClasses As %List) [ Language = python ] class_name = frame.f_globals['__name__'] # extracts the line number line_no = frame.f_lineno - if class_name in tCoverageClasses and line_no != 1: # if this is in a covered class + if class_name in tCoverageClasses and line_no > 1: # if this is in a covered class tGlob = iris.gref('^IRIS.Temp.TestCoveragePY') # python doesn't have macros -- this is $$$PyMonitorResults # $$$PyMonitorResults(classname, linenumber) = the number of times that linenumber in that class was covered From ed7fa7e4dc90e6509062cba6886d51d936e24038 Mon Sep 17 00:00:00 2001 From: Chris Ge Date: Fri, 9 Aug 2024 09:35:45 -0400 Subject: [PATCH 2/4] docs: changelog and module.xml version --- CHANGELOG.md | 4 ++++ module.xml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4493296..ada8ab5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ 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.1] - 2024-08-09 + +- #43: Fixed Python line 0 tracking for 2024.2 + ## [4.0.0] - 2024-08-01 ### Changed diff --git a/module.xml b/module.xml index 0d230e1..5540c9e 100644 --- a/module.xml +++ b/module.xml @@ -2,7 +2,7 @@ TestCoverage - 4.0.0 + 4.0.1 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 41a313b3fbc714b2f4490532e805320a16e18066 Mon Sep 17 00:00:00 2001 From: Chris Ge Date: Fri, 9 Aug 2024 09:37:45 -0400 Subject: [PATCH 3/4] docs: corrected pull request number --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ada8ab5..b2f5c7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [4.0.1] - 2024-08-09 -- #43: Fixed Python line 0 tracking for 2024.2 +- #45: Fixed Python line 0 tracking for 2024.2 ## [4.0.0] - 2024-08-01 From f8fd42e8fb734584807a53d342df59ce8af4b81e Mon Sep 17 00:00:00 2001 From: Chris Ge Date: Tue, 13 Aug 2024 16:37:33 -0400 Subject: [PATCH 4/4] fix: UpdateComplexity and one of the calls in GetCurrentByName no longer use GetCurrentByName just for getting the hash and code of a CodeUnit --- cls/TestCoverage/Data/CodeUnit.cls | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cls/TestCoverage/Data/CodeUnit.cls b/cls/TestCoverage/Data/CodeUnit.cls index 0ac96c3..09781d7 100644 --- a/cls/TestCoverage/Data/CodeUnit.cls +++ b/cls/TestCoverage/Data/CodeUnit.cls @@ -82,9 +82,9 @@ ClassMethod GetCurrentByName(pInternalName As %String, pSourceNamespace As %Stri $$$ThrowOnError(tSC) Set tKnownHash = tMapToResult.%GetData(1) Set tMapToUnit = ..HashOpen(tKnownHash,,.tSC) - $$$ThrowOnError(tSC) - $$$ThrowOnError(..GetCurrentByName(tMapToUnit.Name_"."_tMapToUnit.Type,pSourceNamespace,.tUpdatedUnit,.pCache)) - If (tUpdatedUnit.Hash '= tKnownHash) { + $$$ThrowOnError(tSC) + do ..GetCurrentHash(tMapToUnit.Name, tMapToUnit.Type, .tUpdatedHash, , ) + If (tUpdatedHash '= tKnownHash) { //Clear out old data and flag the need for an update. Set tNeedsUpdate = 1 &sql(delete from TestCoverage_Data.CodeUnitMap where ToHash = :tKnownHash) @@ -247,7 +247,6 @@ ClassMethod GetCurrentByName(pInternalName As %String, pSourceNamespace As %Stri /// Fill in the LineIsPython property of .cls files Method UpdatePythonLines(pName As %String, ByRef pPyCodeUnit) As %Status { - Set tSC = $$$OK Set tOriginalNamespace = $Namespace Set tInitTLevel = $TLevel @@ -543,8 +542,9 @@ Method UpdateComplexity() As %Status // python methods If (##class(TestCoverage.Manager).HasPython(..Name)) { - do ##class(TestCoverage.Data.CodeUnit).GetCurrentByName(..Name _ ".PY", , .pPyCodeUnit, ) // need the source code for the python - set tDocumentText = pPyCodeUnit.Lines.Serialize() + do ..GetCurrentHash(..Name, "PY", ,.tPyCodeArray, ) // need the source code for the python to pass into the method complexity calculator + do ##class(TestCoverage.Utils).CodeArrayToList(.tPyCodeArray, .tDocumentText) + set tDocumentText = tDocumentText _ $listbuild("") set tMethodComplexities = ..GetPythonComplexities(tDocumentText) }