1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-03 12:58:54 -05:00

Fix readLinkSync and readLink tests on Windows (#6463)

This commit is contained in:
Casper Beyer 2020-06-25 19:27:23 +08:00 committed by GitHub
parent 16038b8f82
commit a455a0babf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,16 +10,14 @@ unitTest(
{ perms: { write: true, read: true } }, { perms: { write: true, read: true } },
function readLinkSyncSuccess(): void { function readLinkSyncSuccess(): void {
const testDir = Deno.makeTempDirSync(); const testDir = Deno.makeTempDirSync();
const target = testDir + "/target"; const target =
const symlink = testDir + "/symln"; testDir + (Deno.build.os == "windows" ? "\\target" : "/target");
const symlink =
testDir + (Deno.build.os == "windows" ? "\\symlink" : "/symlink");
Deno.mkdirSync(target); Deno.mkdirSync(target);
// TODO Add test for Windows once symlink is implemented for Windows. Deno.symlinkSync(target, symlink);
// See https://github.com/denoland/deno/issues/815. const targetPath = Deno.readLinkSync(symlink);
if (Deno.build.os !== "windows") { assertEquals(targetPath, target);
Deno.symlinkSync(target, symlink);
const targetPath = Deno.readLinkSync(symlink);
assertEquals(targetPath, target);
}
} }
); );
@ -39,16 +37,14 @@ unitTest(
{ perms: { write: true, read: true } }, { perms: { write: true, read: true } },
async function readLinkSuccess(): Promise<void> { async function readLinkSuccess(): Promise<void> {
const testDir = Deno.makeTempDirSync(); const testDir = Deno.makeTempDirSync();
const target = testDir + "/target"; const target =
const symlink = testDir + "/symln"; testDir + (Deno.build.os == "windows" ? "\\target" : "/target");
const symlink =
testDir + (Deno.build.os == "windows" ? "\\symlink" : "/symlink");
Deno.mkdirSync(target); Deno.mkdirSync(target);
// TODO Add test for Windows once symlink is implemented for Windows. Deno.symlinkSync(target, symlink);
// See https://github.com/denoland/deno/issues/815. const targetPath = await Deno.readLink(symlink);
if (Deno.build.os !== "windows") { assertEquals(targetPath, target);
Deno.symlinkSync(target, symlink);
const targetPath = await Deno.readLink(symlink);
assertEquals(targetPath, target);
}
} }
); );