summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-01-14 05:45:30 -0800
committerGitHub <noreply@github.com>2023-01-14 13:45:30 +0000
commitae2981d7acea79f3513b273ccf1cd2dc9d4dbbda (patch)
tree3a0110344f84ac40fe714d8b2d26de06577522aa /cli/tests
parent68782346d0fb8146ab0eb9e9f4fbd0900d62a85d (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.ts27
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));
+ },
+);