-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from matlab-actions/windows-and-macos
Add limited, undocumented, Windows and macOS support
- Loading branch information
Showing
5 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2022 The MathWorks, Inc. | ||
|
||
import fs from "fs"; | ||
import path from "path"; | ||
import os from "os"; | ||
import * as core from "@actions/core"; | ||
|
||
export const rootFile = path.join(os.tmpdir(), "ephemeral_matlab_root"); | ||
|
||
export function addToPath() { | ||
let root: string; | ||
try { | ||
root = fs.readFileSync(rootFile).toString(); | ||
} catch (err) { | ||
throw new Error(`Unable to read file containing MATLAB root: ${err.message}`); | ||
} | ||
core.addPath(path.join(root, "bin")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2022 The MathWorks, Inc. | ||
|
||
import * as core from "@actions/core"; | ||
import * as fs from "fs"; | ||
import * as ematlab from "./ematlab"; | ||
|
||
jest.mock("@actions/core"); | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
describe("ephemeral matlab", () => { | ||
let addPathMock = core.addPath as jest.Mock; | ||
|
||
beforeEach(() => { | ||
addPathMock = core.addPath as jest.Mock; | ||
if (fs.existsSync(ematlab.rootFile)) { | ||
fs.unlinkSync(ematlab.rootFile); | ||
} | ||
}); | ||
|
||
it("ideally works", async () => { | ||
fs.writeFileSync(ematlab.rootFile, "path/to/matlab"); | ||
ematlab.addToPath(); | ||
expect(addPathMock).toBeCalledWith("path/to/matlab/bin"); | ||
}); | ||
|
||
it("rejects when root file does not exist", async () => { | ||
expect(() => ematlab.addToPath()).toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters