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

Standard library test failure with read_link on Windows 10 #90669

Closed
petrochenkov opened this issue Nov 7, 2021 · 4 comments · Fixed by #90790
Closed

Standard library test failure with read_link on Windows 10 #90669

petrochenkov opened this issue Nov 7, 2021 · 4 comments · Fixed by #90790
Assignees
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. O-windows Operating system: Windows T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@petrochenkov
Copy link
Contributor

petrochenkov commented Nov 7, 2021

---- fs::tests::read_link stdout ----
thread 'fs::tests::read_link' panicked at 'assertion failed: `(left == right)`
  left: `"c:\\ProgramData"`,
 right: `"C:\\ProgramData"`', library\std\src\fs\tests.rs:836:9

The failing assert is

        // directory symlink
        assert_eq!(
            check!(fs::read_link(r"C:\Users\All Users")).to_str().unwrap(),
            r"C:\ProgramData"
        );

I don't know why my Windows is special in this way and the All Users symlink contains the drive letter C in lowercase, this version of Windows was pre-installed on an HP laptop.
Anyway, the Rust test suite fails due to this easily fixable mismatch.

@petrochenkov petrochenkov added A-testsuite Area: The testsuite used to check the correctness of rustc O-windows Operating system: Windows T-libs Relevant to the library team, which will review and decide on the PR/issue. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Nov 7, 2021
@petrochenkov
Copy link
Contributor Author

Other links in the test have the same lowercase issue:

--- a/library/std/src/fs/tests.rs
+++ b/library/std/src/fs/tests.rs
@@ -835,17 +835,17 @@ fn read_link() {
         // directory symlink
         assert_eq!(
             check!(fs::read_link(r"C:\Users\All Users")).to_str().unwrap(),
-            r"C:\ProgramData"
+            r"c:\ProgramData"
         );
         // junction
         assert_eq!(
             check!(fs::read_link(r"C:\Users\Default User")).to_str().unwrap(),
-            r"C:\Users\Default"
+            r"c:\Users\Default"
         );
         // junction with special permissions
         assert_eq!(
             check!(fs::read_link(r"C:\Documents and Settings\")).to_str().unwrap(),
-            r"C:\Users"
+            r"c:\Users"
         );
     }
     let tmpdir = tmpdir();

@the8472
Copy link
Member

the8472 commented Nov 7, 2021

It might not be a good idea to hardcode these paths in general. I'm not sure what the state of things is with windows 10 but with windows 7 it was at least possible to install on other drives than C:\ and so they might not even exist.

@ChrisDenton
Copy link
Member

Whichever drive you install Windows on, they system drive will be labelled C: from within the running system. And certain directories must be on the system drive, e.g. the Windows and Users folders. However those folders could, potentially, be called something different. It's happened before with "Documents and Settings" being renamed "Users", hence the existence of all the symlinks being tested. That said, I think it's pretty unlikely to change again anytime soon. But it is possible.

In any case the simple fix here is to compare Paths rather than strings.

@tamaroning
Copy link
Contributor

@rustbot claim

workingjubilee added a commit to workingjubilee/rustc that referenced this issue Nov 15, 2021
…-Simulacrum

Fix standard library test with read_link

closes rust-lang#90669
resolve this issue by comparing between Paths instead of strs
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Nov 15, 2021
…-Simulacrum

Fix standard library test with read_link

closes rust-lang#90669
resolve this issue by comparing between Paths instead of strs
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 15, 2021
…-Simulacrum

Fix standard library test with read_link

closes rust-lang#90669
resolve this issue by comparing between Paths instead of strs
@bors bors closed this as completed in aaac528 Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. O-windows Operating system: Windows T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants