Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 455da79

Browse files
committed
Added PDF report option
1 parent bef8d55 commit 455da79

File tree

6 files changed

+33
-10
lines changed

6 files changed

+33
-10
lines changed

src/main/java/com/mathworks/ci/MatlabBuilder.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ public static class RunTestsAutomaticallyOption extends TestRunTypeList {
345345
private boolean taCoberturaChkBx;
346346
private boolean taSTMResultsChkBx;
347347
private boolean taModelCoverageChkBx;
348+
private boolean taPDFReportChkBx;
348349

349350
@DataBoundConstructor
350351
public RunTestsAutomaticallyOption() {
@@ -376,6 +377,11 @@ public void setTaModelCoverageChkBx(boolean taModelCoverageChkBx) {
376377
this.taModelCoverageChkBx = taModelCoverageChkBx;
377378
}
378379

380+
@DataBoundSetter
381+
public void setTaPDFReportChkBx(boolean taPDFReportChkBx) {
382+
this.taPDFReportChkBx = taPDFReportChkBx;
383+
}
384+
379385
public boolean getTatapChkBx() {
380386
return tatapChkBx;
381387
}
@@ -396,6 +402,10 @@ public boolean getTaModelCoverageChkBx() {
396402
return taModelCoverageChkBx;
397403
}
398404

405+
public boolean getTaPDFReportChkBx() {
406+
return taPDFReportChkBx;
407+
}
408+
399409
@Extension
400410
public static final class DescriptorImpl extends TestRunTypeDescriptor {
401411
@Override
@@ -417,6 +427,8 @@ public boolean getBooleanByName(String memberName) {
417427
return this.getTaSTMResultsChkBx();
418428
case "taModelCoverageChkBx":
419429
return this.getTaModelCoverageChkBx();
430+
case "taPDFReportChkBx":
431+
return this.getTaPDFReportChkBx();
420432
default:
421433
return false;
422434
}
@@ -605,13 +617,14 @@ private String getNodeSpecificFileSeperator(Launcher launcher) {
605617

606618
// Concatenate the input arguments
607619
private String getInputArguments() {
620+
String pdfReport = MatlabBuilderConstants.PDF_REPORT + "," + getTestRunTypeList().getBooleanByName("taPDFReportChkBx");
608621
String tapResults = MatlabBuilderConstants.TAP_RESULTS + "," + getTestRunTypeList().getBooleanByName("tatapChkBx");
609622
String junitResults = MatlabBuilderConstants.JUNIT_RESULTS + "," + getTestRunTypeList().getBooleanByName("taJunitChkBx");
610623
String stmResults = MatlabBuilderConstants.STM_RESULTS + "," + getTestRunTypeList().getBooleanByName("taSTMResultsChkBx");
611624
String coberturaCodeCoverage = MatlabBuilderConstants.COBERTURA_CODE_COVERAGE + "," + getTestRunTypeList().getBooleanByName("taCoberturaChkBx");
612625
String coberturaModelCoverage = MatlabBuilderConstants.COBERTURA_MODEL_COVERAGE + "," + getTestRunTypeList().getBooleanByName("taModelCoverageChkBx");
613626

614-
String inputArgsToMatlabFcn = tapResults + "," + junitResults + ","
627+
String inputArgsToMatlabFcn = pdfReport + "," + tapResults + "," + junitResults + ","
615628
+ stmResults + "," + coberturaCodeCoverage + "," + coberturaModelCoverage;
616629

617630
return inputArgsToMatlabFcn;

src/main/java/com/mathworks/ci/MatlabBuilderConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class MatlabBuilderConstants {
1515
static final String AUTOMATIC_OPTION = "RunTestsAutomaticallyOption";
1616

1717
// Input parameter names (Passed to runMatlabTests.m as name-value pair arguments)
18+
static final String PDF_REPORT = "'PDFReport'";
1819
static final String TAP_RESULTS = "'TAPResults'";
1920
static final String JUNIT_RESULTS = "'JUnitResults'";
2021
static final String STM_RESULTS = "'SimulinkTestResults'";

src/main/resources/com/mathworks/ci/MatlabBuilder/RunTestsAutomaticallyOption/config.jelly

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
33

44
<f:section title="Generate Test Artifacts">
5+
<f:entry field="taPDFReportChkBx">
6+
<f:checkbox title="PDF test report " name="taPDFReportChkBx" checked="${instance.taPDFReportChkBx}"/>
7+
</f:entry>
8+
59
<f:entry field="tatapChkBx">
610
<f:checkbox title="TAP test results" name="tatapChkBx" checked="${instance.tatapChkBx}"/>
711
</f:entry>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<div>
22
<br>
33
Generate a test report in PDF format, <b>testreport.pdf</b>, and save it in the <b>matlabTestArtifacts</b> folder of the Jenkins workspace.
4-
<br>
5-
<br>
6-
Note: Due to Jenkins Content Security Policy rules, the generated report might not open properly from within the Jenkins workspace.
4+
<br><br>
5+
Due to Jenkins Content Security Policy rules, the generated report might not open properly from within the Jenkins workspace.
76
Consider copying the report to a location outside the workspace and opening it from there. For more information,
87
see <a href="http://wiki.jenkins.io/display/JENKINS/Configuring+Content+Security+Policy">Configuring Jenkins Content Security Policy</a>.
9-
<br>
8+
<br><br>
9+
<i><b>*This feature is not supported on Mac OS platform.</b></i>
1010
</div>

src/main/resources/com/mathworks/ci/MatlabBuilder/runMatlabTests.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
BASE_VERSION_COBERTURA_SUPPORT = '9.3';
7474

7575
if verLessThan('matlab',BASE_VERSION_COBERTURA_SUPPORT)
76-
warning('MATLAB:testArtifact:coberturaReportNotSupported', 'Producing Cobertura results is not supported in this release.');
76+
warning('MATLAB:testArtifact:coberturaReportNotSupported', 'Producing Cobertura code coverage results is not supported in this release.');
7777
else
7878
import('matlab.unittest.plugins.CodeCoveragePlugin');
7979
mkdirIfNeeded(resultsDir)
@@ -111,9 +111,12 @@
111111
end
112112
end
113113

114-
% Produce PDF test report (Not supported below R2016b)
114+
% Produce PDF test report (Not supported on MAC platform and below R2017a)
115115
if producePDFReport
116-
if ~testReportPluginPresent
116+
if ismac
117+
warning('MATLAB:testArtifact:unSupportedPlatform', ...
118+
'Producing a PDF test report is not supported on Mac OS platform.');
119+
elseif ~testReportPluginPresent
117120
issuePDFReportUnsupportedWarning;
118121
else
119122
mkdirIfNeeded(resultsDir);
@@ -129,6 +132,7 @@
129132
results = runner.run(suite);
130133
failed = any([results.Failed]);
131134

135+
132136
function tapToFile = getTapResultFile(resultsDir)
133137
import('matlab.unittest.plugins.ToFile');
134138
mkdirIfNeeded(resultsDir)
@@ -164,7 +168,7 @@ function mkdirIfNeeded(dir)
164168
filePath = fullfile(resultsDir, 'simulinktestresults.mldatx');
165169

166170
function tf = testReportPluginPresent
167-
BASE_VERSION_REPORTPLUGIN_SUPPORT = '9.1'; % R2016b
171+
BASE_VERSION_REPORTPLUGIN_SUPPORT = '9.2'; % R2017a
168172

169173
tf = ~verLessThan('matlab',BASE_VERSION_REPORTPLUGIN_SUPPORT);
170174

src/test/java/com/mathworks/ci/MatlabBuilderTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public void verifyRunTestAutomaticallyIsDefault() throws Exception {
300300
this.matlabBuilder.setMatlabRoot(getMatlabroot("R2018b"));
301301
FreeStyleBuild build = getBuildforRunTestAutomatically();
302302
jenkins.assertLogContains("-batch", build);
303-
jenkins.assertLogContains("\'TAPResults\',true," +
303+
jenkins.assertLogContains("\'PDFReport\',true,\'TAPResults\',true," +
304304
"\'JUnitResults\',true,\'SimulinkTestResults\',true," +
305305
"\'CoberturaCodeCoverage\',true,\'CoberturaModelCoverage\',true", build);
306306
}
@@ -548,6 +548,7 @@ private FreeStyleBuild getBuildforRunTestAutomatically() throws InterruptedExcep
548548
runOption.setTatapChkBx(true);
549549
runOption.setTaModelCoverageChkBx(true);
550550
runOption.setTaSTMResultsChkBx(true);
551+
runOption.setTaPDFReportChkBx(true);
551552
this.matlabBuilder.setTestRunTypeList(runOption);
552553
project.getBuildersList().add(this.matlabBuilder);
553554
FreeStyleBuild build = project.scheduleBuild2(0).get();

0 commit comments

Comments
 (0)