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

Commit 1ed84b0

Browse files
author
Nikhil Bhoski
committed
Changed to addpath approach
1 parent 52049e2 commit 1ed84b0

File tree

5 files changed

+4
-11
lines changed

5 files changed

+4
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
6161
FilePath genScriptLocation =
6262
getFilePathForUniqueFolder(launcher, uniqueTmpFldrName, workspace);
6363
final String cmdPrefix =
64-
"cd('" + genScriptLocation.getRemote().replaceAll("'", "''") + "'); ";
64+
"addpath('" + genScriptLocation.getRemote().replaceAll("'", "''") + "'); ";
6565
final String matlabFunctionName = MatlabBuilderConstants.MATLAB_TEST_RUNNER_FILE_PREFIX
6666
+ genScriptLocation.getBaseName().replaceAll("-", "_");
6767

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
262262
public String constructCommandForTest(String inputArguments, FilePath scriptPath) {
263263
final String matlabFunctionName = MatlabBuilderConstants.MATLAB_TEST_RUNNER_FILE_PREFIX
264264
+ scriptPath.getBaseName().replaceAll("-", "_");
265-
final String runCommand = "cd('" + scriptPath.getRemote().replaceAll("'", "''") + "'); "
265+
final String runCommand = "addpath('" + scriptPath.getRemote().replaceAll("'", "''") + "'); "
266266
+ matlabFunctionName + "(" + inputArguments + ")";
267267
return runCommand;
268268
}

src/main/resources/com/mathworks/ci/RunMatlabTestsBuilder/runMatlabTests.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22

33
function runMatlabTests(varargin)
44

5-
addpath(pwd);
6-
7-
%Back to the workspace folder
8-
workspace = getenv('WORKSPACE');
9-
cd(workspace);
10-
11-
125
p = inputParser;
136
validationFcn = @(c)ischar(c) && (isempty(c) || isrow(c));
147

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void verifyMATLABlaunchedWithDefaultArgumentsBatch() throws Exception {
141141
FreeStyleBuild build = project.scheduleBuild2(0).get();
142142
jenkins.assertLogContains("run_matlab_command", build);
143143
jenkins.assertLogContains("test_runner", build);
144-
jenkins.assertLogContains("cd(", build);
144+
jenkins.assertLogContains("addpath(", build);
145145
}
146146

147147
/*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void verifyCmdOptions() throws Exception {
8787
project.setDefinition(new CpsFlowDefinition(
8888
"node {runMATLABTests(testResultsPDF:'myresult/result.pdf')}", true));
8989
WorkflowRun build = project.scheduleBuild2(0).get();
90-
j.assertLogContains("cd(", build);
90+
j.assertLogContains("addpath(", build);
9191
j.assertLogContains("test_runner", build);
9292
}
9393

0 commit comments

Comments
 (0)