Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: running a folder shouldn't also run folders that share prefix#614

Merged
Skn0tt merged 4 commits into
microsoft:mainfrom
Skn0tt:fix-run-folder
Feb 25, 2025
Merged

fix: running a folder shouldn't also run folders that share prefix#614
Skn0tt merged 4 commits into
microsoft:mainfrom
Skn0tt:fix-run-folder

Conversation

@Skn0tt

@Skn0tt Skn0tt commented Feb 18, 2025

Copy link
Copy Markdown
Member

Closes microsoft/playwright#34813. When running the foo folder, we were sending foo over the wire instead of foo/. That meant that the foobar/ folder also gets executed, which isn't expected.

The fix is to include the trailing slash in the locations we send to Playwright. Because Playwright interprets /root/project/dir/ as a regular expression, I made it omit the leading slash for absolute directories. That has the same effect, because Playwright's location checker isn't strict.

@Skn0tt Skn0tt requested review from Copilot and mxschmitt February 18, 2025 13:31
@Skn0tt Skn0tt self-assigned this Feb 18, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/utils.ts:216

  • [nitpick] Consider renaming the variable 'path' to avoid potential confusion with the imported 'path' module, which may improve code clarity.
  const path = location.split(':')[0];

Comment thread src/playwrightTestServer.ts Outdated
return;
// Locations are regular expressions.
locations = locations.map(escapeRegex);
locations = locations.map(preventRegexLookalike).map(escapeRegex);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we call escapeRegex - perhaps we don't need preventRegexLookalike here at all?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

escapeRegex doesn't do anything to forward slashes. I can merge the preventRegexLookalike logic into escapeRegex if you'd prefer that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yep, that would be great. Just escape the forward slashes together with other characters.

@Skn0tt Skn0tt Feb 25, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Escaping the forward slashes wasn't enough, but removing the leading one did the trick: 42995e8

I also made sure that the exec log preserves the trailing slash for directory. path.relative likes to remove that.

Comment thread src/playwrightTestCLI.ts Outdated
@Skn0tt Skn0tt merged commit 6531eff into microsoft:main Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants