Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

additional edge cases tests for path.rs 🧪 #141105

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
Loading
from

Conversation

GrantBirki
Copy link

This pull request adds a few new edge case tests to the std::path module. The new tests cover scenarios such as paths with only separators, non-ASCII and Unicode characters, embedded null bytes, etc. Each new test is documented with some helpful in-line comments as well.

@rustbot
Copy link
Collaborator

rustbot commented May 16, 2025

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 16, 2025
@rust-log-analyzer

This comment has been minimized.

@GrantBirki
Copy link
Author

It appears that mingw-check-tidy failed, but I am not sure how to correct it. Perhaps its a linter of some sort?

@ChaiTRex
Copy link
Contributor

It appears that mingw-check-tidy failed, but I am not sure how to correct it. Perhaps its a linter of some sort?

mingw-check also failed. Click on CI / PR - mingw-check (pull_request) and see the compiler errors toward the bottom.

@ChaiTRex
Copy link
Contributor

It looks as if OsStrExt and OsStringExt have different methods on Windows than other platforms.

@workingjubilee
Copy link
Member

Yes, please fix the tests to only use functions from OsStr and OsString OR cfg the tests.

@rust-log-analyzer

This comment has been minimized.

library/std/tests/path.rs Outdated Show resolved Hide resolved
Comment on lines +2002 to +2004
// Test: Reserved device names (Windows)
// This test ensures that reserved device names like "CON", "PRN", etc., are handled as normal paths on non-Windows platforms,
// and as special cases on Windows (if applicable).
Copy link
Member

Choose a reason for hiding this comment

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

This comment doesn't seem to describe the test.

Comment on lines +2015 to +2017
// Test: Trailing dots/spaces (Windows)
// This test checks how Path handles trailing dots or spaces, which are special on Windows.
// On Unix, these should be treated as normal characters.
Copy link
Member

Choose a reason for hiding this comment

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

Path mostly works the same across platforms (separator differences and roots/prefixes not withstanding). If there's a difference then you should have tests for both Windows and non-Windows that shows the difference.

Comment on lines +2033 to +2035
// Test: Only extension (e.g., ".gitignore")
// This test verifies that files with only an extension and no base name are handled correctly.
// It checks that the extension is recognized and the file stem is None or empty as appropriate.
Copy link
Member

Choose a reason for hiding this comment

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

Do we really not have a test for this anywhere else?

Copy link
Author

Choose a reason for hiding this comment

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

Actually I think you are right and this is tested already here:

rust/library/std/tests/path.rs

Lines 1127 to 1130 in 2c12b4a

t!(".foo",
file_stem: Some(".foo"),
extension: None
);

Comment on lines +2044 to +2046
// Test: Long components
// This test checks that Path can handle very long path components without truncation or error.
// It ensures that the length of the component is preserved.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why this would be useful for us specifically? We don't usually check that slice wrappers work on the whole slice.

Copy link
Author

Choose a reason for hiding this comment

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

I'll remove this test and a few others that we think aren't the most useful perhaps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.