summaryrefslogtreecommitdiff
path: root/cli/tests/unit/real_path_test.ts
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-10-07 13:05:43 +0100
committerGitHub <noreply@github.com>2020-10-07 14:05:43 +0200
commitc226d3af2572c93af21f5a3261ede4dd8855685e (patch)
tree43a8e1955b12ddc3b6be274b857921b04f91f89a /cli/tests/unit/real_path_test.ts
parent99aa23b8ddd73ab6332430c2ba7c44792fad3886 (diff)
fix(cli/ops/fs): Don't force Windows paths separate paths with forward slash (#7833)
Diffstat (limited to 'cli/tests/unit/real_path_test.ts')
-rw-r--r--cli/tests/unit/real_path_test.ts37
1 files changed, 21 insertions, 16 deletions
diff --git a/cli/tests/unit/real_path_test.ts b/cli/tests/unit/real_path_test.ts
index d00aed0dd..f82929ed5 100644
--- a/cli/tests/unit/real_path_test.ts
+++ b/cli/tests/unit/real_path_test.ts
@@ -1,20 +1,22 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import {
assert,
+ assertMatch,
assertThrows,
assertThrowsAsync,
unitTest,
} from "./test_util.ts";
unitTest({ perms: { read: true } }, function realPathSyncSuccess(): void {
- const incompletePath = "cli/tests/fixture.json";
- const realPath = Deno.realPathSync(incompletePath);
+ const relative = "cli/tests/fixture.json";
+ const realPath = Deno.realPathSync(relative);
if (Deno.build.os !== "windows") {
assert(realPath.startsWith("/"));
+ assert(realPath.endsWith(relative));
} else {
- assert(/^[A-Z]/.test(realPath));
+ assertMatch(realPath, /^[A-Z]:\\/);
+ assert(realPath.endsWith(relative.replace(/\//g, "\\")));
}
- assert(realPath.endsWith(incompletePath));
});
unitTest(
@@ -27,13 +29,14 @@ unitTest(
const symlink = testDir + "/symln";
Deno.mkdirSync(target);
Deno.symlinkSync(target, symlink);
- const targetPath = Deno.realPathSync(symlink);
+ const realPath = Deno.realPathSync(symlink);
if (Deno.build.os !== "windows") {
- assert(targetPath.startsWith("/"));
+ assert(realPath.startsWith("/"));
+ assert(realPath.endsWith("/target"));
} else {
- assert(/^[A-Z]/.test(targetPath));
+ assertMatch(realPath, /^[A-Z]:\\/);
+ assert(realPath.endsWith("\\target"));
}
- assert(targetPath.endsWith("/target"));
},
);
@@ -52,14 +55,15 @@ unitTest({ perms: { read: true } }, function realPathSyncNotFound(): void {
unitTest({ perms: { read: true } }, async function realPathSuccess(): Promise<
void
> {
- const incompletePath = "cli/tests/fixture.json";
- const realPath = await Deno.realPath(incompletePath);
+ const relativePath = "cli/tests/fixture.json";
+ const realPath = await Deno.realPath(relativePath);
if (Deno.build.os !== "windows") {
assert(realPath.startsWith("/"));
+ assert(realPath.endsWith(relativePath));
} else {
- assert(/^[A-Z]/.test(realPath));
+ assertMatch(realPath, /^[A-Z]:\\/);
+ assert(realPath.endsWith(relativePath.replace(/\//g, "\\")));
}
- assert(realPath.endsWith(incompletePath));
});
unitTest(
@@ -72,13 +76,14 @@ unitTest(
const symlink = testDir + "/symln";
Deno.mkdirSync(target);
Deno.symlinkSync(target, symlink);
- const targetPath = await Deno.realPath(symlink);
+ const realPath = await Deno.realPath(symlink);
if (Deno.build.os !== "windows") {
- assert(targetPath.startsWith("/"));
+ assert(realPath.startsWith("/"));
+ assert(realPath.endsWith("/target"));
} else {
- assert(/^[A-Z]/.test(targetPath));
+ assertMatch(realPath, /^[A-Z]:\\/);
+ assert(realPath.endsWith("\\target"));
}
- assert(targetPath.endsWith("/target"));
},
);