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

Commit 8fea3e5

Browse files
author
Nikhil Bhoski
committed
Updated final changes for test artifacts
1 parent b31fddf commit 8fea3e5

File tree

3 files changed

+87
-283
lines changed

3 files changed

+87
-283
lines changed

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

Lines changed: 12 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
package com.mathworks.ci;
22

3-
/**
4-
* Copyright 2019-2020 The MathWorks, Inc.
5-
*
6-
* MATLAB test run builder used to run all MATLAB & Simulink tests automatically and generate
7-
* selected test artifacts.
8-
*
9-
*/
10-
11-
12-
import java.io.File;
133
import java.io.IOException;
144
import java.util.ArrayList;
155
import java.util.List;
16-
import java.util.function.Function;
176
import javax.annotation.Nonnull;
187
import org.apache.commons.io.FilenameUtils;
198
import org.jenkinsci.Symbol;
209
import org.kohsuke.stapler.DataBoundConstructor;
2110
import org.kohsuke.stapler.DataBoundSetter;
22-
import org.kohsuke.stapler.QueryParameter;
2311
import org.kohsuke.stapler.StaplerRequest;
24-
import com.mathworks.ci.UseMatlabVersionBuildWrapper.UseMatlabVersionDescriptor;
2512
import hudson.EnvVars;
2613
import hudson.Extension;
2714
import hudson.FilePath;
@@ -33,8 +20,6 @@
3320
import hudson.model.TaskListener;
3421
import hudson.tasks.BuildStepDescriptor;
3522
import hudson.tasks.Builder;
36-
import hudson.util.FormValidation;
37-
import jenkins.model.Jenkins;
3823
import jenkins.tasks.SimpleBuildStep;
3924
import net.sf.json.JSONObject;
4025

