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

Commit e77b8ae

Browse files
author
Nikhil Bhoski
committed
Updated as per review comment
1 parent 16bcaff commit e77b8ae

File tree

11 files changed

+139
-52
lines changed

11 files changed

+139
-52
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ public class MatlabBuilderConstants {
2323
static final String STM_RESULTS = "'SimulinkTestResults'";
2424
static final String COBERTURA_CODE_COVERAGE = "'CoberturaCodeCoverage'";
2525
static final String COBERTURA_MODEL_COVERAGE = "'CoberturaModelCoverage'";
26-
static final String USE_PARALLEL = "UseParallel";
27-
static final String STRICT = "Strict";
28-
static final String LOGGING_LEVEL = "LoggingLevel";
29-
static final String OUTPUT_DETAIL = "OutputDetail";
26+
3027

3128
// Matlab Runner files
3229
static final String BAT_RUNNER_SCRIPT = "run_matlab_command.bat";

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,21 +419,21 @@ private String getInputArguments() {
419419

420420
// Add Logging level
421421
if (!getLoggingLevel().equalsIgnoreCase("default")) {
422-
inputArgsList.add("'" + MatlabBuilderConstants.LOGGING_LEVEL + "'" + "," + "'"
422+
inputArgsList.add("'LoggingLevel'" + "," + "'"
423423
+ getLoggingLevel() + "'");
424424
}
425425

426-
// Add Logging level
427-
if (!getLoggingLevel().equalsIgnoreCase("default")) {
428-
inputArgsList.add("'" + MatlabBuilderConstants.OUTPUT_DETAIL + "'" + "," + "'"
426+
// Add Output Detail
427+
if (!getOutputDetail().equalsIgnoreCase("default")) {
428+
inputArgsList.add("'OutputDetail'" + "," + "'"
429429
+ getOutputDetail() + "'");
430430
}
431431

432432
// Add UseParallel
433-
inputArgsList.add("'" + MatlabBuilderConstants.USE_PARALLEL + "'" + "," + getUseParallel());
433+
inputArgsList.add("'UseParallel'" + "," + getUseParallel());
434434

435435
// Add Strict
436-
inputArgsList.add("'" + MatlabBuilderConstants.STRICT + "'" + "," + getStrict());
436+
inputArgsList.add("'Strict'" + "," + getStrict());
437437

438438
return String.join(",", inputArgsList);
439439
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ private String getInputArgs() {
196196

197197
args.forEach((key, val) -> {
198198
if (key.equals("SourceFolder") || key.equals("SelectByFolder")
199-
|| key.equals(MatlabBuilderConstants.USE_PARALLEL)
200-
|| key.equals(MatlabBuilderConstants.STRICT) && val != null) {
199+
|| key.equals("UseParallel")
200+
|| key.equals("Strict") && val != null) {
201201
inputArgs.add("'" + key + "'" + "," + val);
202202
} else if (val != null) {
203203
inputArgs.add("'" + key + "'" + "," + "'" + val.replaceAll("'", "''") + "'");
@@ -216,10 +216,10 @@ private Map<String, String> getGenscriptArgs() {
216216
args.put("CoberturaCodeCoverage", getCodeCoverageCobertura());
217217
args.put("CoberturaModelCoverage", getModelCoverageCobertura());
218218
args.put("SelectByTag", getSelectByTag());
219-
args.put(MatlabBuilderConstants.USE_PARALLEL, String.valueOf(getUseParallel()));
220-
args.put(MatlabBuilderConstants.STRICT, String.valueOf(getStrict()));
221-
args.put(MatlabBuilderConstants.LOGGING_LEVEL, getLoggingLevel());
222-
args.put(MatlabBuilderConstants.OUTPUT_DETAIL, getOutputDetail());
219+
args.put("UseParallel", String.valueOf(getUseParallel()));
220+
args.put("Strict", String.valueOf(getStrict()));
221+
args.put("LoggingLevel", getLoggingLevel());
222+
args.put("OutputDetail", getOutputDetail());
223223
addFolderArgs("SourceFolder",getSourceFolder(),args);
224224
addFolderArgs("SelectByFolder",getSelectByFolder(),args);
225225
return args;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div>
2-
<p>Select verbosity level of output details for test results in the log</p>
2+
<p>Display level for event details output by the test run.</p>
33
</div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div>
2-
<p>Select to fail the test suite on warnnings</p>
2+
<p>Select to fail the test suite on warnings</p>
33
</div>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<div>
2-
<p>Select to run the tests in parallel</p>
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>
34
</div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div>
2-
<p>Select verbosity level of output details for test results in the log</p>
2+
<p>Display level for event details output by the test run.</p>
33
</div>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div>
2-
<p>Select to fail the test suite on warnnings</p>
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>
33
</div>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<div>
2-
<p>Select to run the tests in parallel</p>
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>
34
</div>

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

Lines changed: 106 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
import org.junit.Test;
2222
import org.jvnet.hudson.test.JenkinsRule;
2323
import com.gargoylesoftware.htmlunit.WebAssert;
24+
import com.gargoylesoftware.htmlunit.html.DomElement;
2425
import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
2526
import com.gargoylesoftware.htmlunit.html.HtmlPage;
27+
import com.gargoylesoftware.htmlunit.html.HtmlSelect;
28+
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLSelectElement;
2629
import com.mathworks.ci.RunMatlabTestsBuilder.CoberturaArtifact;
2730
import com.mathworks.ci.RunMatlabTestsBuilder.JunitArtifact;
2831
import com.mathworks.ci.RunMatlabTestsBuilder.ModelCovArtifact;
@@ -87,6 +90,8 @@ public static void classSetup() throws URISyntaxException, IOException {
8790
public void testSetup() throws IOException {
8891
this.project = jenkins.createFreeStyleProject();
8992
this.testBuilder = new RunMatlabTestsBuilder();
93+
testBuilder.setLoggingLevel("default");
94+
testBuilder.setOutputDetail("default");
9095
this.buildWrapper = new UseMatlabVersionBuildWrapper();
9196
}
9297

@@ -525,23 +530,106 @@ public void verifySystemTempDirDeleted() throws Exception {
525530
jenkins.assertLogContains("rmdir(tmpDir,'s')", build);
526531
}
527532

533+
528534
/*
535+
* Test to verify Use Parallel check box present.
536+
*/
537+
538+
@Test
539+
public void verifyUseParallelPresent() throws Exception {
540+
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
541+
project.getBuildWrappersList().add(this.buildWrapper);
542+
project.getBuildersList().add(this.testBuilder);
543+
HtmlPage page = jenkins.createWebClient().goTo("job/test0/configure");
544+
WebAssert.assertElementPresentByXPath(page, "//input[@name=\"_.useParallel\"]");
545+
}
546+
547+
/*
548+
* Test to verify Strict check box present.
549+
*/
550+
551+
@Test
552+
public void verifyStrictPresent() throws Exception {
553+
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
554+
project.getBuildWrappersList().add(this.buildWrapper);
555+
project.getBuildersList().add(this.testBuilder);
556+
HtmlPage page = jenkins.createWebClient().goTo("job/test0/configure");
557+
WebAssert.assertElementPresentByXPath(page, "//input[@name=\"_.strict\"]");
558+
}
559+
560+
/*
561+
* Test to verify Logging Level is present.
562+
*/
563+
564+
@Test
565+
public void verifyLoggingLevelPresent() throws Exception {
566+
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
567+
project.getBuildWrappersList().add(this.buildWrapper);
568+
project.getBuildersList().add(this.testBuilder);
569+
HtmlPage page = jenkins.createWebClient().goTo("job/test0/configure");
570+
WebAssert.assertElementPresentByXPath(page, "//select[@name=\"_.loggingLevel\"]");
571+
}
572+
573+
/*
574+
* Test to verify Output Detail is present.
575+
*/
576+
577+
@Test
578+
public void verifyOutputDetailPresent() throws Exception {
579+
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
580+
project.getBuildWrappersList().add(this.buildWrapper);
581+
project.getBuildersList().add(this.testBuilder);
582+
HtmlPage page = jenkins.createWebClient().goTo("job/test0/configure");
583+
WebAssert.assertElementPresentByXPath(page, "//select[@name=\"_.outputDetail\"]");
584+
}
585+
586+
/*
587+
* Test to verify Logging Level set to default
588+
*/
589+
590+
@Test
591+
public void verifyLoggingLevelSetToDefault() throws Exception {
592+
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
593+
project.getBuildWrappersList().add(this.buildWrapper);
594+
project.getBuildersList().add(this.testBuilder);
595+
HtmlPage page = jenkins.createWebClient().goTo("job/test0/configure");
596+
HtmlSelect loggingLevel = page.getElementByName("_.loggingLevel");
597+
assertEquals("default", loggingLevel.getAttribute("value"));
598+
}
599+
600+
/*
601+
* Test to verify Output Detail set to default
602+
*/
603+
604+
@Test
605+
public void verifyOutputDetailSetToDefault() throws Exception {
606+
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
607+
project.getBuildWrappersList().add(this.buildWrapper);
608+
project.getBuildersList().add(this.testBuilder);
609+
HtmlPage page = jenkins.createWebClient().goTo("job/test0/configure");
610+
HtmlSelect outputDetail = page.getElementByName("_.outputDetail");
611+
assertEquals("default", outputDetail.getAttribute("value"));
612+
}
613+
614+
615+
/*
616+
* @Integ
529617
* Test To verify if Logging level is set correctly
530618
*
531619
*/
532620

533-
@Test
621+
534622
public void verifyLoggingLevelSet() throws Exception {
535623
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(
536624
Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
537625
project.getBuildWrappersList().add(this.buildWrapper);
538-
Map<String, String> logginggLevel = new HashMap<String, String>();
539-
logginggLevel.put("None", "'LoggingLevel', 0");
540-
logginggLevel.put("Terse", "'LoggingLevel', 1");
541-
logginggLevel.put("Concise", "'LoggingLevel', 2");
542-
logginggLevel.put("Detailed", "'LoggingLevel', 3");
543-
logginggLevel.put("Verbose", "'LoggingLevel', 4");
544-
logginggLevel.forEach((key, val) -> {
626+
Map<String, String> loggingLevel = new HashMap<String, String>();
627+
loggingLevel.put("None", "'LoggingLevel', 0");
628+
loggingLevel.put("Terse", "'LoggingLevel', 1");
629+
loggingLevel.put("Concise", "'LoggingLevel', 2");
630+
loggingLevel.put("Detailed", "'LoggingLevel', 3");
631+
loggingLevel.put("Verbose", "'LoggingLevel', 4");
632+
loggingLevel.forEach((key, val) -> {
545633
testBuilder.setLoggingLevel(key);
546634
project.getBuildersList().add(this.testBuilder);
547635
FreeStyleBuild build;
@@ -555,12 +643,12 @@ public void verifyLoggingLevelSet() throws Exception {
555643
});
556644
}
557645

558-
/*
646+
/*@Integ
559647
* Test To verify if Output Detail is set correctly
560648
*
561649
*/
562650

563-
@Test
651+
564652
public void verifyOutputDetailSet() throws Exception {
565653
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(
566654
Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
@@ -586,12 +674,12 @@ public void verifyOutputDetailSet() throws Exception {
586674
});
587675
}
588676

589-
/*
677+
/*@Integ
590678
* Test To verify when Strict option set
591679
*
592680
*/
593681

594-
@Test
682+
595683
public void verifyStrictSet() throws Exception {
596684
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(
597685
Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
@@ -604,12 +692,12 @@ public void verifyStrictSet() throws Exception {
604692

605693
}
606694

607-
/*
695+
/*@Integ
608696
* Test To verify when Strict option not set
609697
*
610698
*/
611699

612-
@Test
700+
613701
public void verifyStrictNotSet() throws Exception {
614702
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(
615703
Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
@@ -622,12 +710,12 @@ public void verifyStrictNotSet() throws Exception {
622710

623711
}
624712

625-
/*
713+
/*@Integ
626714
* Test To verify when Run in Parallel option is set
627715
*
628716
*/
629717

630-
@Test
718+
631719
public void verifyRunParallelSet() throws Exception {
632720
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(
633721
Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
@@ -639,12 +727,12 @@ public void verifyRunParallelSet() throws Exception {
639727
jenkins.assertLogContains("runInParallel", build);
640728
}
641729

642-
/*
730+
/*@Integ
643731
* Test To verify when Run in Parallel option is set
644732
*
645733
*/
646734

647-
@Test
735+
648736
public void verifyRunParallelNotSet() throws Exception {
649737
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(
650738
Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));

0 commit comments

Comments
 (0)