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

Commit 7220a07

Browse files
author
Nikhil Bhoski
committed
consoldiated copy operation
1 parent e0ddf94 commit 7220a07

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher
6565
ProcStarter matlabLauncher = getProcessToRunMatlabCommand(workspace, launcher, listener,
6666
envVars, cmdPrefix + envVars.expand(getCommand()), uniqueTmpFldrName);
6767

68+
//Copy Scratch file needed to run MATLAB tests in workspace
69+
copyFileInWorkspace(MatlabBuilderConstants.MATLAB_TESTS_RUNNER_RESOURCE,
70+
MatlabBuilderConstants.MATLAB_TESTS_RUNNER_TARGET_FILE, workspace);
71+
6872
//prepare temp folder by coping genscript package.
6973
prepareTmpFldr(genScriptLocation);
7074

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

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
package com.mathworks.ci;
2-
/**
3-
* Copyright 2020 The MathWorks, Inc.
4-
*
5-
*/
6-
import java.io.IOException;
7-
import java.io.InputStream;
8-
92
/**
103
* Copyright 2020 The MathWorks, Inc.
114
*
@@ -104,16 +97,9 @@ public void setModelCoverageCobertura(String modelCoverageCobertura) {
10497

10598
@Override
10699
public StepExecution start(StepContext context) throws Exception {
107-
Launcher launcher = context.get(Launcher.class);
108-
FilePath workspace = context.get(FilePath.class);
109-
110-
//Copy Scratch file needed to run MATLAB tests in workspace
111-
FilePath targetWorkspace = new FilePath(launcher.getChannel(), workspace.getRemote());
112-
copyScratchFileInWorkspace(MatlabBuilderConstants.MATLAB_TESTS_RUNNER_RESOURCE,
113-
MatlabBuilderConstants.MATLAB_TESTS_RUNNER_TARGET_FILE, targetWorkspace);
114-
return new MatlabRunTestsStepExecution(context,constructCommandForTest(getInputArgs()));
100+
return new MatlabRunTestsStepExecution(context, constructCommandForTest(getInputArgs()));
115101
}
116-
102+
117103
@Extension
118104
public static class RunTestsStepDescriptor extends StepDescriptor {
119105

@@ -169,17 +155,4 @@ private Map<String, String> getMatlabArgs() {
169155
args.put("CoberturaModelCoveragePath", getModelCoverageCobertura());
170156
return args;
171157
}
172-
173-
/*
174-
* Method to copy given file from source to target node specific workspace.
175-
*/
176-
private void copyScratchFileInWorkspace(String sourceFile, String targetFile, FilePath targetWorkspace)
177-
throws IOException, InterruptedException {
178-
final ClassLoader classLoader = getClass().getClassLoader();
179-
FilePath targetFilePath = new FilePath(targetWorkspace, targetFile);
180-
InputStream in = classLoader.getResourceAsStream(sourceFile);
181-
targetFilePath.copyFrom(in);
182-
// set executable permission
183-
targetFilePath.chmod(0755);
184-
}
185158
}

0 commit comments

Comments
 (0)