forked from microsoft/vscode-java-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpathUtil.test.ts
More file actions
65 lines (52 loc) · 2.78 KB
/
Copy pathpathUtil.test.ts
File metadata and controls
65 lines (52 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as assert from "assert";
import { buildNoConfigPathAppendValue } from "../src/pathUtil";
// Regression tests for issue #1637.
suite("buildNoConfigPathAppendValue", () => {
const winDir = "C:\\Users\\me\\.vscode\\extensions\\vscjava.vscode-java-debug-0.59.0\\bundled\\scripts\\noConfigScripts";
const posixDir = "/home/me/.vscode/extensions/vscjava.vscode-java-debug-0.59.0/bundled/scripts/noConfigScripts";
test("uses ';' as separator on Windows", () => {
const result = buildNoConfigPathAppendValue(winDir, "win32");
assert.strictEqual(result, `;${winDir}`);
});
test("uses ':' as separator on Linux", () => {
const result = buildNoConfigPathAppendValue(posixDir, "linux");
assert.strictEqual(result, `:${posixDir}`);
});
test("uses ':' as separator on macOS", () => {
const result = buildNoConfigPathAppendValue(posixDir, "darwin");
assert.strictEqual(result, `:${posixDir}`);
});
test("always starts with a path separator (Windows)", () => {
const result = buildNoConfigPathAppendValue(winDir, "win32");
assert.ok(result.startsWith(";"));
});
test("always starts with a path separator (POSIX)", () => {
const result = buildNoConfigPathAppendValue(posixDir, "linux");
assert.ok(result.startsWith(":"));
});
test("never collapses scriptsDir into the previous PATH entry on Windows", () => {
// #1637 scenario: last user PATH entry has no trailing separator.
const userPath = "C:\\foo;C:\\Program Files\\jreleaser\\";
const entries = (userPath + buildNoConfigPathAppendValue(winDir, "win32")).split(";");
assert.ok(entries.includes("C:\\Program Files\\jreleaser\\"));
assert.ok(entries.includes(winDir));
});
test("never collapses scriptsDir into the previous PATH entry on POSIX", () => {
const userPath = "/usr/bin:/opt/jreleaser/bin";
const entries = (userPath + buildNoConfigPathAppendValue(posixDir, "linux")).split(":");
assert.ok(entries.includes("/opt/jreleaser/bin"));
assert.ok(entries.includes(posixDir));
});
test("yields only an empty (harmless) entry when the user's PATH already ends with a separator", () => {
const userPath = "C:\\foo;C:\\bar;";
const entries = (userPath + buildNoConfigPathAppendValue(winDir, "win32")).split(";");
assert.ok(entries.includes(winDir));
assert.ok(!entries.some((e) => e !== winDir && e.endsWith(winDir)));
});
test("scriptsDir appears unchanged at the end of the appended value", () => {
const result = buildNoConfigPathAppendValue(winDir, "win32");
assert.ok(result.endsWith(winDir));
});
});