From 9ad7121593bc87dd98ffc5310a3feefe9d6bd1dd Mon Sep 17 00:00:00 2001 From: andersnm Date: Sun, 16 Jun 2024 12:08:32 +0200 Subject: [PATCH] Fixed windows-specific uri tests, added wrongly ignored files --- .gitignore | 4 +-- .../src/uri.test.ts | 31 +++++++++++++------ .../test-workspace/with_src_out/out/min.js | 3 ++ .../with_src_out/out/min.js.map | 9 ++++++ .../with_src_out_no_sourceRoot/out/min.js | 3 ++ .../with_src_out_no_sourceRoot/out/min.js.map | 8 +++++ 6 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 packages/vscode-sourcemap-helper-test/test-workspace/with_src_out/out/min.js create mode 100644 packages/vscode-sourcemap-helper-test/test-workspace/with_src_out/out/min.js.map create mode 100644 packages/vscode-sourcemap-helper-test/test-workspace/with_src_out_no_sourceRoot/out/min.js create mode 100644 packages/vscode-sourcemap-helper-test/test-workspace/with_src_out_no_sourceRoot/out/min.js.map diff --git a/.gitignore b/.gitignore index 9c78eae..43b30d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ node_modules **/.vscode-test -**/out -**/dist +packages/*/out +packages/*/dist **/*.vsix diff --git a/packages/vscode-sourcemap-helper-test/src/uri.test.ts b/packages/vscode-sourcemap-helper-test/src/uri.test.ts index c5a6bcd..e52a465 100644 --- a/packages/vscode-sourcemap-helper-test/src/uri.test.ts +++ b/packages/vscode-sourcemap-helper-test/src/uri.test.ts @@ -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", () => { @@ -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)); }) @@ -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)); }) @@ -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)); }); diff --git a/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out/out/min.js b/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out/out/min.js new file mode 100644 index 0000000..07256cb --- /dev/null +++ b/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out/out/min.js @@ -0,0 +1,3 @@ +ONE.foo=function(a){return baz(a);}; +TWO.inc=function(a){return a+1;}; +//# sourceMappingURL=min.js.map \ No newline at end of file diff --git a/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out/out/min.js.map b/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out/out/min.js.map new file mode 100644 index 0000000..6bf2247 --- /dev/null +++ b/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out/out/min.js.map @@ -0,0 +1,9 @@ +{ + "version": 3, + "file": "min.js", + "names": ["bar", "baz", "n"], + "sources": ["one.js", "two.js"], + "sourceRoot": "../src", + "mappings": + "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA" +} \ No newline at end of file diff --git a/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out_no_sourceRoot/out/min.js b/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out_no_sourceRoot/out/min.js new file mode 100644 index 0000000..07256cb --- /dev/null +++ b/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out_no_sourceRoot/out/min.js @@ -0,0 +1,3 @@ +ONE.foo=function(a){return baz(a);}; +TWO.inc=function(a){return a+1;}; +//# sourceMappingURL=min.js.map \ No newline at end of file diff --git a/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out_no_sourceRoot/out/min.js.map b/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out_no_sourceRoot/out/min.js.map new file mode 100644 index 0000000..f4c7ee1 --- /dev/null +++ b/packages/vscode-sourcemap-helper-test/test-workspace/with_src_out_no_sourceRoot/out/min.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "file": "min.js", + "names": ["bar", "baz", "n"], + "sources": ["../src/one.js", "../src/two.js"], + "mappings": + "CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA" +} \ No newline at end of file