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

Commit 9750a26

Browse files
authored
Merge pull request #222 from mathworks/2.8.1-SNAPSHOT-Qualification
2.8.1 snapshot qualification
2 parents 55d8130 + 2ebfe04 commit 9750a26

17 files changed

+593
-63
lines changed

CONFIGDOC.md

Lines changed: 44 additions & 30 deletions
Large diffs are not rendered by default.

examples/Run-MATLAB-Tests.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,43 +24,37 @@ To follow the steps in this example:
2424
Create a new project and configure it by following these steps:
2525
1. In your Jenkins interface, select **New Item** on the left. A new page opens where you can choose the type of your project. Enter a project name, and then click **Freestyle project**. To confirm your choices, click **OK**.
2626

27-
![create_project](https://user-images.githubusercontent.com/48831250/105080784-520e6480-5a5f-11eb-9218-4d43013e2850.png)
27+
![create_project](https://user-images.githubusercontent.com/48831250/193948023-65f038c2-a81e-416b-8dea-0cf91ae5f105.png)
2828

2929
2. On the project configuration page, in the **Source Code Management** section, specify the repository that hosts your tests.
3030

3131
![source_control](https://user-images.githubusercontent.com/48831250/94478391-37a73700-01a1-11eb-9f89-a5a71413baf0.png)
3232

3333
3. In the **Build Environment** section, select **Use MATLAB version** and specify the MATLAB version you want to use in the build. If your desired MATLAB version is not listed under **Use MATLAB version**, enter the full path to its root folder in the **MATLAB root** box.
3434

35-
![build_environment](https://user-images.githubusercontent.com/48831250/105091260-943ea280-5a6d-11eb-8d11-48747df7ec32.png)
35+
![build_environment](https://user-images.githubusercontent.com/48831250/193948480-564ac249-0ef2-407b-b18c-ee52b5129ac0.png)
3636

3737
4. In the **Build** section, select **Add build step > Run MATLAB Tests**. Then, specify the artifacts to be generated in the project workspace. In this example, the plugin generates Cobertura code coverage and JUnit-style test results reports. Furthermore, to generate the coverage report, the plugin uses only the code in the `source` folder located in the root of the repository. For more information about the build steps provided by the plugin, see [Plugin Configuration Guide](../CONFIGDOC.md).
3838

39-
![run_matlab_tests](https://user-images.githubusercontent.com/48831250/105909903-2149a480-5ff6-11eb-81f1-c3b44e9b17d1.png)
39+
![run_,matlab_tests](https://user-images.githubusercontent.com/48831250/193948891-aa09960a-04ba-4a13-9eea-e4bebab9371d.png)
4040

4141
5. In the **Post-build Actions** section, add two post-build actions to publish the Cobertura code coverage and JUnit-style test results reports. For each artifact, provide the path to the report.
4242

43-
![post_build](https://user-images.githubusercontent.com/48831250/105082096-14aad680-5a61-11eb-9868-68d018199f9d.png)
43+
![post_build](https://user-images.githubusercontent.com/48831250/193949176-aced5dfb-f7b9-4978-8726-7d01bae4bc97.png)
4444

4545
6. Click **Save** to save the project configuration settings. You can access and modify your settings at a later stage by selecting **Configure** in the project interface, which displays the project name at the top-left of the page.
4646

4747
## Run Tests and Inspect Artifacts
4848
To build your freestyle project, click **Build Now** in the project interface. Jenkins triggers a build, assigns it a number under **Build History**, and runs the build. If the build is successful, a blue circle icon appears next to the build number. If the build fails, Jenkins adds a red circle icon. In this example, the build succeeds because all the tests in the Times Table App project pass.
4949

50-
![build_1](https://user-images.githubusercontent.com/48831250/105084788-dca59280-5a64-11eb-858d-664a5727a947.png)
51-
5250
Navigate to the project workspace by clicking the **Workspace** icon in the project interface. The generated artifacts are in the `matlabTestArtifacts` folder of the workspace.
5351

54-
![workspace](https://user-images.githubusercontent.com/48831250/105085419-b46a6380-5a65-11eb-8d46-747dd23291bf.png)
55-
56-
Access the published Cobertura code coverage report by opening the **Coverage Report** link in the project interface.
57-
58-
![cobertura_report](https://user-images.githubusercontent.com/48831250/105085331-9ac91c00-5a65-11eb-9628-efbf70520489.png)
52+
![workspace](https://user-images.githubusercontent.com/48831250/193951807-a09ef1f8-cf7e-49c8-8615-af5fbd97acd0.png)
5953

60-
To view the published JUnit-style test results, open the **Latest Test Result** link in the project interface. In the new page, open the link in the **All Tests** table. The table expands and lists information for each of the test classes within the Times Table App project.
54+
Click the **Status** icon in the project interface. You can access the published artifacts by opening the **Latest Test Result** and **Coverage Report** links. For example, open the **Latest Test Result** link to view the published JUnit-style test results. In the new page, open the link in the **All Tests** table. The table expands and lists information for each of the test classes within the Times Table App project.
6155

62-
![junit_report](https://user-images.githubusercontent.com/48831250/105088211-956dd080-5a69-11eb-931c-aef201eb9dbe.png)
56+
![test_results](https://user-images.githubusercontent.com/48831250/194086287-35f7c677-4c18-4316-b676-f2491ffa20a7.png)
6357

6458
## See Also
6559
* [Plugin Configuration Guide](../CONFIGDOC.md)<br/>
66-
* [Explore an Example Project (MATLAB)](https://www.mathworks.com/help/matlab/matlab_prog/explore-an-example-project.html)
60+
* [Explore an Example Project (MATLAB)](https://www.mathworks.com/help/matlab/matlab_prog/explore-an-example-project.html)

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 = "default";
65+
private String outputDetail = "default";
66+
private boolean useParallel = false;
67+
private boolean strict = false;
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 == null ? "default" : this.loggingLevel;
211+
}
212+
213+
public String getOutputDetail() {
214+
return outputDetail == null ? "default" : this.outputDetail;
215+
}
216+
217+
public boolean getStrict() {
218+
return this.strict;
219+
}
220+
221+
public boolean getUseParallel() {
222+
return this.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: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
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+
<br></br>
10+
11+
<f:section title="Filter Tests">
912
<f:block>
10-
<br></br>
11-
<b>Filter Tests</b>
12-
<f:optionalProperty field="selectByFolder" title="By folder name" />
13+
<f:optionalProperty field="selectByFolder" title="By folder name" />
1314
<br></br>
14-
<f:optionalProperty field="selectByTag" title="By tag" />
15+
<f:optionalProperty field="selectByTag" title="By tag" />
1516
</f:block>
17+
</f:section>
18+
<br></br>
1619

20+
<f:section title="Customize Test Run">
21+
<f:block>
22+
<f:entry field="strict" title="Strict " checked="${instance.strict}">
23+
<f:checkbox/>
24+
</f:entry>
25+
<f:entry field="useParallel" title="Use parallel " checked="${instance.useParallel}">
26+
<f:checkbox/>
27+
</f:entry>
28+
29+
<!-- Verbosity fields -->
30+
31+
<f:entry name="outputDetail" title="Output detail " field="outputDetail" default="Default">
32+
<f:select/>
33+
</f:entry>
34+
35+
<f:entry name="loggingLevel " title="Logging level" field="loggingLevel" default="Default">
36+
<f:select/>
37+
</f:entry>
38+
</f:block>
39+
</f:section>
40+
41+
42+
<f:section title="Generate Test Artifacts">
1743
<f:block>
18-
<br></br>
19-
<b>Generate Test Artifacts</b>
2044
<f:optionalBlock name="pdfReportArtifact" field="pdfReportArtifact" title="PDF test report" checked="${instance.pdfReportArtifact.selected}">
2145
<f:entry field="pdfReportFilePath" title="File path: ">
2246
<f:textbox default="matlabTestArtifacts/testreport.pdf"/>
@@ -40,12 +64,12 @@
4064
<f:textbox default="matlabTestArtifacts/simulinktestresults.mldatx"/>
4165
</f:entry>
4266
</f:optionalBlock>
43-
4467
</f:block>
68+
</f:section>
69+
<br></br>
4570

71+
<f:section title="Generate Coverage Artifacts">
4672
<f:block>
47-
<br></br>
48-
<b>Generate Coverage Artifacts</b>
4973
<f:optionalBlock name="coberturaArtifact" field="coberturaArtifact" title="Cobertura code coverage" checked="${instance.coberturaArtifact.selected}">
5074
<f:entry field="coberturaReportFilePath" title="File path: ">
5175
<f:textbox default="matlabTestArtifacts/cobertura.xml"/>
@@ -58,4 +82,5 @@
5882
</f:entry>
5983
</f:optionalBlock>
6084
</f:block>
85+
</f:section>
6186
</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>

0 commit comments

Comments
 (0)