Skip to content

Commit 46152fa

Browse files
committed
Fix #66; also line ending issues on docker
- #66: Fixed errors when a Language = python method has a name starting with "%" - coverage.list files with Windows-style line endings are now parsed properly in Linux containers
1 parent 114426e commit 46152fa

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [4.0.6]
8+
## [4.0.7] - 2025-09-23
9+
10+
### Fixed
11+
- #66: No longer errors when a `[ Language = python ]` method has a name starting with "%"
12+
- coverage.list files with Windows-style line endings are now parsed properly in Linux containers
13+
14+
## [4.0.6] - 2025-08-13
915

1016
### Fixed
1117
- #63: TestCoverage.Manager On/After methods now call superclass so improvements to %UnitTest.Manager like AutoUserNames will work properly

cls/TestCoverage/Data/CodeUnit.cls

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ Method UpdateSourceMap(pSourceNamespace As %String, ByRef pCache) As %Status
401401
// for each method in the .py file, we'll find the line number of the corresponding method (guaranteed to be unique) in the .cls file
402402
// and then map each line in the .py file to each line in the .cls file by just going 1 by 1 down the lines
403403
Set tCLSMethodNum = pCLSCodeUnit.MethodMap.GetAt(tMethod)
404+
If (tCLSMethodNum = "") {
405+
// %Foo() becomes _Foo() in the Python code unit.
406+
Set tCLSMethodNum = pCLSCodeUnit.MethodMap.GetAt($Replace(tMethod,"_","%"))
407+
}
404408
Set tMethodStart = ..MethodMap.GetAt(tMethod)
405409
Set tMethodEnd = ..MethodEndMap.GetAt(tMethod)
406410
Set tMethodName = tMethod
@@ -571,7 +575,12 @@ Method UpdateComplexity() As %Status
571575
Quit
572576
}
573577
If (tSubUnit.IsPythonMethod) {
574-
set tSubUnit.Complexity = tMethodComplexities."__getitem__"(tSubUnit.Name)
578+
for name = tSubUnit.Name,$Replace(tSubUnit.Name,"%","_") {
579+
if tMethodComplexities."__contains__"(name) {
580+
set tSubUnit.Complexity = tMethodComplexities."__getitem__"(name)
581+
quit
582+
}
583+
}
575584
$$$ThrowOnError(tSubUnit.%Save(0))
576585
} Else {
577586
$$$ThrowOnError(tSubUnit.UpdateComplexity())

cls/TestCoverage/Manager.cls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,14 @@ ClassMethod GetCoverageTargetsForFile(pFileName As %String, Output pTargetArray)
425425

426426
Set tFileStream = ##class(%Stream.FileCharacter).%New()
427427
Do tFileStream.LinkToFile(pFileName)
428+
Set tFileStream.LineTerminator = $c(10)
428429
While 'tFileStream.AtEnd {
429430
Set tFileLines($Increment(tFileLines)) = tFileStream.ReadLine()
430431
}
431432

432433
For tLineIndex=1:1:$Get(tFileLines) {
433434
Set tLine = tFileLines(tLineIndex)
434-
Set tLine = $zstrip(tLine, "<>W")
435+
Set tLine = $zstrip(tLine, "<>WC")
435436
// Skip blank lines
436437
If (tLine = "") {
437438
Continue

internal/testing/unit_tests/UnitTest/TestCoverage/Unit/TestComplexity.cls

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,13 @@ ClassMethod ForLoopPython() [ Language = python ]
254254
return 1
255255
}
256256

257+
/// Complexity: 3 (1 + for + if)
258+
ClassMethod %ForLoopPython() [ Language = python ]
259+
{
260+
for i in range(5):
261+
if i > 4:
262+
continue
263+
return 1
264+
}
265+
257266
}

module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Export generator="Cache" version="25">
33
<Document name="TestCoverage.ZPM"><Module>
44
<Name>TestCoverage</Name>
5-
<Version>4.0.6</Version>
5+
<Version>4.0.7</Version>
66
<Description>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.</Description>
77
<Packaging>module</Packaging>
88
<Resource Name="TestCoverage.PKG" Directory="cls" />

0 commit comments

Comments
 (0)