diff options
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)); + }, +); |