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

Commit 079c8ea

Browse files
author
Nikhil Bhoski
committed
Updated as per review
1 parent 78ac049 commit 079c8ea

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ default String getUniqueNameForRunnerFile() {
101101
default void prepareTmpFldr(FilePath tmpFldr, String runnerScript) throws IOException, InterruptedException {
102102
// Write MATLAB scratch file in temp folder.
103103
FilePath scriptFile =
104-
new FilePath(tmpFldr, MatlabBuilderConstants.MATLAB_TEST_RUNNER_FILE_PREFIX
105-
+ tmpFldr.getBaseName().replaceAll("-", "_") + ".m");
104+
new FilePath(tmpFldr, getValidMatlabFileName(tmpFldr.getBaseName()) + ".m");
106105
scriptFile.write(runnerScript, "UTF-8");
107106
// copy genscript package
108107
copyFileInWorkspace(MatlabBuilderConstants.MATLAB_SCRIPT_GENERATOR,
@@ -118,4 +117,9 @@ default String getRunnerScript(String script, String params) {
118117
script = script.replace("${PARAMS}", params);
119118
return script;
120119
}
120+
121+
default String getValidMatlabFileName(String actualName) {
122+
return MatlabBuilderConstants.MATLAB_TEST_RUNNER_FILE_PREFIX
123+
+ actualName.replaceAll("-", "_");
124+
}
121125
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class MatlabBuilderConstants {
3636

3737
// MATLAB runner script
3838
static final String TEST_RUNNER_SCRIPT = "testScript = genscript(${PARAMS});\n" + "\n"
39-
+ "disp('Running MATLAB script with content:\\n');\n"
39+
+ "disp('Running MATLAB script with content:');\n"
4040
+ "disp(strtrim(testScript.writeToText()));\n"
4141
+ "fprintf('___________________________________\\n\\n');\n" + "run(testScript);\n" + "";
4242
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
6262
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
6363
final String cmdPrefix =
6464
"addpath('" + genScriptLocation.getRemote().replaceAll("'", "''") + "'); ";
65-
final String matlabFunctionName = MatlabBuilderConstants.MATLAB_TEST_RUNNER_FILE_PREFIX
66-
+ genScriptLocation.getBaseName().replaceAll("-", "_");
65+
final String matlabScriptName = getValidMatlabFileName(genScriptLocation.getBaseName());
6766

6867
ProcStarter matlabLauncher = getProcessToRunMatlabCommand(workspace, launcher, listener,
69-
envVars, cmdPrefix + matlabFunctionName, uniqueTmpFldrName);
68+
envVars, cmdPrefix + matlabScriptName, uniqueTmpFldrName);
7069

7170
// prepare temp folder by coping genscript package and writing runner script.
7271
prepareTmpFldr(genScriptLocation,

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,9 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
261261
}
262262

263263
public String constructCommandForTest(FilePath scriptPath) {
264-
final String matlabFunctionName = MatlabBuilderConstants.MATLAB_TEST_RUNNER_FILE_PREFIX
265-
+ scriptPath.getBaseName().replaceAll("-", "_");
264+
final String matlabScriptName = getValidMatlabFileName(scriptPath.getBaseName());
266265
final String runCommand = "addpath('" + scriptPath.getRemote().replaceAll("'", "''")
267-
+ "'); " + matlabFunctionName;
266+
+ "'); " + matlabScriptName;
268267
return runCommand;
269268
}
270269

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ private String getInputArgs() {
131131
}
132132
});
133133

134-
if (inputArgs.isEmpty()) {
135-
return "";
136-
}
137-
138134
return String.join(",", inputArgs);
139135
}
140136

0 commit comments

Comments
 (0)