Skip to content

Commit 6b35863

Browse files
committed
Add wildcard support for CLS in coverage list
1 parent c4ddca2 commit 6b35863

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [4.0.8] - Unreleased
99

10+
### Added
11+
- #64: Wildcard support for CLS files in coverage lists
12+
1013
### Fixed
1114
- #70: Performance regression on newer IRIS versions when table stats are missing on a clean instance/run
1215

cls/TestCoverage/Manager.cls

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,11 @@ ClassMethod GetCoverageTargetsForFile(pFileName As %String, Output pTargetArray)
467467
$$$ThrowOnError(tSC)
468468
Set tExtension = "CLS"
469469
} ElseIf (tExtension = "CLS") {
470-
If (tName = "*") {
471-
// TODO: support special case of *.CLS
470+
If (tName [ "*") {
471+
w !, "*CLS",!
472+
// *.CLS is "all classes in the current namespace's default routine database"
473+
// Will ignore system classes unless run in %SYS namespace or "%" is included in the expression
474+
Do ..SearchClasses(tLine,.tNames)
472475
} Else {
473476
Set tNames(tName) = ""
474477
}
@@ -506,6 +509,23 @@ ClassMethod SearchRoutines(pSearchExpr As %String, Output pRoutines) [ Private ]
506509
} While 'tAtEnd
507510
}
508511

512+
/// Returns the classes in this namespace that satisfy the pSearchExpr
513+
/// Will not return system classes unless run in %SYS or pSearchExpr contains "%" prefix
514+
ClassMethod SearchClasses(pSearchExpr As %String, Output pClasses)
515+
{
516+
set statement = "SELECT Name FROM %Library.RoutineMgr_StudioOpenDialog(?,1,1,0,1,0,0)"
517+
518+
#dim result As %SQL.StatementResult
519+
Set result = ##class(%SQL.Statement).%ExecDirect(,statement, pSearchExpr)
520+
If (result.%SQLCODE < 0) {
521+
Throw ##class(%Exception.SQL).CreateFromSQLCODE(result.%SQLCODE,result.%Message)
522+
}
523+
While result.%Next(.tSC) {
524+
$$$ThrowOnError(tSC)
525+
set pClasses($Piece(result.%Get("Name"),".",1,*-1)) = ""
526+
}
527+
}
528+
509529
Method GetObjectCodeForSourceNames(pSourceNameList As %List) As %List [ Private ]
510530
{
511531
New $Namespace

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,25 @@ Method TestAutoUserNames()
1515
Do $$$AssertNotTrue(##class(Security.Users).Exists("TestD"))
1616
}
1717

18+
Method TestSearchClasses()
19+
{
20+
set expr = "TestCoverage.DataType.*"
21+
do ##class(TestCoverage.Manager).SearchClasses(expr, .classes)
22+
23+
do $$$AssertTrue($data(classes("TestCoverage.DataType.Bitstring")))
24+
do $$$AssertTrue($data(classes("TestCoverage.DataType.Detail")))
25+
do $$$AssertTrue($data(classes("TestCoverage.DataType.Metric")))
26+
do $$$AssertTrue($data(classes("TestCoverage.DataType.RoutineType")))
27+
do $$$AssertTrue($data(classes("TestCoverage.DataType.Timing")))
28+
29+
set count = 0
30+
set node = ""
31+
for {
32+
set node = $Order(classes(node))
33+
quit:node=""
34+
set count = count + 1
35+
}
36+
do $$$AssertEquals(count, 5)
37+
}
38+
1839
}

0 commit comments

Comments
 (0)