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

Commit cb5e71f

Browse files
authored
Fix Java Temp Path discrepancy for Window (#122)
* Fix Java temp path discrepancy * Fix Java temp path discrepancy * Fix Java temp dir discrepancy * Fix test for temp dir discrepancy * Fix Java temp path discrepancy * Fix Java temp dir path discrepancy * Fix temp path issue_Incorporate reviews * Fix temp path discrepancy_use computer channel
1 parent 2ea8a8d commit cb5e71f

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,21 @@ default FilePath getFilePathForUniqueFolder(Launcher launcher, String uniqueName
7676
* https://javadoc.jenkins-ci.org/jenkins/tasks/SimpleBuildStep.html */
7777

7878
String tmpDir = getNodeSpecificTmpFolderPath(workspace);
79-
return new FilePath(launcher.getChannel(), tmpDir+"/"+uniqueName);
79+
80+
return new FilePath(launcher.getChannel(), tmpDir + "/" + uniqueName);
8081
}
8182

8283
default String getNodeSpecificTmpFolderPath(FilePath workspace) throws IOException, InterruptedException {
8384
Computer cmp = workspace.toComputer();
8485
if (cmp == null) {
8586
throw new IOException(Message.getValue("build.workspace.computer.not.found"));
8687
}
87-
String tmpDir = (String) cmp.getSystemProperties().get("java.io.tmpdir");
88-
return tmpDir;
88+
89+
String tmpDirPath = (String) cmp.getSystemProperties().get("java.io.tmpdir");
90+
91+
// Invoke FilePath.normalize for clean file path on any channel.
92+
FilePath tmpDir = new FilePath(cmp.getChannel(), tmpDirPath);
93+
return tmpDir.getRemote();
8994
}
9095

9196
default String getUniqueNameForRunnerFile() {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ public void verifyCommandSupportsEnvVar() throws Exception {
249249

250250
/*
251251
* Test to verify if appropriate MATALB runner file is copied in workspace.
252+
*
253+
* NOTE: This test assumes there is no MATLAB installed and is not on System Path.
254+
*
252255
*/
253256
@Test
254257
public void verifyMATLABrunnerFileGenerated() throws Exception {
@@ -262,6 +265,9 @@ public void verifyMATLABrunnerFileGenerated() throws Exception {
262265

263266
/*
264267
* Test to verify if Matrix build fails when MATLAB is not available.
268+
*
269+
* NOTE: This test assumes there is no MATLAB installed and is not on System Path.
270+
*
265271
*/
266272
@Test
267273
public void verifyMatrixBuildFails() throws Exception {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ public void veriyEmptyParameters() throws Exception {
334334

335335
/*
336336
* Test to verify if appropriate MATALB runner file is copied in workspace.
337+
*
338+
* NOTE: This test assumes there is no MATLAB installed and is not on System Path.
339+
*
337340
*/
338341
@Test
339342
public void verifyMATLABrunnerFileGeneratedForAutomaticOption() throws Exception {
@@ -346,6 +349,9 @@ public void verifyMATLABrunnerFileGeneratedForAutomaticOption() throws Exception
346349

347350
/*
348351
* Test to verify if Matrix build fails when MATLAB is not available.
352+
*
353+
* NOTE: This test assumes there is no MATLAB installed and is not on System Path.
354+
*
349355
*/
350356
@Test
351357
public void verifyMatrixBuildFails() throws Exception {

0 commit comments

Comments
 (0)