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

Commit 5fb8b97

Browse files
committed
Switch to using a temporary directory on the agent external to the workspace.
1 parent 7b77260 commit 5fb8b97

File tree

8 files changed

+8
-83
lines changed

8 files changed

+8
-83
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import hudson.Launcher;
1919
import hudson.Launcher.ProcStarter;
2020
import hudson.model.Computer;
21+
import hudson.slaves.WorkspaceList;
2122
import hudson.util.ArgumentListBuilder;
2223

2324
import com.mathworks.ci.Utilities;
@@ -43,11 +44,11 @@ public MatlabCommandRunner(MatlabActionParameters params) throws IOException, In
4344
}
4445

4546
// Create MATLAB folder
46-
FilePath matlabFolder = new FilePath(workspace, ".matlab");
47-
matlabFolder.mkdirs();
47+
FilePath tmpRoot = WorkspaceList.tempDir(workspace);
48+
tmpRoot.mkdirs();
4849

4950
// Create temp folder
50-
this.tempFolder = matlabFolder.createTempDir("tempDir", null);
51+
this.tempFolder = tmpRoot.createTempDir("matlab", null);
5152
}
5253

5354
/**

src/test/java/integ/com/mathworks/ci/RunMatlabBuildBuilderTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -356,18 +356,4 @@ public void verifyMatrixBuildPasses() throws Exception {
356356
jenkins.assertLogContains("R2018b completed", build);
357357
jenkins.assertBuildStatus(Result.SUCCESS, build);
358358
}
359-
360-
/*
361-
* Test to verify if .matlab temp folder generated in workspace.
362-
*/
363-
@Test
364-
public void verifyMATLABtmpFolderGenerated() throws Exception {
365-
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
366-
project.getBuildWrappersList().add(this.buildWrapper);
367-
scriptBuilder.setTasks("");
368-
project.getBuildersList().add(this.scriptBuilder);
369-
FreeStyleBuild build = project.scheduleBuild2(0).get();
370-
File matlabRunner = new File(build.getWorkspace() + File.separator + ".matlab");
371-
Assert.assertTrue(matlabRunner.exists());
372-
}
373359
}

src/test/java/integ/com/mathworks/ci/RunMatlabBuildStepTest.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,4 @@ public void verifyExceptionStackTraceForNonZeroExitCode() throws Exception {
176176
j.assertBuildStatus(Result.FAILURE, build);
177177
j.assertLogContains(String.format(Message.getValue("matlab.execution.exception.prefix"), 1), build);
178178
}
179-
180-
/*
181-
* Verify .matlab folder is generated
182-
*/
183-
@Test
184-
public void verifyMATLABtempFolderGenerated() throws Exception {
185-
project.setDefinition(
186-
new CpsFlowDefinition("node { runMATLABBuild() }", true));
187-
188-
WorkflowRun build = project.scheduleBuild2(0).get();
189-
j.assertLogContains(".matlab", build);
190-
}
191179
}

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,4 @@ public void verifyMultispecialChar() throws Exception {
377377
jenkins.assertLogContains("Generating MATLAB script with content", build);
378378
jenkins.assertLogContains(expectedCommand, build);
379379
}
380-
381-
/*
382-
* Test to verify if .matlab temp folder generated in workspace.
383-
*/
384-
@Test
385-
public void verifyMATLABtmpFolderGenerated() throws Exception {
386-
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
387-
project.getBuildWrappersList().add(this.buildWrapper);
388-
scriptBuilder.setMatlabCommand("pwd");
389-
project.getBuildersList().add(this.scriptBuilder);
390-
FreeStyleBuild build = project.scheduleBuild2(0).get();
391-
File matlabRunner = new File(build.getWorkspace() + File.separator + ".matlab");
392-
Assert.assertTrue(matlabRunner.exists());
393-
}
394380
}

src/test/java/integ/com/mathworks/ci/RunMatlabCommandStepTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,4 @@ public void verifyExceptionForNonZeroExitCode() throws Exception {
149149
j.assertLogContains(String.format(Message.getValue("matlab.execution.exception.prefix"), 1), build);
150150
j.assertBuildStatusSuccess(build);
151151
}
152-
153-
/*
154-
* Verify .matlab folder is generated
155-
*
156-
*/
157-
158-
@Test
159-
public void verifyMATLABtempFolderGenerated() throws Exception {
160-
project.setDefinition(
161-
new CpsFlowDefinition("node { runMATLABCommand(command: 'pwd')}", true));
162-
163-
WorkflowRun build = project.scheduleBuild2(0).get();
164-
j.assertLogContains(".matlab", build);
165-
}
166152
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -484,19 +484,6 @@ public void verifyMATLABscratchFileGenerated() throws Exception {
484484
Assert.assertFalse(matlabRunner.exists());
485485
}
486486

487-
/*
488-
* Test to verify if .matlab gets created in workspace.
489-
*/
490-
@Test
491-
public void verifyMATLABfolderGenerated() throws Exception {
492-
this.buildWrapper.setMatlabBuildWrapperContent(new MatlabBuildWrapperContent(Message.getValue("matlab.custom.location"), getMatlabroot("R2018b")));
493-
project.getBuildWrappersList().add(this.buildWrapper);
494-
project.getBuildersList().add(testBuilder);
495-
FreeStyleBuild build = project.scheduleBuild2(0).get();
496-
File matlabRunner = new File(build.getWorkspace() + File.separator + ".matlab");
497-
Assert.assertTrue(matlabRunner.exists());
498-
}
499-
500487
/*
501488
* Test to verify Use Parallel check box present.
502489
*/

src/test/java/integ/com/mathworks/ci/RunMatlabTestsStepTest.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,6 @@ public void verifyExceptionForNonZeroExitCode() throws Exception {
156156
j.assertLogContains(String.format(Message.getValue("matlab.execution.exception.prefix"), 1), build);
157157
}
158158

159-
/*
160-
* Verify .matlab folder created
161-
*/
162-
163-
@Test
164-
public void verifyMATLABtempFolderGenerated() throws Exception {
165-
project.setDefinition(new CpsFlowDefinition(
166-
"node {runMATLABTests(testResultsPDF:'myresult/result.pdf')}", true));
167-
WorkflowRun build = project.scheduleBuild2(0).get();
168-
j.assertLogContains(".matlab", build);
169-
}
170-
171159
/*@Integ Test
172160
* Verify default command options for test Filter using selectByFolder option
173161
*/

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import hudson.Launcher;
1717
import hudson.Launcher.ProcStarter;
1818
import hudson.model.TaskListener;
19+
import hudson.slaves.WorkspaceList;
1920
import hudson.util.ArgumentListBuilder;
2021

2122
import org.junit.Test;
@@ -91,8 +92,10 @@ public void constructorUsesParamsForTempFolder() throws IOException, Interrupted
9192
public void correctTempFolderLocation() throws IOException, InterruptedException {
9293
runner = new MatlabCommandRunner(params);
9394
FilePath tmp = runner.getTempFolder();
94-
FilePath expected = new FilePath(new File(tempDir.getRoot(), ".matlab"));
95+
96+
FilePath expected = WorkspaceList.tempDir(new FilePath(tempDir.getRoot()));
9597

98+
Assert.assertTrue(tmp.exists());
9699
Assert.assertThat(
97100
tmp.getRemote(),
98101
startsWith(expected.getRemote()));

0 commit comments

Comments
 (0)