Skip to content

Commit

Permalink
Fixed windows-specific uri tests, added wrongly ignored files
Browse files Browse the repository at this point in the history
  • Loading branch information
andersnm committed Jun 16, 2024
1 parent 3ae315e commit 9ad7121
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
**/.vscode-test
**/out
**/dist
packages/*/out
packages/*/dist
**/*.vsix
31 changes: 22 additions & 9 deletions packages/vscode-sourcemap-helper-test/src/uri.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ suite("Uri sanity checks", () => {
});

test("Uri.file() with Windows path with backslash", () => {
// Observation: Normalizes drive letter and slashes
// Observation: Normalizes drive letter and slashes on Windows, not other OS
let uri = vscode.Uri.file("C:\\test\\file.txt")
assert.equal("file:///c:/test/file.txt", uri.toString(true));
if (process.platform === "win32") {
assert.equal("file:///c:/test/file.txt", uri.toString(true));
} else {
assert.equal("file:///c:\\test\\file.txt", uri.toString(true));
}
});

test("Uri.file() with Windows path with frontslash", () => {
Expand All @@ -41,13 +45,16 @@ suite("Uri sanity checks", () => {
});

test("Uri.parse() with incorrect two-slash Windows path", () => {
// Observation: "C:" becomes the authority, fsPath resolves UNC-path to "C:" host
// Observation: "C:" becomes the authority, fsPath resolves UNC-path to "C:" host on Windows
let uri = vscode.Uri.parse("file://C:/test/dir/file.txt")
assert.equal("C:", uri.authority);
assert.equal("/test/dir/file.txt", uri.path, "path");

// TODO; Backslashes here are prob windows-only
assert.equal("\\\\C:\\test\\dir\\file.txt", uri.fsPath, "fsPath");
if (process.platform === "win32") {
assert.equal("\\\\C:\\test\\dir\\file.txt", uri.fsPath, "fsPath");
} else {
assert.equal("//C:/test/dir/file.txt", uri.fsPath, "fsPath");
}

assert.equal("file://c:/test/dir/file.txt", uri.toString(true));
})
Expand All @@ -58,8 +65,11 @@ suite("Uri sanity checks", () => {
assert.equal("", uri.authority, "authority");
assert.equal("/C:/test/dir/file.txt", uri.path, "path");

// TODO; Backslashes here are prob windows-only
assert.equal("c:\\test\\dir\\file.txt", uri.fsPath, "fsPath");
if (process.platform === "win32") {
assert.equal("c:\\test\\dir\\file.txt", uri.fsPath, "fsPath");
} else {
assert.equal("c:/test/dir/file.txt", uri.fsPath, "fsPath");
}

assert.equal("file:///c:/test/dir/file.txt", uri.toString(true));
})
Expand All @@ -70,8 +80,11 @@ suite("Uri sanity checks", () => {
assert.equal("", uri.authority, "authority");
assert.equal("/dir/file.txt", uri.path, "path");

// TODO; Backslashes here are prob windows-only
assert.equal("\\dir\\file.txt", uri.fsPath, "fsPath");
if (process.platform === "win32") {
assert.equal("\\dir\\file.txt", uri.fsPath, "fsPath");
} else {
assert.equal("/dir/file.txt", uri.fsPath, "fsPath");
}

assert.equal("file:///dir/file.txt", uri.toString(true));
});
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9ad7121

Please sign in to comment.