Skip to content

Commit c4fcfb7

Browse files
committed
Auto merge of #6947 - matthiaskrgr:test_permission_fix, r=alexcrichton
tests: registry: revert readonly permission after running tests. Fixes #6943
2 parents 1ae512d + 235fcbe commit c4fcfb7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/testsuite/registry.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -2003,25 +2003,28 @@ fn readonly_registry_still_works() {
20032003

20042004
p.cargo("generate-lockfile").run();
20052005
p.cargo("fetch --locked").run();
2006-
chmod_readonly(&paths::home());
2006+
chmod_readonly(&paths::home(), true);
20072007
p.cargo("build").run();
2008+
// make sure we un-readonly the files afterwards so "cargo clean" can remove them (#6934)
2009+
chmod_readonly(&paths::home(), false);
20082010

2009-
fn chmod_readonly(path: &Path) {
2011+
2012+
fn chmod_readonly(path: &Path, readonly: bool) {
20102013
for entry in t!(path.read_dir()) {
20112014
let entry = t!(entry);
20122015
let path = entry.path();
20132016
if t!(entry.file_type()).is_dir() {
2014-
chmod_readonly(&path);
2017+
chmod_readonly(&path, readonly);
20152018
} else {
2016-
set_readonly(&path);
2019+
set_readonly(&path, readonly);
20172020
}
20182021
}
2019-
set_readonly(path);
2022+
set_readonly(path, readonly);
20202023
}
20212024

2022-
fn set_readonly(path: &Path) {
2025+
fn set_readonly(path: &Path, readonly: bool) {
20232026
let mut perms = t!(path.metadata()).permissions();
2024-
perms.set_readonly(true);
2027+
perms.set_readonly(readonly);
20252028
t!(fs::set_permissions(path, perms));
20262029
}
20272030
}

0 commit comments

Comments
 (0)