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

Commit 37a550d

Browse files
authored
Merge pull request #330 from mathworks/mac_arm
Update run-matlab-command version, add maca support
2 parents b6b89af + 9663700 commit 37a550d

File tree

3 files changed

+65
-13
lines changed

3 files changed

+65
-13
lines changed

pom.xml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,35 +124,49 @@
124124
<goal>wget</goal>
125125
</goals>
126126
<configuration>
127-
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v1/glnxa64/run-matlab-command</url>
127+
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command</url>
128128
<unpack>false</unpack>
129129
<outputDirectory>${basedir}/src/main/resources/glnxa64</outputDirectory>
130130
<skipCache>true</skipCache>
131131
<overwrite>true</overwrite>
132132
</configuration>
133133
</execution>
134134
<execution>
135-
<id>get-matlab-runner-mac</id>
135+
<id>get-matlab-runner-maci</id>
136136
<phase>validate</phase>
137137
<goals>
138138
<goal>wget</goal>
139139
</goals>
140140
<configuration>
141-
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v1/maci64/run-matlab-command</url>
141+
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/maci64/run-matlab-command</url>
142142
<unpack>false</unpack>
143143
<outputDirectory>${basedir}/src/main/resources/maci64</outputDirectory>
144144
<skipCache>true</skipCache>
145145
<overwrite>true</overwrite>
146146
</configuration>
147147
</execution>
148+
<execution>
149+
<id>get-matlab-runner-maca</id>
150+
<phase>validate</phase>
151+
<goals>
152+
<goal>wget</goal>
153+
</goals>
154+
<configuration>
155+
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/maca64/run-matlab-command</url>
156+
<unpack>false</unpack>
157+
<outputDirectory>${basedir}/src/main/resources/maca64</outputDirectory>
158+
<skipCache>true</skipCache>
159+
<overwrite>true</overwrite>
160+
</configuration>
161+
</execution>
148162
<execution>
149163
<id>get-matlab-runner-windows</id>
150164
<phase>validate</phase>
151165
<goals>
152166
<goal>wget</goal>
153167
</goals>
154168
<configuration>
155-
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v1/win64/run-matlab-command.exe</url>
169+
<url>https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/win64/run-matlab-command.exe</url>
156170
<unpack>false</unpack>
157171
<outputDirectory>${basedir}/src/main/resources/win64</outputDirectory>
158172
<skipCache>true</skipCache>

src/main/java/com/mathworks/ci/utilities/MatlabCommandRunner.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public MatlabCommandRunner(MatlabActionParameters params) throws IOException, In
6868
*/
6969
public void runMatlabCommand(String command) throws IOException, InterruptedException, MatlabExecutionException {
7070

71+
System.err.println("START");
72+
7173
this.params.getTaskListener().getLogger()
7274
.println("\n#################### Starting command output ####################");
7375

@@ -191,15 +193,24 @@ protected FilePath prepareRunnerExecutable() throws IOException, InterruptedExce
191193
if (launcher.isUnix()) {
192194
// Run uname to check if we're on Linux
193195
ByteArrayOutputStream kernelStream = new ByteArrayOutputStream();
196+
197+
ArgumentListBuilder args = new ArgumentListBuilder();
198+
args.add("uname");
199+
args.add("-s");
200+
args.add("-m");
201+
194202
launcher.launch()
195-
.cmds("uname")
196-
.masks(true)
203+
.cmds(args)
204+
.masks(true, true, true)
197205
.stdout(kernelStream)
198206
.join();
199207

200208
String runnerSource;
201-
if (kernelStream.toString("UTF-8").contains("Linux")) {
209+
String kernelArch = kernelStream.toString("UTF-8");
210+
if (kernelArch.contains("Linux")) {
202211
runnerSource = "glnxa64/run-matlab-command";
212+
} else if (kernelArch.contains("arm64")) {
213+
runnerSource = "maca64/run-matlab-command";
203214
} else {
204215
runnerSource = "maci64/run-matlab-command";
205216
}

src/test/java/unit/com/mathworks/ci/utilities/MatlabCommandRunnerTest.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ public void initialize() throws IOException, InterruptedException {
6666

6767
doReturn(false).when(launcher).isUnix();
6868
when(launcher.launch()).thenReturn(procStarter);
69-
when(procStarter.cmds(anyString())).thenReturn(procStarter);
7069
when(procStarter.cmds(any(ArgumentListBuilder.class))).thenReturn(procStarter);
71-
when(procStarter.masks(anyBoolean())).thenReturn(procStarter);
70+
when(procStarter.masks(anyBoolean(), anyBoolean(), anyBoolean()))
71+
.thenReturn(procStarter);
7272
when(procStarter.envs(any(EnvVars.class))).thenReturn(procStarter);
7373
doReturn(procStarter).when(procStarter)
7474
.stdout(any(OutputStream.class));
@@ -99,7 +99,23 @@ public void correctTempFolderLocation() throws IOException, InterruptedException
9999
}
100100

101101
@Test
102-
public void prepareRunnerExecutableLinux() throws IOException, InterruptedException {
102+
public void prepareRunnerExecutableMaci() throws IOException, InterruptedException {
103+
runner = new MatlabCommandRunner(params);
104+
105+
doReturn(true).when(launcher).isUnix();
106+
107+
FilePath f = runner.prepareRunnerExecutable();
108+
109+
Assert.assertTrue(f.exists());
110+
Assert.assertEquals(
111+
runner.getTempFolder().getRemote()
112+
+ File.separator
113+
+ "run-matlab-command",
114+
f.getRemote());
115+
}
116+
117+
@Test
118+
public void prepareRunnerExecutableMaca() throws IOException, InterruptedException {
103119
runner = new MatlabCommandRunner(params);
104120

105121
doReturn(true).when(launcher).isUnix();
@@ -109,7 +125,7 @@ public Object answer(InvocationOnMock invocation) throws IOException {
109125
Object[] args = invocation.getArguments();
110126
OutputStream s = (OutputStream)args[0];
111127

112-
String tag = "Linux";
128+
String tag = "arm64";
113129
s.write(tag.getBytes());
114130
return procStarter;
115131
}
@@ -126,10 +142,21 @@ public Object answer(InvocationOnMock invocation) throws IOException {
126142
}
127143

128144
@Test
129-
public void prepareRunnerExecutableMac() throws IOException, InterruptedException {
145+
public void prepareRunnerExecutableLinux() throws IOException, InterruptedException {
130146
runner = new MatlabCommandRunner(params);
131147

132-
doReturn(true).when(launcher).isUnix();
148+
doReturn(true).when(launcher).isUnix();
149+
when(procStarter.stdout(any(OutputStream.class))).thenAnswer(
150+
new Answer() {
151+
public Object answer(InvocationOnMock invocation) throws IOException {
152+
Object[] args = invocation.getArguments();
153+
OutputStream s = (OutputStream)args[0];
154+
155+
String tag = "Linux";
156+
s.write(tag.getBytes());
157+
return procStarter;
158+
}
159+
});
133160

134161
FilePath f = runner.prepareRunnerExecutable();
135162

0 commit comments

Comments
 (0)