mirror of
https://github.com/actions/cache.git
synced 2025-04-22 03:56:45 +00:00
Fallback to which tar if no system tar
This commit is contained in:
parent
6199b9ad63
commit
1569e37d6f
2 changed files with 26 additions and 18 deletions
|
@ -6,17 +6,11 @@ jest.mock("@actions/exec");
|
|||
jest.mock("@actions/io");
|
||||
|
||||
beforeAll(() => {
|
||||
process.env["windir"] = "C:";
|
||||
|
||||
jest.spyOn(io, "which").mockImplementation(tool => {
|
||||
return Promise.resolve(tool);
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
delete process.env["windir"];
|
||||
});
|
||||
|
||||
test("extract tar", async () => {
|
||||
const mkdirMock = jest.spyOn(io, "mkdirP");
|
||||
const execMock = jest.spyOn(exec, "exec");
|
||||
|
@ -28,7 +22,7 @@ test("extract tar", async () => {
|
|||
expect(mkdirMock).toHaveBeenCalledWith(targetDirectory);
|
||||
|
||||
const IS_WINDOWS = process.platform === "win32";
|
||||
const tarPath = IS_WINDOWS ? "C:\\System32\\tar.exe" : "tar";
|
||||
const tarPath = IS_WINDOWS ? `${process.env["windir"]}\\System32\\tar.exe` : "tar";
|
||||
expect(execMock).toHaveBeenCalledTimes(1);
|
||||
expect(execMock).toHaveBeenCalledWith(`"${tarPath}"`, [
|
||||
"-xz",
|
||||
|
@ -47,7 +41,7 @@ test("create tar", async () => {
|
|||
await tar.createTar(archivePath, sourceDirectory);
|
||||
|
||||
const IS_WINDOWS = process.platform === "win32";
|
||||
const tarPath = IS_WINDOWS ? "C:\\System32\\tar.exe" : "tar";
|
||||
const tarPath = IS_WINDOWS ? `${process.env["windir"]}\\System32\\tar.exe` : "tar";
|
||||
expect(execMock).toHaveBeenCalledTimes(1);
|
||||
expect(execMock).toHaveBeenCalledWith(`"${tarPath}"`, [
|
||||
"-cz",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue