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

Commit 52049e2

Browse files
author
Nikhil Bhoski
committed
Removed src folder and addpath
1 parent 4aef46a commit 52049e2

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
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-
"addpath('" + genScriptLocation.getRemote().replaceAll("'", "''") + "'); ";
64+
"cd('" + 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ 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 = "addpath('" + scriptPath.getRemote().replaceAll("'", "''")
266-
+ "'); " + matlabFunctionName + "(" + inputArguments + ")";
265+
final String runCommand = "cd('" + scriptPath.getRemote().replaceAll("'", "''") + "'); "
266+
+ matlabFunctionName + "(" + inputArguments + ")";
267267
return runCommand;
268268
}
269269

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
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+
512
p = inputParser;
613
validationFcn = @(c)ischar(c) && (isempty(c) || isrow(c));
714

@@ -21,16 +28,13 @@ function runMatlabTests(varargin)
2128
coberturaReportPath = p.Results.CoberturaCodeCoveragePath;
2229
modelCoveragePath = p.Results.CoberturaModelCoveragePath;
2330

24-
srcFldr = getenv('WORKSPACE');
25-
2631
testScript = genscript('Test',...
2732
'PDFTestReport',pdfReportPath,...
2833
'TAPTestResults',tapReportPath,...
2934
'JUnitTestResults',junitReportPath,...
3035
'SimulinkTestResults',stmReportPath,...
3136
'CoberturaCodeCoverage',coberturaReportPath,...
32-
'CoberturaModelCoverage',modelCoveragePath,...
33-
'SourceFolder',srcFldr);
37+
'CoberturaModelCoverage',modelCoveragePath);
3438

3539
disp('Running MATLAB script with content:\n');
3640
disp(strtrim(testScript.writeToText()));

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("addpath(", build);
144+
jenkins.assertLogContains("cd(", 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("addpath(", build);
90+
j.assertLogContains("cd(", build);
9191
j.assertLogContains("test_runner", build);
9292
}
9393

0 commit comments

Comments
 (0)