Skip to content

readLink() testcase failed with localized non-english language? #93211

Closed
@m1guelperez

Description

@m1guelperez

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 the
if cfg!(windows){/.../}

This won't pass:

#[test]
fn read_link() {
    if cfg!(windows) {
        // directory symlink
        assert_eq!(check!(fs::read_link(r"C:\Users\All Users")), Path::new(r"C:\ProgramData"));
        // junction
        assert_eq!(check!(fs::read_link(r"C:\Users\Default User")), Path::new(r"C:\Users\Default"));
        // junction with special permissions
        assert_eq!(check!(fs::read_link(r"C:\Documents and settings\")), Path::new(r"C:\Users"));
    }
    let tmpdir = tmpdir();
    let link = tmpdir.join("link");
    if !got_symlink_permission(&tmpdir) {
        return;
    };
    check!(symlink_file(&"foo", &link));
    assert_eq!(check!(fs::read_link(&link)).to_str().unwrap(), "foo");
}

This will pass:

fn read_link() {
    if cfg!(windows) {
        // directory symlink
        assert_eq!(check!(fs::read_link(r"C:\Users\All Users")), Path::new(r"C:\ProgramData"));
        // junction
        assert_eq!(check!(fs::read_link(r"C:\Users\Default User")), Path::new(r"C:\Users\Default"));
        // junction with special permissions
        assert_eq!(check!(fs::read_link(r"C:\Dokumente und Einstellungen\")), Path::new(r"C:\Users"));
    }
    let tmpdir = tmpdir();
    let link = tmpdir.join("link");
    if !got_symlink_permission(&tmpdir) {
        return;
    };
    check!(symlink_file(&"foo", &link));
    assert_eq!(check!(fs::read_link(&link)).to_str().unwrap(), "foo");
}

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

Junction

Meta

rustc --version --verbose:

rustc 1.60.0-nightly (777bb86bc 2022-01-20)
binary: rustc
commit-hash: 777bb86bcdbc568be7cff6eeeaaf81a89b4aa50b
commit-date: 2022-01-20
host: x86_64-pc-windows-msvc
release: 1.60.0-nightly
LLVM version: 13.0.0
Backtrace

failures:

---- fs::tests::read_link stdout ----
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


failures:
    fs::tests::read_link

test result: FAILED. 896 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 10.90s

error: test failed, to rerun pass '-p std --lib'


command did not execute successfully: "\\\\?\\C:\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "test" "--target" "x86_64-pc-windows-msvc" "-Zbinary-dep-depinfo" "-j" "20" "--release" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "C:\\rust\\library/test/Cargo.toml" "-p" "std" "--" "--quiet"
expected success, got: exit code: 101

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions