Skip to content

Commit

Permalink
try cacheFile to fix file location
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbuzinski committed Dec 14, 2023
1 parent 8a99c94 commit 506eab2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/mpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ export async function setup(platform: string, architecture: string): Promise<str
}

let mpm: string = await tc.downloadTool(mpmUrl);
let mpmPath= await tc.cacheFile(mpm, `mpm${ext}`, "mpm", "1.0.0");

const exitCode = await exec.exec(`chmod +x ${mpm + ext}`);
const exitCode = await exec.exec(`chmod +x mpmPath`);
if (exitCode !== 0) {
return Promise.reject(Error("Unable to set up mpm."));
}
return mpm
return mpmPath
}

export async function install(mpmPath: string, release: matlab.Release, products: string[], destination: string) {
Expand Down
7 changes: 4 additions & 3 deletions src/mpm.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,39 @@ afterEach(() => {

describe("setup mpm", () => {
let tcDownloadToolMock: jest.Mock;
let tcCacheFileMock: jest.Mock;
let execMock: jest.Mock;
let defaultInstallRootMock: jest.Mock;
const arch = "x64";
const mpmMockPath = path.join("path", "to", "mpm");

beforeEach(() => {
tcDownloadToolMock = tc.downloadTool as jest.Mock;
tcCacheFileMock = tc.cacheFile as jest.Mock;
execMock = exec.exec as jest.Mock;
defaultInstallRootMock = script.defaultInstallRoot as jest.Mock;
tcDownloadToolMock.mockResolvedValue(mpmMockPath);
tcCacheFileMock.mockResolvedValue(mpmMockPath);
process.env.RUNNER_TEMP = path.join("runner", "workdir", "tmp");
});

describe("test on all supported platforms", () => {
it(`works on linux`, async () => {
const platform = "linux";
tcDownloadToolMock.mockResolvedValue(mpmMockPath);
execMock.mockResolvedValue(0);
await expect(mpm.setup(platform, arch)).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(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(mpmMockPath);
expect(tcDownloadToolMock.mock.calls[0][0]).toContain("maci64");
Expand Down

0 comments on commit 506eab2

Please sign in to comment.