mirror of
https://github.com/rust-lang/cargo
synced 2024-08-25 10:35:53 +00:00
tests: registry: revert readonly permission after running tests.
Fixes #6943
This commit is contained in:
parent
1b4fab3263
commit
235fcbecc2
|
@ -2003,25 +2003,28 @@ fn readonly_registry_still_works() {
|
|||
|
||||
p.cargo("generate-lockfile").run();
|
||||
p.cargo("fetch --locked").run();
|
||||
chmod_readonly(&paths::home());
|
||||
chmod_readonly(&paths::home(), true);
|
||||
p.cargo("build").run();
|
||||
// make sure we un-readonly the files afterwards so "cargo clean" can remove them (#6934)
|
||||
chmod_readonly(&paths::home(), false);
|
||||
|
||||
fn chmod_readonly(path: &Path) {
|
||||
|
||||
fn chmod_readonly(path: &Path, readonly: bool) {
|
||||
for entry in t!(path.read_dir()) {
|
||||
let entry = t!(entry);
|
||||
let path = entry.path();
|
||||
if t!(entry.file_type()).is_dir() {
|
||||
chmod_readonly(&path);
|
||||
chmod_readonly(&path, readonly);
|
||||
} else {
|
||||
set_readonly(&path);
|
||||
set_readonly(&path, readonly);
|
||||
}
|
||||
}
|
||||
set_readonly(path);
|
||||
set_readonly(path, readonly);
|
||||
}
|
||||
|
||||
fn set_readonly(path: &Path) {
|
||||
fn set_readonly(path: &Path, readonly: bool) {
|
||||
let mut perms = t!(path.metadata()).permissions();
|
||||
perms.set_readonly(true);
|
||||
perms.set_readonly(readonly);
|
||||
t!(fs::set_permissions(path, perms));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue