diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-01-14 05:45:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-14 13:45:30 +0000 |
commit | ae2981d7acea79f3513b273ccf1cd2dc9d4dbbda (patch) | |
tree | 3a0110344f84ac40fe714d8b2d26de06577522aa /cli/tests | |
parent | 68782346d0fb8146ab0eb9e9f4fbd0900d62a85d (diff) |
fix(runtime/fs): preserve permissions in copyFileSync for macOS (#17412)
Fixes https://github.com/denoland/deno/issues/16921
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/copy_file_test.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cli/tests/unit/copy_file_test.ts b/cli/tests/unit/copy_file_test.ts index c53f2601b..5e77b0dca 100644 --- a/cli/tests/unit/copy_file_test.ts +++ b/cli/tests/unit/copy_file_test.ts @@ -209,3 +209,30 @@ Deno.test( }, Deno.errors.PermissionDenied); }, ); + +function copyFileSyncMode(content: string): void { + const tempDir = Deno.makeTempDirSync(); + const fromFilename = tempDir + "/from.txt"; + const toFilename = tempDir + "/to.txt"; + Deno.writeTextFileSync(fromFilename, content); + Deno.chmodSync(fromFilename, 0o100755); + + Deno.copyFileSync(fromFilename, toFilename); + const toStat = Deno.statSync(toFilename); + assertEquals(toStat.mode!, 0o100755); +} + +Deno.test( + { + ignore: Deno.build.os === "windows", + permissions: { read: true, write: true }, + }, + function copyFileSyncChmod() { + // this Tests different optimization paths on MacOS: + // + // < 128 KB clonefile() w/ fallback to copyfile() + // > 128 KB + copyFileSyncMode("Hello world!"); + copyFileSyncMode("Hello world!".repeat(128 * 1024)); + }, +); |