Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure all paths use uppercase drive letter #587

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

dgozman
Copy link
Contributor

@dgozman dgozman commented Jan 8, 2025

VSCode expects lowercase drive letter, while Playwright expects uppercase drive letter. This introduces bugs where we accidentally use two different casings for paths.

To achieve this and avoid future issues with path casing mismatch:

  • make mock vscode lowercase the drive letter to match real vscode - this exposed a few tests that fail due to drive letter mismatch:
      [default] › global-errors.spec.ts:19:5 › should report duplicate test title ────────────────────
      [default] › list-tests.spec.ts:442:5 › should forget tests after error before first test ───────
      [default] › problems.spec.ts:55:5 › should update diagnostics on file change ───────────────────
      [default] › watch.spec.ts:24:5 › should watch all tests ────────────────────────────────────────
      [default] › watch.spec.ts:147:5 › should watch test file ───────────────────────────────────────
      [default] › watch.spec.ts:198:5 › should watch tests via helper ────────────────────────────────
    
  • internally, use Playwright-style uppercase drive letter paths everywhere;
  • when interacting with VSCode through uri, either use uriToPath(uri) or vscode.Uri.file(path);
  • ban Uri.fsPath so that we never use VSCode-style lowercase paths.

This change superseedes #584.

Fixes microsoft/playwright#34146.
Fixes microsoft/playwright#33671.

@@ -45,7 +46,7 @@ export async function installPlaywright(vscode: vscodeTypes.VSCode) {

const terminal = vscode.window.createTerminal({
name: 'Install Playwright',
cwd: workspaceFolder.uri.fsPath,
cwd: uriToPath(workspaceFolder.uri),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting an example of VSCode API that accepts string.

const watcher = this._vscode.workspace.createFileSystemWatcher(folder.replaceAll(path.sep, '/') + '/**');
// Make sure to use lowercase drive letter in the pattern.
// eslint-disable-next-line no-restricted-properties
const watcher = this._vscode.workspace.createFileSystemWatcher(this._vscode.Uri.file(folder).fsPath.replaceAll(path.sep, '/') + '/**');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another API that takes string!

Dmitry Gozman (from Dev Box) added 2 commits January 10, 2025 15:27
VSCode expects lowercase drive letter, while Playwright expects
uppercase drive letter. To properly test this, update vscode mock
to match vscode proper, which reveals a few failing tests:
- watch fails because it tries to watch lowercase paths in Playwright;
- errors through diagnostics fail because they update with both
  lowercase and uppercase paths.
To achieve this and avoid future issues with path casing mismatch:
- internally, use Playwright-style uppercase drive letter paths;
- when interacting with VSCode through uri, either use `uriToPath(uri)` or
  `vscode.Uri.file(path)`;
- ban `Uri.fsPath` so that we never use VSCode-style lowercase paths.
@dgozman dgozman merged commit 4068938 into microsoft:main Jan 10, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants