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

path: fix basename() regressions #6590

Merged
merged 3 commits into from
May 18, 2016
Merged

Conversation

mscdex
Copy link
Contributor

@mscdex mscdex commented May 5, 2016

Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • the commit message follows commit guidelines
Affected core subsystem(s)
  • path
Description of change

This commit fixes a regression in basename() for the case when a supplied extension name completely matches the resulting basename.

Fixes: #6587

@mscdex mscdex added path Issues and PRs related to the path subsystem. land-on-v5.x labels May 5, 2016
@mscdex
Copy link
Contributor Author

mscdex commented May 5, 2016

@jasnell
Copy link
Member

jasnell commented May 5, 2016

@mscdex ... just for purposes of keeping track, was this related to the performance changes that landed in v5 or separate issue? (@nodejs/lts has been keeping an eye on the path changes and related regressions in case we decide to pull those in to v4 at some point)

@jasnell
Copy link
Member

jasnell commented May 5, 2016

Unrelated build bot failure in CI (https://ci.nodejs.org/job/node-test-commit-arm/3146/nodes=armv8-ubuntu1404/console). LGTM otherwise. No specific comments on the commits.

@mscdex
Copy link
Contributor Author

mscdex commented May 5, 2016

@jasnell Yes, this is fixing a regression from the path rewrite I did in node v5.

assert.equal(path.basename('aaa/bbb', 'bbb'), 'bbb');
assert.equal(path.basename('aaa/bbb//', 'bbb'), 'bbb');
assert.equal(path.basename('aaa/bbb', 'bb'), 'b');
assert.equal(path.basename('aaa/bbb', 'b'), 'bb');
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a few tests for absolute paths with this case?

Copy link
Contributor Author

@mscdex mscdex May 10, 2016

Choose a reason for hiding this comment

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

I've now added absolute versions of these tests, is that what you meant?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking maybe something more like path.basename('/aaa/bbb') since we have seen regressions for absolute vs relative paths. They may already be there though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I've added that and a couple more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@evanlucas does this LGTY now?

@mscdex mscdex force-pushed the path-basename-fix-6587 branch 3 times, most recently from b274124 to f1595e1 Compare May 10, 2016 14:38
@evanlucas
Copy link
Contributor

LGTM if CI is happy

@mscdex
Copy link
Contributor Author

mscdex commented May 11, 2016

assert.throws(path.win32.basename.bind(null, true), TypeError);
assert.throws(path.win32.basename.bind(null, 1), TypeError);
assert.throws(path.win32.basename.bind(null), TypeError);
assert.throws(path.win32.basename.bind(null, {}), TypeError);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering, why were these tests removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The TypeError checks are already done later on in the test file
for all path functions.

@mscdex
Copy link
Contributor Author

mscdex commented May 18, 2016

One last CI before landing, just in case: https://ci.nodejs.org/job/node-test-pull-request/2684/

This commit fixes a regression in basename() for the case when a
supplied extension name completely matches the resulting basename.

Fixes: nodejs#6587
PR-URL: nodejs#6590
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
The TypeError checks are already done later on in the test file
for all path functions.

PR-URL: nodejs#6590
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
PR-URL: nodejs#6590
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
@mscdex mscdex merged commit 27549f6 into nodejs:master May 18, 2016
@mscdex mscdex deleted the path-basename-fix-6587 branch May 18, 2016 06:19
Fishrock123 pushed a commit that referenced this pull request May 23, 2016
This commit fixes a regression in basename() for the case when a
supplied extension name completely matches the resulting basename.

Fixes: #6587
PR-URL: #6590
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Fishrock123 pushed a commit that referenced this pull request May 23, 2016
The TypeError checks are already done later on in the test file
for all path functions.

PR-URL: #6590
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Fishrock123 pushed a commit that referenced this pull request May 23, 2016
PR-URL: #6590
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
rvagg pushed a commit that referenced this pull request Jun 2, 2016
This commit fixes a regression in basename() for the case when a
supplied extension name completely matches the resulting basename.

Fixes: #6587
PR-URL: #6590
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
rvagg pushed a commit that referenced this pull request Jun 2, 2016
The TypeError checks are already done later on in the test file
for all path functions.

PR-URL: #6590
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
rvagg pushed a commit that referenced this pull request Jun 2, 2016
PR-URL: #6590
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
path Issues and PRs related to the path subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Why path.basename behaves differently by platform?
5 participants