Skip to content

Commit f54e5e3

Browse files
committed
Normalize file paths in PackageDependencyProvider tests
1 parent 05bc130 commit f54e5e3

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

.vscode-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
const { defineConfig } = require("@vscode/test-cli");
1616
const path = require("path");
1717

18-
const isCIBuild = false; // process.env["CI"] === "1";
18+
const isCIBuild = process.env["CI"] === "1";
1919
const isFastTestRun = process.env["FAST_TEST_RUN"] === "1";
2020

2121
// "env" in launch.json doesn't seem to work with vscode-test

test/integration-tests/ui/PackageDependencyProvider.test.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import { expect } from "chai";
16+
import * as vscode from "vscode";
1617
import * as path from "path";
1718
import {
1819
PackageDependenciesProvider,
@@ -51,7 +52,8 @@ suite("PackageDependencyProvider Test Suite", function () {
5152
const dep = items.find(n => n.name === "swift-markdown") as PackageNode;
5253
expect(dep).to.not.be.undefined;
5354
expect(dep?.location).to.equal("https://github.com/swiftlang/swift-markdown.git");
54-
expect(dep?.path).to.equal(
55+
assertPathsEqual(
56+
dep?.path,
5557
path.join(testAssetPath("dependencies"), ".build/checkouts/swift-markdown")
5658
);
5759
});
@@ -62,7 +64,7 @@ suite("PackageDependencyProvider Test Suite", function () {
6264
const dep = items.find(n => n.name === "defaultpackage") as PackageNode;
6365
expect(dep).to.not.be.undefined;
6466
expect(dep?.location).to.equal(testAssetPath("defaultPackage"));
65-
expect(dep?.path).to.equal(testAssetPath("defaultPackage"));
67+
assertPathsEqual(dep?.path, testAssetPath("defaultPackage"));
6668
});
6769

6870
test("Lists local dependency file structure", async () => {
@@ -75,21 +77,23 @@ suite("PackageDependencyProvider Test Suite", function () {
7577
const folder = folders.find(n => n.name === "Sources");
7678
expect(folder).to.not.be.undefined;
7779

78-
expect(folder?.path).to.equal(path.join(testAssetPath("defaultPackage"), "Sources"));
80+
assertPathsEqual(folder?.path, path.join(testAssetPath("defaultPackage"), "Sources"));
7981

8082
const childFolders = await treeProvider.getChildren(folder);
8183
const childFolder = childFolders.find(n => n.name === "PackageExe");
8284
expect(childFolder).to.not.be.undefined;
8385

84-
expect(childFolder?.path).to.equal(
86+
assertPathsEqual(
87+
childFolder?.path,
8588
path.join(testAssetPath("defaultPackage"), "Sources/PackageExe")
8689
);
8790

8891
const files = await treeProvider.getChildren(childFolder);
8992
const file = files.find(n => n.name === "main.swift");
9093
expect(file).to.not.be.undefined;
9194

92-
expect(file?.path).to.equal(
95+
assertPathsEqual(
96+
file?.path,
9397
path.join(testAssetPath("defaultPackage"), "Sources/PackageExe/main.swift")
9498
);
9599
});
@@ -105,18 +109,25 @@ suite("PackageDependencyProvider Test Suite", function () {
105109
expect(folder).to.not.be.undefined;
106110

107111
const depPath = path.join(testAssetPath("dependencies"), ".build/checkouts/swift-markdown");
108-
expect(folder?.path).to.equal(path.join(depPath, "Sources"));
112+
assertPathsEqual(folder?.path, path.join(depPath, "Sources"));
109113

110114
const childFolders = await treeProvider.getChildren(folder);
111115
const childFolder = childFolders.find(n => n.name === "CAtomic");
112116
expect(childFolder).to.not.be.undefined;
113117

114-
expect(childFolder?.path).to.equal(path.join(depPath, "Sources/CAtomic"));
118+
assertPathsEqual(childFolder?.path, path.join(depPath, "Sources/CAtomic"));
115119

116120
const files = await treeProvider.getChildren(childFolder);
117121
const file = files.find(n => n.name === "CAtomic.c");
118122
expect(file).to.not.be.undefined;
119123

120-
expect(file?.path).to.equal(path.join(depPath, "Sources/CAtomic/CAtomic.c"));
124+
assertPathsEqual(file?.path, path.join(depPath, "Sources/CAtomic/CAtomic.c"));
121125
});
126+
127+
function assertPathsEqual(path1: string | undefined, path2: string | undefined) {
128+
expect(path1).to.not.be.undefined;
129+
expect(path2).to.not.be.undefined;
130+
// Convert to vscode.Uri to normalize paths, including drive letter capitalization on Windows.
131+
expect(vscode.Uri.file(path1!).fsPath).to.equal(vscode.Uri.file(path2!).fsPath);
132+
}
122133
});

0 commit comments

Comments
 (0)