Skip to content

Commit 17d4294

Browse files
authored
Merge pull request #72 from intersystems/fix-64
Add wildcard support for CLS in coverage list
2 parents c4ddca2 + 3a5de0f commit 17d4294

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ 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.8] - Unreleased
8+
## [4.1.0] - Unreleased
9+
10+
### Added
11+
- #64: Wildcard support for CLS files in coverage lists
912

1013
### Fixed
1114
- #70: Performance regression on newer IRIS versions when table stats are missing on a clean instance/run

cls/TestCoverage/Manager.cls

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,10 @@ 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+
// *.CLS is "all classes in the current namespace's default routine database"
472+
// Will ignore system classes unless run in %SYS namespace or "%" is included in the expression
473+
Do ..SearchClasses(tLine,.tNames)
472474
} Else {
473475
Set tNames(tName) = ""
474476
}
@@ -506,6 +508,23 @@ ClassMethod SearchRoutines(pSearchExpr As %String, Output pRoutines) [ Private ]
506508
} While 'tAtEnd
507509
}
508510

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