@@ -202,8 +187,6 @@ private EnvVars getEnv() {
202187
@Extension
203188
public static class RunMatlabTestsDescriptor extends BuildStepDescriptor<Builder> {
204189

205-
MatlabReleaseInfo rel;
206-
207190
// Overridden Method used to show the text under build dropdown
208191
@Override
209192
public String getDisplayName() {
@@ -228,116 +211,6 @@ public boolean isApplicable(
228211
@SuppressWarnings("rawtypes") Class<? extends AbstractProject> jobtype) {
229212
return true;
230213
}
231-
232-
233-
/*
234-
* Validation for Test artifact generator checkBoxes
235-
*/
236-
237-
// Get the MATLAB root entered in build wrapper descriptor
238-
239-
240-
241-
public FormValidation doCheckCoberturaChkBxFilePath(@QueryParameter String coberturaChkBxFilePath) {
242-
List<Function<String, FormValidation>> listOfCheckMethods =
243-
new ArrayList<Function<String, FormValidation>>();
244-
if(!coberturaChkBxFilePath.isEmpty()) {
245-
listOfCheckMethods.add(chkCoberturaSupport);
246-
}
247-
return FormValidationUtil.getFirstErrorOrWarning(listOfCheckMethods, getMatlabRoot());
248-
}
249-
250-
Function<String, FormValidation> chkCoberturaSupport = (String matlabRoot) -> {
251-
FilePath matlabRootPath = new FilePath(new File(matlabRoot));
252-
rel = new MatlabReleaseInfo(matlabRootPath);
253-
final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot);
254-
if (!resolver.hasVariablePattern()) {
255-
try {
256-
if (rel.verLessThan(
257-
MatlabBuilderConstants.BASE_MATLAB_VERSION_COBERTURA_SUPPORT)) {
258-
return FormValidation.warning(
259-
Message.getValue("Builder.matlab.cobertura.support.warning"));
260-
}
261-
} catch (MatlabVersionNotFoundException e) {
262-
return FormValidation
263-
.warning(Message.getValue("Builder.invalid.matlab.root.warning"));
264-
}
265-
}
266-
267-
268-
return FormValidation.ok();
269-
};
270-
271-
public FormValidation doCheckModelCoverageChkBxFilePath(
272-
@QueryParameter String modelCoverageChkBxFilePath) {
273-
List<Function<String, FormValidation>> listOfCheckMethods =
274-
new ArrayList<Function<String, FormValidation>>();
275-
if (!modelCoverageChkBxFilePath.isEmpty()) {
276-
listOfCheckMethods.add(chkModelCoverageSupport);
277-
}
278-
return FormValidationUtil.getFirstErrorOrWarning(listOfCheckMethods, getMatlabRoot());
279-
}
280-
281-
Function<String, FormValidation> chkModelCoverageSupport = (String matlabRoot) -> {
282-
FilePath matlabRootPath = new FilePath(new File(matlabRoot));
283-
rel = new MatlabReleaseInfo(matlabRootPath);
284-
final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot);
285-
if (!resolver.hasVariablePattern()) {
286-
try {
287-
if (rel.verLessThan(
288-
MatlabBuilderConstants.BASE_MATLAB_VERSION_MODELCOVERAGE_SUPPORT)) {
289-
return FormValidation.warning(
290-
Message.getValue("Builder.matlab.modelcoverage.support.warning"));
291-
}
292-
} catch (MatlabVersionNotFoundException e) {
293-
return FormValidation
294-
.warning(Message.getValue("Builder.invalid.matlab.root.warning"));
295-
}
296-
}
297-
298-
299-
return FormValidation.ok();
300-
};
301-
302-
public FormValidation doCheckStmResultsChkBxFilePath(@QueryParameter String stmResultsChkBxFilePath) {
303-
List<Function<String, FormValidation>> listOfCheckMethods =
304-
new ArrayList<Function<String, FormValidation>>();
305-
if (!stmResultsChkBxFilePath.isEmpty()) {
306-
listOfCheckMethods.add(chkSTMResultsSupport);
307-
}
308-
return FormValidationUtil.getFirstErrorOrWarning(listOfCheckMethods, getMatlabRoot());
309-
}
310-
311-
Function<String, FormValidation> chkSTMResultsSupport = (String matlabRoot) -> {
312-
FilePath matlabRootPath = new FilePath(new File(matlabRoot));
313-
rel = new MatlabReleaseInfo(matlabRootPath);
314-
final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot);
315-
if (!resolver.hasVariablePattern()) {
316-
try {
317-
if (rel.verLessThan(
318-
MatlabBuilderConstants.BASE_MATLAB_VERSION_EXPORTSTMRESULTS_SUPPORT)) {
319-
return FormValidation.warning(Message
320-
.getValue("Builder.matlab.exportstmresults.support.warning"));
321-
}
322-
} catch (MatlabVersionNotFoundException e) {
323-
return FormValidation
324-
.warning(Message.getValue("Builder.invalid.matlab.root.warning"));
325-
}
326-
}
327-
return FormValidation.ok();
328-
};
329-
330-
// Method to get the MatlabRoot value from Build wrapper class.
331-
public static String getMatlabRoot() {
332-
try {
333-
return Jenkins.getInstance().getDescriptorByType(UseMatlabVersionDescriptor.class)
334-
.getMatlabRootFolder();
335-
} catch (Exception e) {
336-
// For any exception during getMatlabRootFolder() operation, return matlabRoot as
337-
// NULL.
338-
return null;
339-
}
340-
}
341214
}
342215

343216
@Override
@@ -425,8 +298,8 @@ private void addInputArgs(String reportName, String reportPath) {
425298
* 7Csort:date/jenkinsci-dev/AFYHSG3NUEI/UsVJIKoE4B8J
426299
*
427300
*/
428-
public class PdfChkBx {
429-
String pdfReportFilePath;
301+
public static class PdfChkBx {
302+
private String pdfReportFilePath;
430303

431304
@DataBoundConstructor
432305
public PdfChkBx() {
@@ -443,8 +316,8 @@ public String getPdfReportFilePath() {
443316
}
444317
}
445318

446-
public class TapChkBx {
447-
String tapReportFilePath;
319+
public static class TapChkBx {
320+
private String tapReportFilePath;
448321

449322
@DataBoundConstructor
450323
public TapChkBx() {
@@ -461,8 +334,8 @@ public String getTapReportFilePath() {
461334
}
462335
}
463336

464-
public class JunitChkBx {
465-
String junitReportFilePath;
337+
public static class JunitChkBx {
338+
private String junitReportFilePath;
466339

467340
@DataBoundConstructor
468341
public JunitChkBx() {
@@ -479,8 +352,8 @@ public String getJunitReportFilePath() {
479352
}
480353
}
481354

482-
public class CoberturaChkBx {
483-
String coberturaReportFilePath;
355+
public static class CoberturaChkBx {
356+
private String coberturaReportFilePath;
484357

485358
@DataBoundConstructor
486359
public CoberturaChkBx() {
@@ -497,8 +370,8 @@ public String getCoberturaReportFilePath() {
497370
}
498371
}
499372

500-
public class StmResultsChkBx {
501-
String stmResultsFilePath;
373+
public static class StmResultsChkBx {
374+
private String stmResultsFilePath;
502375

503376
@DataBoundConstructor
504377
public StmResultsChkBx() {
@@ -515,8 +388,8 @@ public String getStmResultsFilePath() {
515388
}
516389
}
517390

518-
public class ModelCovChkBx {
519-
String modelCoverageFilePath;
391+
public static class ModelCovChkBx {
392+
private String modelCoverageFilePath;
520393

521394
@DataBoundConstructor
522395
public ModelCovChkBx() {

src/main/resources/com/mathworks/ci/RunMatlabTestsBuilder/config.jelly

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33

44
<f:section title="Generate Test Artifacts">
55
<f:optionalBlock name="pdfReportChkBx" field="pdfReportChkBx" title="PDF test report" checked="${instance.isPdfChecked}">
6-
<f:entry field="pdfReportFilePath" title="Save PDF report at">
6+
<f:entry field="pdfReportFilePath" title="File location ">
77
<f:textbox default="matlabTestArtifacts/testreport.pdf"/>
88
</f:entry>
99
</f:optionalBlock>
1010

1111
<f:optionalBlock name="tapChkBx" field="tapChkBx" title="TAP test results" checked="${instance.isTapChecked}">
12-
<f:entry field="tapChkBxFilePath" title="Save TAP report at">
12+
<f:entry field="tapReportFilePath" title="File location ">
1313
<f:textbox default="matlabTestArtifacts/taptestresults.tap"/>
1414
</f:entry>
1515
</f:optionalBlock>
1616

1717
<f:optionalBlock name="junitChkBx" field="junitChkBx" title="JUnit-style test results" checked="${instance.isJunitChecked}">
18-
<f:entry field="junitChkBxFilePath" title="Save JUnit-style report at">
18+
<f:entry field="junitReportFilePath" title="File location ">
1919
<f:textbox default="matlabTestArtifacts/junittestresults.xml"/>
2020
</f:entry>
2121
</f:optionalBlock>
2222

2323
<f:optionalBlock name="stmResultsChkBx" field="stmResultsChkBx" title="Simulink Test Manager results" checked="${instance.isStmChecked}">
24-
<f:entry field="stmResultsChkBxFilePath" title="Save Simulink Test Manager results at">
24+
<f:entry field="stmResultsFilePath" title="File location ">
2525
<f:textbox default="matlabTestArtifacts/simulinktestresults.mldatx"/>
2626
</f:entry>
2727
</f:optionalBlock>
@@ -30,13 +30,13 @@
3030

3131
<f:section title="Generate Coverage Artifacts">
3232
<f:optionalBlock name="coberturaChkBx" field="coberturaChkBx" title="Cobertura code coverage" checked="${instance.isCoberturaChecked}">
33-
<f:entry field="coberturaChkBxFilePath" title="Save Cobertura code coverage at">
33+
<f:entry field="coberturaReportFilePath" title="File location ">
3434
<f:textbox default="matlabTestArtifacts/cobertura.xml"/>
3535
</f:entry>
3636
</f:optionalBlock>
3737

3838
<f:optionalBlock name="modelCoverageChkBx" field="modelCoverageChkBx" title="Cobertura model coverage" checked="${instance.isModelCovChecked}">
39-
<f:entry field="modelCoverageChkBxFilePath" title="Save Cobertura mode">
39+
<f:entry field="modelCoverageFilePath" title="File location ">
4040
<f:textbox default="matlabTestArtifacts/modelcoverage.xml"/>
4141
</f:entry>
4242
</f:optionalBlock>

0 commit comments

Comments
 (0)