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

Commit b6b89af

Browse files
authored
Merge pull request #329 from mathworks/fix_326
Fix 326
2 parents 3924684 + 8e6040d commit b6b89af

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/main/java/com/mathworks/ci/utilities/MatlabCommandRunner.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*
66
*/
77

8-
import java.io.File;
98
import java.io.IOException;
109
import java.io.InputStream;
1110
import java.io.OutputStream;
@@ -36,16 +35,15 @@ public MatlabCommandRunner(MatlabActionParameters params) throws IOException, In
3635
this.params = params;
3736
this.additionalEnvVars = new HashMap<String,String>();
3837

38+
FilePath workspace = params.getWorkspace();
39+
3940
// Handle case where workspace doesn't exist
40-
if (!params.getWorkspace().exists()) {
41-
params.getWorkspace().mkdirs();
41+
if (!workspace.exists()) {
42+
workspace.mkdirs();
4243
}
4344

4445
// Create MATLAB folder
45-
FilePath matlabFolder = new FilePath(
46-
params.getLauncher().getChannel(), params.getWorkspace().getRemote()
47-
+ File.separator
48-
+ ".matlab");
46+
FilePath matlabFolder = new FilePath(workspace, ".matlab");
4947
matlabFolder.mkdirs();
5048

5149
// Create temp folder

src/test/java/unit/com/mathworks/ci/utilities/MatlabCommandRunnerTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
@RunWith(MockitoJUnitRunner.class)
4141
public class MatlabCommandRunnerTest {
4242

43-
@Mock private FilePath workspace;
4443
@Mock private Launcher launcher;
4544
@Mock private ProcStarter procStarter;
4645
private EnvVars env;
@@ -57,14 +56,12 @@ public class MatlabCommandRunnerTest {
5756
public void initialize() throws IOException, InterruptedException {
5857
env = new EnvVars();
5958

60-
when(params.getWorkspace()).thenReturn(workspace);
59+
doReturn(new FilePath(tempDir.getRoot())).when(params).getWorkspace();
6160
when(params.getLauncher()).thenReturn(launcher);
6261
when(params.getEnvVars()).thenReturn(env);
6362
when(params.getTaskListener()).thenReturn(listener);
6463
when(params.getStartupOptions()).thenReturn("");
6564

66-
when(launcher.getChannel()).thenReturn(null);
67-
when(workspace.getRemote()).thenReturn(tempDir.getRoot().getAbsolutePath());
6865
when(listener.getLogger()).thenReturn(logger);
6966

7067
doReturn(false).when(launcher).isUnix();
@@ -87,8 +84,7 @@ public void validConstructorDoesNotThrow() throws IOException, InterruptedExcept
8784
@Test
8885
public void constructorUsesParamsForTempFolder() throws IOException, InterruptedException {
8986
MatlabCommandRunner runner = new MatlabCommandRunner(params);
90-
verify(params, times(1)).getLauncher();
91-
verify(params, times(3)).getWorkspace();
87+
verify(params, times(1)).getWorkspace();
9288
}
9389

9490
@Test
@@ -214,7 +210,7 @@ public void runUsesWorkspaceLocationAsWD() throws IOException, InterruptedExcept
214210

215211
runner.runMatlabCommand("COMMAND");
216212

217-
verify(procStarter).pwd(workspace);
213+
verify(procStarter).pwd(new FilePath(tempDir.getRoot()));
218214
}
219215

220216
@Test

0 commit comments

Comments
 (0)