-
Notifications
You must be signed in to change notification settings - Fork 13.3k
readLink() testcase failed with localized non-english language? #93211
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
Comments
Do you happen to have access to any german-language Windows 10 machines? I'm curious if this localization is new in Windows 11, or pre-existing. |
@eddyb I have a laptop from work which runs Windows 10 Enterprise in German, Version 21H1. The cmd output is the same, with Dokumente und Einstellungen as junction instead of Documents and settings |
Weird, this is on my Windows 10 laptop:
It might depend on the system language used for installation. I think we should just disable the assert, if |
@hkratz Interesting, but yes I think you are right, that it depends on the system language used for installation. |
Wow, looks like this was added almost 6 years ago, in #31630, and not touched since. I'm surprised nobody ran into this before, seems like it would be an issue with any localized Windows. (Another aspect is that I've had to deal with Romanian-localized Windows and I don't ever recall seeing Maybe it only happens if the localization was used during installation, or maybe you have a "localized OEM" edition? If this didn't take up time and whatnot, I would consider playing around with Windows VMs just to see what conditions are required to get the file system in that state. Removing the case from the test seems like it might leave some codepath untested, I wonder what "junction with special permissions" means and if there is some unlocalized one by default on Windows. |
We can also try creating one if needed. At least CI has admin permissions. |
I think the best option would be for the test to create a symlink (and/or juncture point) itself, set the permissions on that and then try to read the link. That way the test will run independently of whether a specific directory exists or not. However, I don't think we currently have any code for setting permissions on Windows so that would need to be written by someone. |
I also had that idea in mind. But wouldn't we then have to execute the test itself with admin rights? When the test case set permissions itself? Because I am not sure if windows allows to run code, which changes permissions, in non admin mode. But if the requirement for compiler tests is, to have admin rights, then this shouldn't be a problem. But I thought, that compiler tests should run without admin rights, could be a mistake on my site though.
There she goes, my hope for my first pull request :P |
You can set permissions on ones you created because the user will own them by default. So this shouldn't require admin rights.
Hm, perhaps we could temporarily skip that part of the test when the directory isn't found, and add a "FIXME" comment saying someone needs to write a fallback implementation? Though I'd ask @the8472 if that's ok as a temporary measure? |
The main concern would be that the next CI runner update might silently break this if microsoft decides to not created it on newer windows versions. So it's a tradeoff between running the tests on some non-english machines vs. having this particular case reliably covered in CI. To have our cake and eat it too we could make the test mandatory in CI but optional on local machines, e.g by checking the |
Do you mean something like that? fn snippet() {
let var = "CI";
match env::var(var) {
Ok(val) => if val == "true" {assert_eq!(check!(fs::read_link(r"C:\Documents and settings\")), Path::new(r"C:\Users"));},
Err(e) => println!("Test case can be skipped"),
}
} |
Kind of, but I meant:
|
fn snippet() {
let var = "CI";
match env::var(var) {
Ok(val) => assert_eq!(check!(fs::read_link(r"C:\Documents and settings\")), Path::new(r"C:\Users")),
Err(e) => if Path::new(r"C:\Documents and settings\").exists() {
assert_eq!(check!(fs::read_link(r"C:\Documents and settings\")), Path::new(r"C:\Users"))
} else { println!("Path does not exist => Skip the test.") },
}
} Okay, then something like that this should to the job? |
Roughly, the details can be discussed in PR review. |
So I can create my first PR? :) Do I have to claim? |
Yes, you don't need to ask for permission for that. At worst there'll be some reason it can't be accepted. |
@rustbot claim |
Fix for localized windows editions in testcase fn read_link() Issue#93211 This PR aims to fix the issue with localized windows versions that do not necessarily have the folder "Documents and settings" in English. The idea was provided by `@the8472.` We check if the "CI" environment variable is set, then we always check for the "Documents and Settings"-folder, otherwise we check if the folder exists on the local machine, and if not we skip this assert. Resoles rust-lang#93211.
Hey!
I am not sure if this is directly a bug on the compiler test case or if it is my machine's fault.
My OS is Windows 11 Pro with version: 10.0.22000 Build 22000.
I built the compiler for the first time, set everything up (toolchains, etc.), and never got an error so far.
./x.py check
succeeded instantly as well.But as soon as I tried to run the following test,
./x.py test --stage 0 library/std
without any changes made to the compiler, 1 test case failed.
The test case fn readLink() in:
library\std\src\fs\tests.rs:839:20
is the problem, or to be more precise, the last assert_eq!in theif cfg!(windows){/.../}
This won't pass:
This will pass:
I expected to see the test pass, but it seems, that if the junction is not called in English, the test will fail.
Instead, I got the following error (long error below):
thread 'fs::tests::read_link' panicked at 'fs::read_link(r"C:\Documents and settings\") failed with: The system cannot find the file specified. (os error 2)', library\std\src\fs\tests.rs:839:20
Finally, I am not sure if this is an "error" in the test case or if my windows is broken, because I set the origin language (german) to English.
I included my cmd output which shows the junction is in german.
Dokumente und Einstellungen means Documents and Settings in German
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: