mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-05-16 05:49:53 +02:00
Run tar with sudo [actions/cache#133]
This commit is contained in:
parent
78a4b2143b
commit
1e5552f09c
2 changed files with 24 additions and 17 deletions
|
@ -25,14 +25,15 @@ test("extract tar", async () => {
|
|||
const tarPath = IS_WINDOWS
|
||||
? `${process.env["windir"]}\\System32\\tar.exe`
|
||||
: "tar";
|
||||
let tarParams = ["-xz", "-f", archivePath, "-C", targetDirectory];
|
||||
let tarExec = `${tarPath}`;
|
||||
if (!IS_WINDOWS) {
|
||||
tarExec = "sudo";
|
||||
tarParams = [`${tarPath}`, ...tarParams];
|
||||
}
|
||||
|
||||
expect(execMock).toHaveBeenCalledTimes(1);
|
||||
expect(execMock).toHaveBeenCalledWith(`"${tarPath}"`, [
|
||||
"-xz",
|
||||
"-f",
|
||||
archivePath,
|
||||
"-C",
|
||||
targetDirectory
|
||||
]);
|
||||
expect(execMock).toHaveBeenCalledWith(`"${tarExec}"`, tarParams);
|
||||
});
|
||||
|
||||
test("create tar", async () => {
|
||||
|
@ -46,13 +47,13 @@ test("create tar", async () => {
|
|||
const tarPath = IS_WINDOWS
|
||||
? `${process.env["windir"]}\\System32\\tar.exe`
|
||||
: "tar";
|
||||
let tarParams = ["-cz", "-f", archivePath, "-C", sourceDirectory, "."];
|
||||
let tarExec = `${tarPath}`;
|
||||
if (!IS_WINDOWS) {
|
||||
tarExec = "sudo";
|
||||
tarParams = [`${tarPath}`, ...tarParams];
|
||||
}
|
||||
|
||||
expect(execMock).toHaveBeenCalledTimes(1);
|
||||
expect(execMock).toHaveBeenCalledWith(`"${tarPath}"`, [
|
||||
"-cz",
|
||||
"-f",
|
||||
archivePath,
|
||||
"-C",
|
||||
sourceDirectory,
|
||||
"."
|
||||
]);
|
||||
expect(execMock).toHaveBeenCalledWith(`"${tarExec}"`, tarParams);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue