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

Commit 64e65f4

Browse files
authored
Merge pull request #221 from mathworks/genscript_new_changes
Genscript new changes
2 parents e05fe15 + 97e53de commit 64e65f4

File tree

15 files changed

+540
-19
lines changed

15 files changed

+540
-19
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class MatlabBuilderConstants {
2424
static final String COBERTURA_CODE_COVERAGE = "'CoberturaCodeCoverage'";
2525
static final String COBERTURA_MODEL_COVERAGE = "'CoberturaModelCoverage'";
2626

27+
2728
// Matlab Runner files
2829
static final String BAT_RUNNER_SCRIPT = "run_matlab_command.bat";
2930
static final String SHELL_RUNNER_SCRIPT = "run_matlab_command.sh";

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

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import hudson.Launcher.ProcStarter;
3636
import hudson.tasks.BuildStepDescriptor;
3737
import hudson.tasks.Builder;
38+
import hudson.util.ListBoxModel;
3839
import jenkins.tasks.SimpleBuildStep;
3940
import net.sf.json.JSONObject;
4041

@@ -60,6 +61,10 @@ public class RunMatlabTestsBuilder extends Builder implements SimpleBuildStep, M
6061
private SourceFolder sourceFolder;
6162
private SelectByFolder selectByFolder;
6263
private SelectByTag selectByTag;
64+
private String loggingLevel;
65+
private String outputDetail;
66+
private boolean useParallel;
67+
private boolean strict;
6368

6469

6570
@DataBoundConstructor
@@ -113,6 +118,27 @@ public void setSourceFolder(SourceFolder sourceFolder) {
113118
public void setSelectByFolder(SelectByFolder selectByFolder) {
114119
this.selectByFolder = selectByFolder;
115120
}
121+
122+
123+
@DataBoundSetter
124+
public void setLoggingLevel(String loggingLevel) {
125+
this.loggingLevel = loggingLevel;
126+
}
127+
128+
@DataBoundSetter
129+
public void setOutputDetail(String outputDetail) {
130+
this.outputDetail = outputDetail;
131+
}
132+
133+
@DataBoundSetter
134+
public void setUseParallel(boolean useParallel) {
135+
this.useParallel = useParallel;
136+
}
137+
138+
@DataBoundSetter
139+
public void setStrict(boolean strict) {
140+
this.strict = strict;
141+
}
116142

117143

118144
public String getTapReportFilePath() {
@@ -178,6 +204,24 @@ private Artifact getArtifactObject(boolean isChecked, Artifact returnVal) {
178204
return (isChecked) ? returnVal : new NullArtifact();
179205
}
180206

207+
// Verbosity level
208+
209+
public String getLoggingLevel() {
210+
return loggingLevel;
211+
}
212+
213+
public String getOutputDetail() {
214+
return outputDetail;
215+
}
216+
217+
public boolean getStrict() {
218+
return strict;
219+
}
220+
221+
public boolean getUseParallel() {
222+
return useParallel;
223+
}
224+
181225

182226
// To retain Backward compatibility
183227
protected Object readResolve() {
@@ -229,6 +273,31 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc
229273
save();
230274
return super.configure(req, formData);
231275
}
276+
277+
// Verbosity lists
278+
public ListBoxModel doFillLoggingLevelItems() {
279+
ListBoxModel items = new ListBoxModel();
280+
281+
items.add("Default", "default");
282+
items.add("None", "none");
283+
items.add("Terse", "terse");
284+
items.add("Concise", "concise");
285+
items.add("Detailed", "detailed");
286+
items.add("Verbose", "verbose");
287+
return items;
288+
}
289+
290+
public ListBoxModel doFillOutputDetailItems() {
291+
ListBoxModel items = new ListBoxModel();
292+
293+
items.add("Default", "default");
294+
items.add("None", "none");
295+
items.add("Terse", "terse");
296+
items.add("Concise", "concise");
297+
items.add("Detailed", "detailed");
298+
items.add("Verbose", "verbose");
299+
return items;
300+
}
232301

233302
/*
234303
* This is to identify which project type in jenkins this should be applicable.(non-Javadoc)
@@ -347,6 +416,24 @@ private String getInputArguments() {
347416
if (getSelectByTag() != null && !getSelectByTag().getTestTag().isEmpty()) {
348417
getSelectByTag().addTagToInputArgs(inputArgsList);
349418
}
419+
420+
// Add Logging level
421+
if (!getLoggingLevel().equalsIgnoreCase("default")) {
422+
inputArgsList.add("'LoggingLevel'" + "," + "'"
423+
+ getLoggingLevel() + "'");
424+
}
425+
426+
// Add Output Detail
427+
if (!getOutputDetail().equalsIgnoreCase("default")) {
428+
inputArgsList.add("'OutputDetail'" + "," + "'"
429+
+ getOutputDetail() + "'");
430+
}
431+
432+
// Add UseParallel
433+
inputArgsList.add("'UseParallel'" + "," + getUseParallel());
434+
435+
// Add Strict
436+
inputArgsList.add("'Strict'" + "," + getStrict());
350437

351438
return String.join(",", inputArgsList);
352439
}

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

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public class RunMatlabTestsStep extends Step {
3333
private String testResultsSimulinkTest;
3434
private String modelCoverageCobertura;
3535
private String selectByTag;
36+
private String loggingLevel;
37+
private String outputDetail;
38+
private boolean useParallel;
39+
private boolean strict;
3640
private List<String> sourceFolder = new ArrayList<>();
3741
private List<String> selectByFolder = new ArrayList<>();
3842

@@ -122,6 +126,42 @@ public List<String> getSelectByFolder() {
122126
public void setSelectByFolder(List<String> selectByFolder) {
123127
this.selectByFolder = selectByFolder;
124128
}
129+
130+
public String getLoggingLevel() {
131+
return loggingLevel;
132+
}
133+
134+
@DataBoundSetter
135+
public void setLoggingLevel(String loggingLevel) {
136+
this.loggingLevel = loggingLevel;
137+
}
138+
139+
public String getOutputDetail() {
140+
return outputDetail;
141+
}
142+
143+
@DataBoundSetter
144+
public void setOutputDetail(String outputDetail) {
145+
this.outputDetail = outputDetail;
146+
}
147+
148+
public boolean getUseParallel() {
149+
return useParallel;
150+
}
151+
152+
@DataBoundSetter
153+
public void setUseParallel(boolean useParallel) {
154+
this.useParallel = useParallel;
155+
}
156+
157+
public boolean getStrict() {
158+
return strict;
159+
}
160+
161+
@DataBoundSetter
162+
public void setStrict(boolean strict) {
163+
this.strict = strict;
164+
}
125165

126166
@Override
127167
public StepExecution start(StepContext context) throws Exception {
@@ -155,10 +195,14 @@ private String getInputArgs() {
155195
inputArgs.add("'Test'");
156196

157197
args.forEach((key, val) -> {
158-
if(key.equals("SourceFolder") || key.equals("SelectByFolder") && val != null){
159-
inputArgs.add("'" + key + "'" + "," + val);
160-
}else if(val != null){
161-
inputArgs.add("'" + key + "'" + "," + "'" + val.replaceAll("'", "''") + "'");
198+
if (val != null) {
199+
if (key.equals("SourceFolder") || key.equals("SelectByFolder")
200+
|| key.equals("UseParallel")
201+
|| key.equals("Strict")) {
202+
inputArgs.add("'" + key + "'" + "," + val);
203+
} else {
204+
inputArgs.add("'" + key + "'" + "," + "'" + val.replaceAll("'", "''") + "'");
205+
}
162206
}
163207
});
164208

@@ -174,6 +218,10 @@ private Map<String, String> getGenscriptArgs() {
174218
args.put("CoberturaCodeCoverage", getCodeCoverageCobertura());
175219
args.put("CoberturaModelCoverage", getModelCoverageCobertura());
176220
args.put("SelectByTag", getSelectByTag());
221+
args.put("UseParallel", String.valueOf(getUseParallel()));
222+
args.put("Strict", String.valueOf(getStrict()));
223+
args.put("LoggingLevel", getLoggingLevel());
224+
args.put("OutputDetail", getOutputDetail());
177225
addFolderArgs("SourceFolder",getSourceFolder(),args);
178226
addFolderArgs("SelectByFolder",getSelectByFolder(),args);
179227
return args;

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

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
11
<?jelly escape-by-default='true'?>
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

4-
<f:block>
4+
<f:block>
55
<br></br>
66
<f:optionalProperty field="sourceFolder" title="Source folder" />
77
</f:block>
88

9+
<f:section title="Run Customization">
910
<f:block>
10-
<br></br>
11-
<b>Filter Tests</b>
12-
<f:optionalProperty field="selectByFolder" title="By folder name" />
11+
<f:entry field="useParallel" title="Use parallel " checked="${instance.useParallel}">
12+
<f:checkbox/>
13+
</f:entry>
14+
15+
<f:entry field="strict" title="Strict " checked="${instance.strict}">
16+
<f:checkbox/>
17+
</f:entry>
18+
19+
<!-- Verbosity fields -->
20+
<f:entry name="loggingLevel " title="Logging level" field="loggingLevel" default="Default">
21+
<f:select/>
22+
</f:entry>
23+
24+
<f:entry name="outputDetail" title="Output detail " field="outputDetail" default="Default">
25+
<f:select/>
26+
</f:entry>
27+
</f:block>
28+
</f:section>
29+
<br></br>
30+
31+
<f:section title="Filter Tests">
32+
<f:block>
33+
<f:optionalProperty field="selectByFolder" title="By folder name" />
1334
<br></br>
14-
<f:optionalProperty field="selectByTag" title="By tag" />
35+
<f:optionalProperty field="selectByTag" title="By tag" />
1536
</f:block>
37+
</f:section>
38+
<br></br>
39+
1640

41+
<f:section title="Generate Test Artifacts">
1742
<f:block>
18-
<br></br>
19-
<b>Generate Test Artifacts</b>
2043
<f:optionalBlock name="pdfReportArtifact" field="pdfReportArtifact" title="PDF test report" checked="${instance.pdfReportArtifact.selected}">
2144
<f:entry field="pdfReportFilePath" title="File path: ">
2245
<f:textbox default="matlabTestArtifacts/testreport.pdf"/>
@@ -40,12 +63,12 @@
4063
<f:textbox default="matlabTestArtifacts/simulinktestresults.mldatx"/>
4164
</f:entry>
4265
</f:optionalBlock>
43-
4466
</f:block>
67+
</f:section>
68+
<br></br>
4569

70+
<f:section title="Generate Coverage Artifacts">
4671
<f:block>
47-
<br></br>
48-
<b>Generate Coverage Artifacts</b>
4972
<f:optionalBlock name="coberturaArtifact" field="coberturaArtifact" title="Cobertura code coverage" checked="${instance.coberturaArtifact.selected}">
5073
<f:entry field="coberturaReportFilePath" title="File path: ">
5174
<f:textbox default="matlabTestArtifacts/cobertura.xml"/>
@@ -58,4 +81,5 @@
5881
</f:entry>
5982
</f:optionalBlock>
6083
</f:block>
84+
</f:section>
6185
</j:jelly>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
<p>Maximum verbosity level for logged diagnostics included for the test run.</p>
3+
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
<p>Display level for event details output by the test run.</p>
3+
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
<p>Whether to apply strict checks when running the tests. For example, the framework generates a qualification failure if a test issues a warning.</p>
3+
</div>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div>
2+
<p>Whether to run tests in parallel. This feature requires a Parallel Computing Toolbox license, and might not be
3+
compatible with other options. If incompatible, testing occurs in serial regardless of the value of this feature.</p>
4+
</div>

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,25 @@
3333
<f:entry field="selectByTag" title="selectByTag: ">
3434
<f:textbox/>
3535
</f:entry>
36-
37-
<f:entry field="sourceFolder" title="sourceFolder: ">
36+
37+
<f:entry field="loggingLevel" title="loggingLevel: ">
3838
<f:textbox/>
39-
</f:entry>
39+
</f:entry>
40+
41+
<f:entry field="outputDetail" title="outputDetail: ">
42+
<f:textbox/>
43+
</f:entry>
44+
45+
<f:entry field="sourceFolder" title="sourceFolder: ">
46+
<f:textbox/>
47+
</f:entry>
48+
49+
<f:entry field="useParallel" title="useParallel: ">
50+
<f:checkbox/>
51+
</f:entry>
52+
53+
<f:entry field="strict" title="strict: ">
54+
<f:checkbox/>
55+
</f:entry>
4056

4157
</j:jelly>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
<p>Maximum verbosity level for logged diagnostics included for the test run.</p>
3+
</div>

0 commit comments

Comments
 (0)