Skip to content

Commit 0c2ff29

Browse files
authored
Merge pull request intersystems#30 from isc-shuliu/master
Fix intersystems#23 and intersystems#24
2 parents 9c2c65a + ea1a5f5 commit 0c2ff29

File tree

5 files changed

+103
-7
lines changed

5 files changed

+103
-7
lines changed

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Export XML and Release on Tag Push
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
env:
13+
# ** FOR GENERAL USE, LIKELY NEED TO CHANGE: **
14+
package: TestCoverage
15+
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: **
22+
instance: iris
23+
# Note: test_reports value is duplicated in test_flags environment variable
24+
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
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
35+
- name: Run Container
36+
run: |
37+
# Create test_reports directory to share test results before running container
38+
mkdir $test_reports
39+
chmod 777 $test_reports
40+
# Run InterSystems IRIS instance
41+
docker pull $container_image
42+
docker run -d -h $instance --name $instance -v $GITHUB_WORKSPACE:/source -v $GITHUB_WORKSPACE/$test_reports:/$test_reports --init $container_image
43+
echo halt > wait
44+
# Wait for instance to be ready
45+
until docker exec --interactive $instance iris session $instance < wait; do sleep 1; done
46+
47+
- name: Install TestCoverage
48+
run: |
49+
echo "zpm \"install testcoverage\":1:1" > install-testcoverage
50+
docker exec --interactive $instance iris session $instance -B < install-testcoverage
51+
# Workaround for permissions issues in TestCoverage (creating directory for source export)
52+
chmod 777 $GITHUB_WORKSPACE
53+
54+
- name: Get latest tag
55+
id: tag
56+
uses: actions-ecosystem/action-get-latest-tag@v1
57+
58+
- name: Export XML
59+
run: |
60+
# Pick the targets to export as XML
61+
echo 'set list("TestCoverage.*.cls") = ""' >> export
62+
echo 'set list("TestCoverage.inc") = ""' >> export
63+
echo 'do $System.OBJ.Export(.list,"/source/TestCoverage-${{ steps.tag.outputs.tag }}.xml","/exportversion=2017.2")' >> export
64+
docker exec --interactive $instance iris session $instance -B < export
65+
66+
- name: Create Release
67+
id: create_release
68+
uses: softprops/action-gh-release@v1
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
with:
72+
files: TestCoverage-${{ steps.tag.outputs.tag }}.xml
73+
tag_name: ${{ github.ref }}
74+
name: ${{ steps.tag.outputs.tag }}
75+
body: |
76+
Automated release created by [action-gh-release](https://github.com/softprops/action-gh-release).
77+
draft: false
78+
prerelease: false

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ 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
9+
10+
### Changed
11+
- #23: Allow CoverageClasses and CoverageRoutines to be specified as %DynamicArray in addition to $ListBuild() lists.
12+
13+
### Fixed
14+
- #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.
15+
816
## [3.0.0] - 2023-12-01
917

1018
### Changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ Generally speaking, set `^UnitTestRoot`, and then call `##class(TestCoverage.Man
6767
The "userparam" argument can be used to pass information about code coverage data collection. For example:
6868

6969
```
70-
Set tCoverageParams("CoverageClasses") = <$ListBuild list of class names for which code coverage data should be collected>
71-
Set tCoverageParams("CoverageRoutines") = <$ListBuild list of routine names for which code coverage data should be collected>
70+
Set tCoverageParams("CoverageClasses") = <$ListBuild list or %DynamicArray of class names for which code coverage data should be collected>
71+
Set tCoverageParams("CoverageRoutines") = <$ListBuild list or %DynamicArray of routine names for which code coverage data should be collected>
7272
Set tCoverageParams("CoverageDetail") = <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.>
7373
Do ##class(TestCoverage.Manager).RunTest(,,.tCoverageParams)
7474
```

cls/TestCoverage/Manager.cls

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ Property Monitor As TestCoverage.Utils.LineByLineMonitor [ InitialExpression = {
6767
/// <ul>
6868
/// <li><var>pPackage</var> has the top-level package containing all the unit test classes to run. These must already be loaded.</li>
6969
/// <li><var>pLogFile</var> (optional) may specify a file to log all output to.</li>
70-
/// <li><var>pCoverageClasses</var> (optional) has a $ListBuild list of class names within which to track code coverage. By default, none are tracked.</li>
71-
/// <li><var>pCoverageRoutines</var> (optional) has a $ListBuild list of routine names within which to track code coverage. By default, none are tracked.</li>
70+
/// <li><var>pCoverageClasses</var> (optional) has a $ListBuild list or %DynamicArray of class names within which to track code coverage. By default, none are tracked.</li>
71+
/// <li><var>pCoverageRoutines</var> (optional) has a $ListBuild list or %DynamicArray of routine names within which to track code coverage. By default, none are tracked.</li>
7272
/// <li><var>pCoverageLevel</var> (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.
7373
/// Note that overall tracking is always available; more granular tracking requires more time and disk space.</li>
7474
/// <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>
@@ -94,8 +94,8 @@ ClassMethod RunAllTests(pPackage As %String = "", pLogFile As %String = "", pCov
9494
Set tTestSuite = $Replace(pPackage,"/",".")
9595
Set tSpec = "/noload/nodelete"
9696
Merge tCoverageParams("LogIndex") = pLogIndex // Set only if defined.
97-
Set tCoverageParams("CoverageClasses") = pCoverageClasses
98-
Set tCoverageParams("CoverageRoutines") = pCoverageRoutines
97+
Set tCoverageParams("CoverageClasses") = $SELECT($CLASSNAME(pCoverageClasses) = "%Library.DynamicArray":..ArrayToList(pCoverageClasses), 1:pCoverageClasses)
98+
Set tCoverageParams("CoverageRoutines") = $SELECT($CLASSNAME(pCoverageRoutines) = "%Library.DynamicArray":..ArrayToList(pCoverageRoutines), 1:pCoverageRoutines)
9999
Set tCoverageParams("CoverageDetail") = pCoverageLevel
100100
Set tCoverageParams("SourceNamespace") = pSourceNamespace
101101
Set tCoverageParams("ProcessIDs") = pPIDList
@@ -129,6 +129,16 @@ ClassMethod RunAllTests(pPackage As %String = "", pLogFile As %String = "", pCov
129129
Quit $Select(tSuccess:1,1:$$$ERROR($$$GeneralError,"One or more errors occurred in unit tests."))
130130
}
131131

132+
ClassMethod ArrayToList(pDynamicArray As %DynamicArray) As %List
133+
{
134+
Set tList = ""
135+
Set tIter = pDynamicArray.%GetIterator()
136+
While tIter.GetNext(, .value) {
137+
Set tList = tList _ $LISTBUILD(value)
138+
}
139+
Quit tList
140+
}
141+
132142
Method SetCoverageTargets(pClasses As %List = "", pRoutines As %List = "", pInit As %Boolean = 0) [ Private ]
133143
{
134144
Set tList = "", tPtr = 0

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>3.0.0</Version>
5+
<Version>3.1.0</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)