Skip to content

Commit 58f1059

Browse files
committed
Merge branch 'master' of https://github.com/intersystems/TestCoverage into EmbeddedPython Adding changes from release 3.1.0
2 parents d6b81ca + f13bdf4 commit 58f1059

File tree

4 files changed

+52
-31
lines changed

4 files changed

+52
-31
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
1-
name: Export XML and Release on Tag Push
1+
name: Release
22

33
on:
44
push:
55
tags:
6-
- '*'
6+
- 'v[0-9]+.[0-9]+.[0-9]+' # force semantic versioning
77

88
jobs:
9-
build:
9+
build-and-release:
1010
runs-on: ubuntu-latest
1111

1212
env:
13-
# ** FOR GENERAL USE, LIKELY NEED TO CHANGE: **
14-
package: TestCoverage
1513
container_image: intersystemsdc/iris-community:latest
16-
17-
# ** FOR GENERAL USE, MAY NEED TO CHANGE: **
18-
build_flags: -dev -verbose # Load in -dev mode to get unit test code preloaded
19-
test_package: UnitTest
20-
21-
# ** FOR GENERAL USE, SHOULD NOT NEED TO CHANGE: **
2214
instance: iris
23-
# Note: test_reports value is duplicated in test_flags environment variable
2415
test_reports: test-reports
25-
test_flags: >-
26-
-verbose -DUnitTest.ManagerClass=TestCoverage.Manager -DUnitTest.JUnitOutput=/test-reports/junit.xml
27-
-DUnitTest.FailuresAreFatal=1 -DUnitTest.Manager=TestCoverage.Manager
28-
-DUnitTest.UserParam.CoverageReportClass=TestCoverage.Report.Cobertura.ReportGenerator
29-
-DUnitTest.UserParam.CoverageReportFile=/source/coverage.xml
3016

