-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Test if reserved filenames are allowed in Windows #10322
Conversation
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. If I want to verify the behavior of this patch. What environment should I prepare? Specifically, can you provide some official doc about this change? Thanks!
I'm on the Windows 11 Insiders Beta channel, and winver says it's version 21H2 (OS Build 22000.466). Unfortunately, I haven't been able to find official documentation about the change, but I did confirm the behavior with the Windows dev who made the change. |
Could you post a transcript of the test failure (including with nocapture so we can see the actual test output)? |
Sure, here's the output from
|
So, reading that test case, I don't think that's a test that should pass in general, even if the platform doesn't actually reserve such filenames. The logic that checks for I think, rather than changing the test so its behavior depends on the OS, this should instead change the implementation of the code that this test tests to ensure that it catches reserved filenames on all versions of Windows. |
That seems reasonable. If I remember right, the code for publishing packages tries to prevent you from publishing packages that couldn't be unpacked on all OSes supported by Cargo, so it makes sense to have similar behavior for unpacking packages. In that case though, I think we should also remove the |
Exactly.
Agreed. |
I decided to close this PR in favor of #10461 which cleanly does what was decided in the discussion here. |
Reopening this since there's disagreement about whether we want this change or the one in #10461. We only need one of these to land though. |
Per discussion on Zulip, this approach seems fine to me, as long as it doesn't actually use the same code in both this check and the code being tested (which would be circular). In that spirit, and in the spirit of not providing this as a public API of Cargo, could you move this function into the test code rather than the util module? |
46cbe37
to
a1e0981
Compare
Yup, that's done now! I moved it to the |
Seems reasonable to me. Does anyone see an issue with adding that dependency to the test support crate? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry for the super long delay. I didn't have a Windows 11 system handy. I would be happy to get this merged with a small change.
Recent versions of Windows have removed the limitation on filenames like `aux` or `con`. This change allows the `package::reserved_windows_name` to still pass by first trying to create a file with a reserved name to see if Windows supports it. If so, it skips the rest of the test. Otherwise, we keep the same behavior as before.
The previous commit tests whether the current machine supports Windows restricted names by creating a file and checking whether that succeeds. This commit reworks this testto use GetFullPathNameW, which can be done without having to create and remove new files.
a1e0981
to
e9c7544
Compare
Thanks! @bors r+ |
☀️ Test successful - checks-actions |
Update cargo 7 commits in 4fd148c47e733770c537efac5220744945d572ef..ce40690a5e4e315d3dab0aae1eae69d0252c52ac 2022-08-03 15:03:52 +0000 to 2022-08-09 22:32:17 +0000 - Make the `rust-version` error recommend `cargo update --precise -p crate@ver` (rust-lang/cargo#10891) - resolver docs: link to version requirements syntax full explanation (rust-lang/cargo#10946) - Bump os_info to 3.5.0 (rust-lang/cargo#10943) - Mark --timings=html unstable in the document (rust-lang/cargo#10941) - Mention that aliases are recursive (rust-lang/cargo#10935) - Test if reserved filenames are allowed in Windows (rust-lang/cargo#10322) - improve error message for `no such subcommand` (rust-lang/cargo#10924)
Recent versions of Windows have removed the limitation on filenames like
aux
orcon
. This change allows thepackage::reserved_windows_name
to still pass by first trying to create a file with a reserved name to see if Windows supports it. If so, it skips the rest of the test. Otherwise, we keep the same behavior as before.