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

Commit 93dbc57

Browse files
author
Nikhil Bhoski
committed
Updated tests
1 parent a9c3791 commit 93dbc57

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,6 @@ public synchronized void setUp(Context context, Run<?, ?> build, FilePath worksp
148148
}
149149

150150
private String getNodeSpecificExecutable(Launcher launcher) {
151-
if (launcher.isUnix()) {
152-
return "matlab";
153-
} else {
154-
return "matlab.exe";
155-
}
151+
return (launcher.isUnix()) ? "matlab" : "matlab.exe";
156152
}
157153
}

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,19 @@ public void verifyMATLABrunnerFileGenerated() throws Exception {
264264
jenkins.assertLogContains("run_matlab_command", build);
265265
}
266266

267+
/*
268+
* Verify default MATLAB is not picked if invalid MATLAB path is provided
269+
*/
270+
@Test
271+
public void verifyDefaultMatlabNotPicked() throws Exception {
272+
this.buildWrapper.setMatlabRootFolder(getMatlabroot("R2020b"));
273+
project.getBuildWrappersList().add(this.buildWrapper);
274+
scriptBuilder.setMatlabCommand("pwd");
275+
project.getBuildersList().add(scriptBuilder);
276+
FreeStyleBuild build = project.scheduleBuild2(0).get();
277+
jenkins.assertLogContains("MatlabNotFoundError", build);
278+
}
279+
267280
/*
268281
* Test to verify if Matrix build fails when MATLAB is not available.
269282
*
@@ -273,7 +286,7 @@ public void verifyMATLABrunnerFileGenerated() throws Exception {
273286
@Test
274287
public void verifyMatrixBuildFails() throws Exception {
275288
MatrixProject matrixProject = jenkins.createProject(MatrixProject.class);
276-
Axis axes = new Axis("VERSION", "R2018a", "R2018b");
289+
Axis axes = new Axis("VERSION", "R2018a", "R2015b");
277290
matrixProject.setAxes(new AxisList(axes));
278291
String matlabRoot = getMatlabroot("R2018b");
279292
this.buildWrapper.setMatlabRootFolder(matlabRoot.replace("R2018b", "$VERSION"));
@@ -287,10 +300,10 @@ public void verifyMatrixBuildFails() throws Exception {
287300
MatrixRun build = matrixProject.scheduleBuild2(0).get().getRun(c1);
288301
jenkins.assertLogContains("run_matlab_command", build);
289302
jenkins.assertBuildStatus(Result.FAILURE, build);
290-
vals.put("VERSION", "R2018b");
303+
vals.put("VERSION", "R2015b");
291304
Combination c2 = new Combination(vals);
292305
MatrixRun build2 = matrixProject.scheduleBuild2(0).get().getRun(c2);
293-
jenkins.assertLogContains("run_matlab_command", build2);
306+
jenkins.assertLogContains("MatlabNotFoundError", build2);
294307
jenkins.assertBuildStatus(Result.FAILURE, build2);
295308
}
296309

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,18 @@ public void verifyMATLABrunnerFileGeneratedForAutomaticOption() throws Exception
346346
jenkins.assertLogContains("run_matlab_command", build);
347347
}
348348

349+
/*
350+
* Verify default MATLAB is not picked if invalid MATLAB path is provided
351+
*/
352+
@Test
353+
public void verifyDefaultMatlabNotPicked() throws Exception {
354+
this.buildWrapper.setMatlabRootFolder(getMatlabroot("R2020b"));
355+
project.getBuildWrappersList().add(this.buildWrapper);
356+
project.getBuildersList().add(testBuilder);
357+
FreeStyleBuild build = project.scheduleBuild2(0).get();
358+
jenkins.assertLogContains("MatlabNotFoundError", build);
359+
}
360+
349361
/*
350362
* Test to verify if Matrix build fails when MATLAB is not available.
351363
*
@@ -375,9 +387,8 @@ public void verifyMatrixBuildFails() throws Exception {
375387

376388
// Check for second Matrix combination
377389

378-
Map<String, String> val = new HashMap<String, String>();
379-
val.put("VERSION", "R2015b");
380-
Combination c2 = new Combination(val);
390+
vals.put("VERSION", "R2015b");
391+
Combination c2 = new Combination(vals);
381392
MatrixRun build2 = matrixProject.scheduleBuild2(0).get().getRun(c2);
382393

383394
jenkins.assertLogContains("MatlabNotFoundError", build2);

0 commit comments

Comments
 (0)