Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*
*/

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -36,16 +35,15 @@ public MatlabCommandRunner(MatlabActionParameters params) throws IOException, In
this.params = params;
this.additionalEnvVars = new HashMap<String,String>();

FilePath workspace = params.getWorkspace();

// Handle case where workspace doesn't exist
if (!params.getWorkspace().exists()) {
params.getWorkspace().mkdirs();
if (!workspace.exists()) {
workspace.mkdirs();
}

// Create MATLAB folder
FilePath matlabFolder = new FilePath(
params.getLauncher().getChannel(), params.getWorkspace().getRemote()
+ File.separator
+ ".matlab");
FilePath matlabFolder = new FilePath(workspace, ".matlab");
matlabFolder.mkdirs();

// Create temp folder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
@RunWith(MockitoJUnitRunner.class)
public class MatlabCommandRunnerTest {

@Mock private FilePath workspace;
@Mock private Launcher launcher;
@Mock private ProcStarter procStarter;
private EnvVars env;
Expand All @@ -57,14 +56,12 @@ public class MatlabCommandRunnerTest {
public void initialize() throws IOException, InterruptedException {
env = new EnvVars();

when(params.getWorkspace()).thenReturn(workspace);
doReturn(new FilePath(tempDir.getRoot())).when(params).getWorkspace();
when(params.getLauncher()).thenReturn(launcher);
when(params.getEnvVars()).thenReturn(env);
when(params.getTaskListener()).thenReturn(listener);
when(params.getStartupOptions()).thenReturn("");

when(launcher.getChannel()).thenReturn(null);
when(workspace.getRemote()).thenReturn(tempDir.getRoot().getAbsolutePath());
when(listener.getLogger()).thenReturn(logger);

doReturn(false).when(launcher).isUnix();
Expand All @@ -87,8 +84,7 @@ public void validConstructorDoesNotThrow() throws IOException, InterruptedExcept
@Test
public void constructorUsesParamsForTempFolder() throws IOException, InterruptedException {
MatlabCommandRunner runner = new MatlabCommandRunner(params);
verify(params, times(1)).getLauncher();
verify(params, times(3)).getWorkspace();
verify(params, times(1)).getWorkspace();
}

@Test
Expand Down Expand Up @@ -214,7 +210,7 @@ public void runUsesWorkspaceLocationAsWD() throws IOException, InterruptedExcept

runner.runMatlabCommand("COMMAND");

verify(procStarter).pwd(workspace);
verify(procStarter).pwd(new FilePath(tempDir.getRoot()));
}

@Test
Expand Down