Skip to content

Commit

Permalink
Install Intel version on Apple silicon prior to R2023b
Browse files Browse the repository at this point in the history
  • Loading branch information
mcafaro committed May 6, 2024
1 parent 6985e68 commit 48b8437
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/bat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ jobs:
products: Symbolic_Math_Toolbox
check-matlab: matlabVer = ver('matlab'); assert(~isempty(matlabVer));
check-toolbox: symbolicVer = ver('symbolic'); assert(~isempty(symbolicVer));
- os: macos-14
release: R2023a
check-matlab: matlabVer = ver('matlab'); assert(strcmp(matlabVer.Release,'(R2023a)'));
check-toolbox: symbolicVer = ver('symbolic'); assert(strcmp(symbolicVer.Release,'(R2023a)'));
steps:
- uses: actions/download-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function install(platform: string, architecture: string, release: s
}

if (!alreadyExists && !cacheHit) {
const mpmPath: string = await mpm.setup(platform, architecture);
const mpmPath: string = await mpm.setup(platform, architecture, releaseInfo.name);
await mpm.install(mpmPath, releaseInfo, products, destination);
}

Expand Down
2 changes: 1 addition & 1 deletion src/matlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export function getSupportPackagesPath(platform: string, release: string): strin
export async function installSystemDependencies(platform: string, architecture: string, release: string) {
if (platform === "linux") {
return script.downloadAndRunScript(platform, properties.matlabDepsUrl, [release]);
} else if (platform === "darwin" && architecture === "arm64") {
} else if (platform === "darwin" && architecture === "arm64" && release >= "r2023b") {
return installAppleSiliconJdk();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/matlab.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ describe("matlab tests", () => {
let tcDownloadToolMock: jest.Mock;
let execMock: jest.Mock;
const arch = "x64";
const release = "R2023b";
const release = "r2023b";

beforeEach(() => {
downloadAndRunScriptMock = script.downloadAndRunScript as jest.Mock;
Expand Down
4 changes: 2 additions & 2 deletions src/mpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as path from "path";
import * as matlab from "./matlab";
import properties from "./properties.json";

export async function setup(platform: string, architecture: string): Promise<string> {
export async function setup(platform: string, architecture: string, release: string): Promise<string> {
let mpmUrl: string;
let ext = "";
if (architecture != "x64" && !(platform == "darwin" && architecture == "arm64")) {
Expand All @@ -21,7 +21,7 @@ export async function setup(platform: string, architecture: string): Promise<str
mpmUrl = properties.mpmRootUrl + "glnxa64/mpm";
break;
case "darwin":
if (architecture == "x64") {
if (architecture == "x64" || release < "r2023b") {
mpmUrl = properties.mpmRootUrl + "maci64/mpm";
} else {
mpmUrl = properties.mpmRootUrl + "maca64/mpm";
Expand Down
19 changes: 10 additions & 9 deletions src/mpm.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe("setup mpm", () => {
let execMock: jest.Mock;
let defaultInstallRootMock: jest.Mock;
const arch = "x64";
const release = "r2023b";
const mpmMockPath = path.join("path", "to", "mpm");

beforeEach(() => {
Expand All @@ -37,41 +38,41 @@ describe("setup mpm", () => {
it(`works on linux`, async () => {
const platform = "linux";
execMock.mockResolvedValue(0);
await expect(mpm.setup(platform, arch)).resolves.toBe(mpmMockPath);
await expect(mpm.setup(platform, arch, release)).resolves.toBe(mpmMockPath);
expect(tcDownloadToolMock.mock.calls[0][0]).toContain("glnxa64");
});

it(`works on windows`, async () => {
const platform = "win32";
tcDownloadToolMock.mockResolvedValue(mpmMockPath);
execMock.mockResolvedValue(0);
await expect(mpm.setup(platform, arch)).resolves.toBe(path.join(mpmMockPath));
await expect(mpm.setup(platform, arch, release)).resolves.toBe(path.join(mpmMockPath));
expect(tcDownloadToolMock.mock.calls[0][0]).toContain("win64");
});

it(`works on mac`, async () => {
const platform = "darwin";
tcDownloadToolMock.mockResolvedValue(mpmMockPath);
execMock.mockResolvedValue(0);
await expect(mpm.setup(platform, arch)).resolves.toBe(path.join(mpmMockPath));
await expect(mpm.setup(platform, arch, release)).resolves.toBe(path.join(mpmMockPath));
expect(tcDownloadToolMock.mock.calls[0][0]).toContain("maci64");
});

it(`works on mac with apple silicon`, async () => {
const platform = "darwin";
execMock.mockResolvedValue(0);
await expect(mpm.setup(platform, "arm64")).resolves.toBe(mpmMockPath);
await expect(mpm.setup(platform, "arm64", release)).resolves.toBe(mpmMockPath);
expect(tcDownloadToolMock.mock.calls[0][0]).toContain("maca64");
});
});

it("errors on unsupported platform", async () => {
await expect(() => mpm.setup('sunos', arch)).rejects.toBeDefined();
await expect(() => mpm.setup('sunos', arch, release)).rejects.toBeDefined();
});

it("errors on unsupported architecture", async () => {
const platform = "linux";
await expect(() => mpm.setup(platform, 'x86')).rejects.toBeDefined();
await expect(() => mpm.setup(platform, 'x86', release)).rejects.toBeDefined();
});

it("errors without RUNNER_TEMP", async () => {
Expand All @@ -80,21 +81,21 @@ describe("setup mpm", () => {
tcDownloadToolMock.mockResolvedValue(mpmMockPath);
defaultInstallRootMock.mockReturnValue(path.join("path", "to", "install", "root"));
execMock.mockResolvedValue(0);
await expect(mpm.setup(platform, arch)).rejects.toBeDefined();
await expect(mpm.setup(platform, arch, release)).rejects.toBeDefined();
});

it("rejects when the download fails", async () => {
const platform = "linux";
tcDownloadToolMock.mockRejectedValue(Error("oof"));
execMock.mockResolvedValue(0);
await expect(mpm.setup(platform, arch)).rejects.toBeDefined();
await expect(mpm.setup(platform, arch, release)).rejects.toBeDefined();
});

it("rejects when the chmod fails", async () => {
const platform = "linux";
tcDownloadToolMock.mockResolvedValue("/path/to/mpm");
execMock.mockResolvedValue(1);
await expect(mpm.setup(platform, arch)).rejects.toBeDefined();
await expect(mpm.setup(platform, arch, release)).rejects.toBeDefined();
});

});
Expand Down

0 comments on commit 48b8437

Please sign in to comment.