Skip to content

Commit f22021f

Browse files
committed
Test(fs): Fix test_eq_windows_file_type for Windows 7
Would otherwise fail on: ``` thread 'fs::tests::test_eq_windows_file_type' panicked at library/std/src/test_helpers.rs:53:20: called `Result::unwrap()` on an `Err` value: Os { code: 5, kind: PermissionDenied, message: "Access is denied." } ``` This came from the read-only attribute set on the test file. In order to fix this, instead of simply disabling the test, the attribute is reset before the test's end so it may still run successfully. Signed-off-by: Paul Mabileau <[email protected]>
1 parent 36ad75b commit f22021f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

library/std/src/fs/tests.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1760,8 +1760,14 @@ fn test_eq_windows_file_type() {
17601760
// Change the readonly attribute of one file.
17611761
let mut perms = file1.metadata().unwrap().permissions();
17621762
perms.set_readonly(true);
1763-
file1.set_permissions(perms).unwrap();
1763+
file1.set_permissions(perms.clone()).unwrap();
17641764
assert_eq!(file1.metadata().unwrap().file_type(), file2.metadata().unwrap().file_type());
1765+
1766+
// Reset the attribute before the `TmpDir`'s drop that removes the
1767+
// associated directory, which fails with a `PermissionDenied` error when
1768+
// running under Windows 7.
1769+
perms.set_readonly(false);
1770+
file1.set_permissions(perms).unwrap();
17651771
}
17661772

17671773
/// Regression test for https://github.com/rust-lang/rust/issues/50619.

0 commit comments

Comments
 (0)