3117
steps:
3218
- name: Checkout code
@@ -51,16 +37,12 @@ jobs:
5137
# Workaround for permissions issues in TestCoverage (creating directory for source export)
5238
chmod 777 $GITHUB_WORKSPACE
5339
54-
- name: Get latest tag
55-
id: tag
56-
uses: actions-ecosystem/action-get-latest-tag@v1
57-
5840
- name: Export XML
5941
run: |
6042
# Pick the targets to export as XML
6143
echo 'set list("TestCoverage.*.cls") = ""' >> export
6244
echo 'set list("TestCoverage.inc") = ""' >> export
63-
echo 'do $System.OBJ.Export(.list,"/source/TestCoverage-${{ steps.tag.outputs.tag }}.xml","/exportversion=2017.2")' >> export
45+
echo 'do $System.OBJ.Export(.list,"/source/TestCoverage-${{ github.ref_name }}.xml","/exportversion=2017.2")' >> export
6446
docker exec --interactive $instance iris session $instance -B < export
6547
6648
- name: Create Release
@@ -69,9 +51,9 @@ jobs:
6951
env:
7052
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7153
with:
72-
files: TestCoverage-${{ steps.tag.outputs.tag }}.xml
73-
tag_name: ${{ github.ref }}
74-
name: ${{ steps.tag.outputs.tag }}
54+
files: TestCoverage-${{ github.ref_name }}.xml
55+
tag_name: ${{ github.ref_name }}
56+
name: ${{ github.ref_name }}
7557
body: |
7658
Automated release created by [action-gh-release](https://github.com/softprops/action-gh-release).
7759
draft: false

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ 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-
## [3.1.0] - 2024-01-17
8+
## [3.1.0] - 2024-07-05
99

10-
### Changed
10+
### Added
1111
- #23: Allow CoverageClasses and CoverageRoutines to be specified as %DynamicArray in addition to $ListBuild() lists.
12+
- #14: Added a straightforward way to find and track coverage on all interoperability processes in the current namespace
1213

1314
### Fixed
1415
- #24: Whenever a new tag is created, a new release will be published using the tag string as its version. The release also comes with an export of the TestCoverage package in XML.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Where:
101101
* `tCoverageLevel` (optional) is 0 to track code coverage overall; 1 to track it per test suite (the default); 2 to track it per test class; 3 to track it per test method.
102102
* `tLogIndex` (optional) allows for aggregation of code coverage results across unit test runs. To use this, get it back as output from the first test run, then pass it to the next.
103103
* `tSourceNamespace` (optional) specifies the namespace in which classes were compiled, defaulting to the current namespace. This may be required to retrieve some metadata.
104-
* `tPIDList` (optional) has a $ListBuild list of process IDs to monitor. If this is empty, all processes are monitored. By default, only the current process is monitored.
104+
* `tPIDList` (optional) has a $ListBuild list of process IDs to monitor. If this is empty, all processes are monitored. If this is $ListBuild("Interop") or "Interoperability", all interoperability processes and the current process are monitored. By default, only the current process is monitored.
105105
* `tTiming` (optional) is 1 to capture execution time data for monitored classes/routines as well, or 0 (the default) to not capture this data.
106106

107107
### Viewing Results

cls/TestCoverage/Manager.cls

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ Property SourceNamespace As %String(MAXLEN = 255) [ Internal, Private ];
5757

5858
Property ProcessIDs As %List [ Internal, Private ];
5959

60+
/// 0 means don't bother with interoperability processes, 1 means track interoperability processes
61+
Property InteroperabilityProcesses As %Integer [ InitialExpression = 0, Internal, Private ];
62+
6063
Property Run As TestCoverage.Data.Run;
6164

6265
/// Known coverage targets (already snapshotted). <br />
@@ -80,7 +83,7 @@ Property Monitor As TestCoverage.Utils.LineByLineMonitor [ InitialExpression = {
8083
/// Note that overall tracking is always available; more granular tracking requires more time and disk space.</li>
8184
/// <li><var>pLogIndex</var> (optional) allows for aggregation of code coverage results across unit test runs. To use this, get it back as output from the first test run, then pass it to the next.</li>
8285
/// <li><var>pSourceNamespace</var> (optional) specifies the namespace in which classes were compiled, defaulting to the current namespace. This may be required to retrieve some metadata.</li>
83-
/// <li><var>pPIDList</var> (optional) has a $ListBuild list of process IDs to monitor. If this is empty, all processes are monitored. By default, this is just the current process.</li>
86+
/// <li><var>pPIDList</var> (optional) has a $ListBuild list of process IDs to monitor. If this is empty, all processes are monitored. If this is $listbuild("Interop") or "Interoperability", the current process and all interoperability processes are monitored. By default, this is just the current process.</li>
8487
/// <li><var>pTiming</var> (optional) may be set to 1 to also collect timing information per line.</li>
8588
/// </ul>
8689
/// Granular data is stored in <class>TestCoverage.Data.Coverage</class>; aggregated data is stored per class in <class>TestCoverage.Data.Aggregate.ByCodeUnit</class> and for the whole run in <class>TestCoverage.Data.Aggregate.ByRun</class>.
@@ -195,14 +198,39 @@ Method CoverageTargetsSet(%value) As %Status [ Internal, Private ]
195198
Quit $$$OK
196199
}
197200

201+
/// Collect the list of PIDs used by Interoperability processes in the current namespace
202+
/// In order to run unit tests collecting coverage in that specific list of processes (plus the current process)
203+
Method GetInteropProcesses(Output tProcessIDs)
204+
{
205+
&sql(select %DLIST(Process) into :tProcessIDs from %SYS.ProcessQuery_SS() where "User" = '_Ensemble' and Namespace = $Namespace)
206+
If (SQLCODE < 0) {
207+
Throw ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE,%msg)
208+
}
209+
if ('$LISTFIND(tProcessIDs, $Job)) {
210+
set tProcessIDs = tProcessIDs _ $ListBuild($Job)
211+
}
212+
}
213+
214+
/// Overriden LogAssert method because we want to be able to hook into the StartProduction() call in subclasses of %UnitTest.TestProduction
215+
/// in order to get the interoperability process list after the production has started
216+
Method LogAssert(success, action, description, extra, args...)
217+
{
218+
do ##super(.success, .action, .description, .extra, args...)
219+
if (..InteroperabilityProcesses && (description = "StartProduction()")) {
220+
do ..GetInteropProcesses(.tProcessIDs)
221+
set ..ProcessIDs = tProcessIDs
222+
$$$ThrowOnError(..EndCoverageTracking())
223+
$$$ThrowOnError(..StartCoverageTracking())
224+
}
225+
}
226+
198227
Method StartCoverageTracking() As %Status [ Private ]
199228
{
200229
Set tSC = $$$OK
201230
New $Namespace
202231
Try {
203232
If (..CoverageTargets '= "") {
204233
Set $Namespace = ..SourceNamespace
205-
206234
Set tRelevantTargets = ""
207235
Set tPyRelevantTargets = ""
208236
Set tNewTargets = ""
@@ -275,6 +303,10 @@ Method StartCoverageTracking() As %Status [ Private ]
275303
}
276304
}
277305
}
306+
ElseIf (..InteroperabilityProcesses)
307+
{
308+
do ..GetInteropProcesses(.tProcessIDs)
309+
}
278310
Set tMetrics = $ListBuild("RtnLine") _ $Select(..Timing:$ListBuild("Time","TotalTime"),1:"")
279311
$$$ThrowOnError(..Monitor.StartWithScope(tRelevantTargets, tPyRelevantTargets, tMetrics,tProcessIDs))
280312
}
@@ -585,8 +617,14 @@ ClassMethod OnBeforeAllTests(manager As TestCoverage.Manager, dir As %String, By
585617
Set tProcessIDs = $Get(userparam("ProcessIDs"),$ListBuild($Job))
586618
If (tProcessIDs = "*") {
587619
Set tProcessIDs = ""
588-
} ElseIf (tProcessIDs = "") || '$ListValid(tProcessIDs) {
620+
} ElseIf ((tProcessIDs = "Interoperability") || (tProcessIDs = "interoperability")) {
621+
Set manager.InteroperabilityProcesses = 1
622+
Set tProcessIDs = $lb("Interop")
623+
}
624+
ElseIf (tProcessIDs = "") || '$ListValid(tProcessIDs) {
589625
Set tProcessIDs = $ListBuild($Job)
626+
} ElseIf (($list(tProcessIDs, 1)="Interop") || ($list(tProcessIDs, 1)="interop") ) {
627+
Set manager.InteroperabilityProcesses = 1
590628
}
591629
Set tTiming = $Get(userparam("Timing"),0)
592630
Set tSubject = $Get(userparam("Subject"))

0 commit comments

Comments
 (0)